mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
inference: partially resolve before erasure for target type inference
IDEA-192208
This commit is contained in:
@@ -654,13 +654,9 @@ public class InferenceSession {
|
||||
public void registerReturnTypeConstraints(PsiType returnType, PsiType targetType, PsiElement context) {
|
||||
returnType = substituteWithInferenceVariables(returnType);
|
||||
if (myErased) {
|
||||
final InferenceVariable inferenceVariable = getInferenceVariable(returnType);
|
||||
if (inferenceVariable != null) {
|
||||
final PsiSubstitutor substitutor = resolveSubset(Collections.singletonList(inferenceVariable), mySiteSubstitutor);
|
||||
returnType = substitutor.substitute(inferenceVariable);
|
||||
if (returnType == null) return;
|
||||
}
|
||||
addConstraint(new TypeCompatibilityConstraint(targetType, TypeConversionUtil.erasure(returnType)));
|
||||
PsiSubstitutor currentSubstitutor = resolveSubset(myInferenceVariables, mySiteSubstitutor);
|
||||
addConstraint(new TypeCompatibilityConstraint(targetType,
|
||||
TypeConversionUtil.erasure(currentSubstitutor.substitute(returnType))));
|
||||
}
|
||||
else if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(returnType)) {
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(returnType);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
abstract class MyTest {
|
||||
interface A<S> {}
|
||||
interface B<K> {}
|
||||
abstract <_B, _P extends A<_B>> _P foo(B<_B> data);
|
||||
|
||||
public void m(B b) {
|
||||
final A a = foo(b);
|
||||
}
|
||||
}
|
||||
@@ -191,6 +191,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
public void testVarargsMethodPreferred() { doTest(); }
|
||||
public void testSameNamedFreshVariables() { doTest(); }
|
||||
public void testEnsureOrderOfFreshVariablesWhenCaptureNonProperTypes() { doTest(); }
|
||||
public void testFreshVariablesBounds() { doTest(); }
|
||||
|
||||
public void testApplicabilityCheckFailsExpressionTypeCheckPasses() {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user