inference: erasure functional type for raw substitutors (IDEA-154759)

This commit is contained in:
Anna.Kozlova
2016-04-14 20:59:13 +02:00
parent 6740ffecbd
commit 320aeb7b5e
4 changed files with 32 additions and 2 deletions
@@ -402,7 +402,13 @@ public class LambdaUtil {
return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, !MethodCandidateInfo.isOverloadCheck(), new Computable<PsiType>() {
@Override
public PsiType compute() {
return resolveResult.getSubstitutor().substitute(getNormalizedType(parameters[finalLambdaIdx]));
final PsiType normalizedType = getNormalizedType(parameters[finalLambdaIdx]);
if (resolveResult instanceof MethodCandidateInfo && ((MethodCandidateInfo)resolveResult).isRawSubstitution()) {
return TypeConversionUtil.erasure(normalizedType);
}
else {
return resolveResult.getSubstitutor().substitute(normalizedType);
}
}
});
}
@@ -399,7 +399,7 @@ public class MethodCandidateInfo extends CandidateInfo{
}, super.getSubstitutor(), policy.isVarargsIgnored() || isVarargs(), !includeReturnConstraint);
}
private boolean isRawSubstitution() {
public boolean isRawSubstitution() {
final PsiMethod method = getElement();
if (!method.hasModifierProperty(PsiModifier.STATIC)) {
final PsiClass containingClass = method.getContainingClass();
@@ -0,0 +1,20 @@
interface Processor<T> {
void process(T t);
}
class MySymbol<T extends String> {
void processSameSymbols(Processor<MySymbol> processor) {}
T locateDefinition() {
return (T) "";
}
void findUsages(MySymbol s) {
s.processSameSymbols(symbol -> {
String definition = symbol.<error descr="Cannot resolve method 'locateDefinition()'">locateDefinition</error>();
});
}
}
@@ -304,6 +304,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testRawSiteSubstitutorWithExpectedGenericsParameterType() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}