mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
method refs/lambda: types assignability (IDEA-92786)
This commit is contained in:
@@ -656,6 +656,14 @@ public class TypeConversionUtil {
|
||||
final PsiMethodReferenceExpression methodReferenceExpression = ((PsiMethodReferenceType)right).getExpression();
|
||||
if (left instanceof PsiClassType) {
|
||||
return LambdaUtil.isAcceptable(methodReferenceExpression, (PsiClassType)left);
|
||||
} else if (left instanceof PsiLambdaExpressionType) {
|
||||
final PsiType rType = methodReferenceExpression.getFunctionalInterfaceType();
|
||||
final PsiType lType = ((PsiLambdaExpressionType)left).getExpression().getFunctionalInterfaceType();
|
||||
return Comparing.equal(rType, lType);
|
||||
} else if (left instanceof PsiMethodReferenceType) {
|
||||
final PsiType rType = methodReferenceExpression.getFunctionalInterfaceType();
|
||||
final PsiType lType = ((PsiMethodReferenceType)left).getExpression().getFunctionalInterfaceType();
|
||||
return Comparing.equal(rType, lType);
|
||||
}
|
||||
}
|
||||
if (right instanceof PsiLambdaExpressionType) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
class Test {
|
||||
void foo(boolean flag) {
|
||||
Runnable r = null;
|
||||
Runnable x1 = flag ? System.out::println : System.out::println;
|
||||
Runnable x2 = flag ? r : System.out::println;
|
||||
Runnable x3 = flag ? System.out::println : r;
|
||||
Runnable x4 = flag ? System.out::println : new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
};
|
||||
Runnable x5 = flag ? System.out::println : () -> {
|
||||
};
|
||||
Runnable x6 = flag ? () -> {} : System.out::println;
|
||||
Runnable x7 = flag ? () -> {} : () -> {};
|
||||
Runnable x8 = flag ? new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
} : () -> {};
|
||||
Runnable x9 = flag ? () -> {} : r;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user