mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
SOE (IDEA-95955)
(cherry picked from commit d092c1363b3ae02dbfb4059f0c0cf28df575024c)
This commit is contained in:
@@ -33,6 +33,7 @@ import com.intellij.psi.impl.light.LightTypeElement;
|
||||
import com.intellij.psi.impl.source.*;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.impl.source.parsing.ParseUtilBase;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.CharTable;
|
||||
@@ -171,6 +172,9 @@ public class JavaTreeGenerator implements TreeGenerator {
|
||||
LightTypeElement te = new LightTypeElement(original.getManager(), ((PsiIntersectionType)type).getRepresentative());
|
||||
return ChangeUtil.generateTreeElement(te, table, manager);
|
||||
}
|
||||
if (type instanceof PsiMethodReferenceType || type instanceof PsiLambdaExpressionType) {
|
||||
type = PsiType.getJavaLangObject(manager, GlobalSearchScope.projectScope(manager.getProject()));
|
||||
}
|
||||
|
||||
PsiClassType classType = (PsiClassType)type;
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ public class LambdaUtil {
|
||||
else if (parent instanceof PsiVariable) {
|
||||
return ((PsiVariable)parent).getType();
|
||||
}
|
||||
else if (parent instanceof PsiAssignmentExpression) {
|
||||
else if (parent instanceof PsiAssignmentExpression && expression instanceof PsiExpression && !PsiUtil.isOnAssignmentLeftHand((PsiExpression)expression)) {
|
||||
final PsiExpression lExpression = ((PsiAssignmentExpression)parent).getLExpression();
|
||||
return lExpression.getType();
|
||||
}
|
||||
|
||||
@@ -73,13 +73,13 @@ public class PsiTypeVisitor<A> {
|
||||
final PsiLambdaExpression lambdaExpression = lambdaExpressionType.getExpression();
|
||||
final PsiType interfaceType = lambdaExpression.getFunctionalInterfaceType();
|
||||
if (interfaceType != null) return interfaceType.accept(this);
|
||||
return visitType(interfaceType);
|
||||
return visitType(lambdaExpressionType);
|
||||
}
|
||||
|
||||
public A visitMethodReferenceType(PsiMethodReferenceType methodReferenceType) {
|
||||
final PsiMethodReferenceExpression expression = methodReferenceType.getExpression();
|
||||
final PsiType interfaceType = expression.getFunctionalInterfaceType();
|
||||
if (interfaceType != null) return interfaceType.accept(this);
|
||||
return visitType(interfaceType);
|
||||
return visitType(methodReferenceType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import java.util.*;
|
||||
|
||||
class LambdaTest {
|
||||
public void testR() {
|
||||
<error descr="Incompatible types. Found: 'java.lang.String', required: '<method reference>'">new ArrayList<String>() :: size = ""</error>;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,10 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSOE() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInferenceFromReturnType() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user