mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 22:11:40 +07:00
lambda: check formal types for equality
This commit is contained in:
@@ -141,12 +141,12 @@ public class LambdaUtil {
|
||||
final PsiType lambdaFormalType = typeElement.getType();
|
||||
final PsiType methodParameterType = parameterTypes[lambdaParamIdx];
|
||||
if (lambdaFormalType instanceof PsiPrimitiveType) {
|
||||
if (methodParameterType instanceof PsiPrimitiveType) return methodParameterType.isAssignableFrom(lambdaFormalType);
|
||||
if (methodParameterType instanceof PsiPrimitiveType) return methodParameterType.equals(lambdaFormalType);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!resolveResult.getSubstitutor().substitute(methodSignature.getSubstitutor().substitute(methodParameterType))
|
||||
.isAssignableFrom(lambdaFormalType)) {
|
||||
if (!lambdaFormalType
|
||||
.equals(resolveResult.getSubstitutor().substitute(methodSignature.getSubstitutor().substitute(methodParameterType)))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
{
|
||||
<error descr="Incompatible types. Found: '<lambda expression>', required: 'java.lang.Comparable'">Comparable c = (String o)->{
|
||||
return 0;
|
||||
};</error>
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,10 @@ public class LambdaParamsTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRaw() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user