mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
ensure fresh variables for the same context don't conflict by names (IDEA-196642)
This commit is contained in:
@@ -1027,6 +1027,7 @@ public class InferenceSession {
|
||||
|
||||
protected void resolveBounds(final Collection<InferenceVariable> inferenceVariables,
|
||||
@NotNull PsiSubstitutor substitutor) {
|
||||
final UniqueNameGenerator uniqueNameGenerator = new UniqueNameGenerator();
|
||||
final Collection<InferenceVariable> allVars = new ArrayList<>(inferenceVariables);
|
||||
while (!allVars.isEmpty()) {
|
||||
final List<InferenceVariable> vars = InferenceVariablesOrder.resolveOrder(allVars, this);
|
||||
@@ -1054,7 +1055,7 @@ public class InferenceSession {
|
||||
}
|
||||
}
|
||||
|
||||
if (!initFreshVariables(substitutor, unresolved)) {
|
||||
if (!initFreshVariables(substitutor, unresolved, uniqueNameGenerator)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1091,11 +1092,10 @@ public class InferenceSession {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean initFreshVariables(PsiSubstitutor substitutor, List<InferenceVariable> vars) {
|
||||
private boolean initFreshVariables(PsiSubstitutor substitutor, List<InferenceVariable> vars, UniqueNameGenerator nameGenerator) {
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(getManager().getProject());
|
||||
PsiSubstitutor ySubstitutor = PsiSubstitutor.EMPTY;
|
||||
final PsiTypeParameter[] yVars = new PsiTypeParameter[vars.size()];
|
||||
UniqueNameGenerator nameGenerator = new UniqueNameGenerator();
|
||||
for (int i = 0; i < vars.size(); i++) {
|
||||
InferenceVariable var = vars.get(i);
|
||||
final PsiTypeParameter parameter = var.getParameter();
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class MyTest {
|
||||
|
||||
static class Foo<A> {}
|
||||
|
||||
static <B> void bar(Foo<? super B> f1, Foo<? super B> f2) { }
|
||||
|
||||
{
|
||||
bar<error descr="'bar(MyTest.Foo<? super B>, MyTest.Foo<? super B>)' in 'MyTest' cannot be applied to '(MyTest.Foo<T>, MyTest.Foo<T>)'">(m(), m())</error>;
|
||||
}
|
||||
|
||||
static <T extends Comparable<T>> Foo<T> m() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public void testNameConflictBetweenFreshVariables() { doTest(); }
|
||||
public void testCreateFreshVariablesOnlyForWildcardPlacesDuringReturnTypeProcessing() { doTest(); }
|
||||
public void testCapturedConversionDuringDirectSuperCheck() { doTest(); }
|
||||
//public void _testResolutionOrderForVariableCycles() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user