mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inference: erasure functional type for raw substitutors (IDEA-154759)
This commit is contained in:
@@ -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();
|
||||
|
||||
+20
@@ -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>();
|
||||
});
|
||||
}
|
||||
}
|
||||
+4
@@ -304,6 +304,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRawSiteSubstitutorWithExpectedGenericsParameterType() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user