mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 21:41:24 +07:00
new inference: process fresh variables depending on resolved vars (IDEA-56775)
This commit is contained in:
@@ -747,7 +747,7 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(getManager().getProject());
|
||||
final PsiTypeParameter[] freshParameters = createFreshVariables(vars);
|
||||
final PsiTypeParameter[] freshParameters = createFreshVariables(vars, substitutor);
|
||||
for (int i = 0; i < freshParameters.length; i++) {
|
||||
PsiTypeParameter parameter = freshParameters[i];
|
||||
final InferenceVariable var = vars.get(i);
|
||||
@@ -770,7 +770,7 @@ public class InferenceSession {
|
||||
return substitutor;
|
||||
}
|
||||
|
||||
private PsiTypeParameter[] createFreshVariables(final List<InferenceVariable> vars) {
|
||||
private PsiTypeParameter[] createFreshVariables(final List<InferenceVariable> vars, final PsiSubstitutor siteSubstitutor) {
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(getManager().getProject());
|
||||
|
||||
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
|
||||
@@ -787,7 +787,7 @@ public class InferenceSession {
|
||||
final String classText = "class I<" + StringUtil.join(vars, new Function<InferenceVariable, String>() {
|
||||
@Override
|
||||
public String fun(InferenceVariable variable) {
|
||||
final PsiType glb = composeBound(variable, InferenceBound.UPPER, UPPER_BOUND_FUNCTION, ySubstitutor, true);
|
||||
final PsiType glb = composeBound(variable, InferenceBound.UPPER, UPPER_BOUND_FUNCTION, ySubstitutor.putAll(siteSubstitutor), true);
|
||||
return getFreshVariableName(variable) + " extends " + glb.getInternalCanonicalText();
|
||||
}
|
||||
}, ", ") + ">{}";
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class Test {
|
||||
|
||||
class X<F extends Foo, B extends Bar<F, B>> {
|
||||
}
|
||||
class Foo {
|
||||
}
|
||||
class Bar<A, B> {
|
||||
}
|
||||
|
||||
private <F extends Foo, B extends Bar<F, B>> X<F, B> foo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
X x = foo();
|
||||
}
|
||||
}
|
||||
@@ -240,6 +240,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFreshVariablesCreatedDuringResolveDependingOnAlreadyResolvedVariables() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user