inference: don't distinguish parameterizations with 2 different interfaces (IDEA-163950)

This commit is contained in:
Anna.Kozlova
2016-11-15 18:11:31 +01:00
parent 38116b22c1
commit 39aa837db3
3 changed files with 38 additions and 1 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -140,7 +140,12 @@ public class TypesDistinctProver {
if (level < 2) return false;
}
if (boundClass1 == null || boundClass2 == null) {
return type1 != null && type2 != null && !type1.equals(type2);
}
return type2 != null && type1 != null && !type1.equals(type2) &&
!(boundClass1.isInterface() && boundClass2.isInterface()) &&
(!InheritanceUtil.isInheritorOrSelf(boundClass1, boundClass2, true) ||
!InheritanceUtil.isInheritorOrSelf(boundClass2, boundClass1, true));
}
@@ -0,0 +1,28 @@
class Test {
{
Marker<String> cm = forEach(child1(), child2());
}
public static <D> Child1<D> child1() {
return null;
}
public static <S> Child2<S> child2() {
return null;
}
public static <F, CM extends Marker<F>> CM forEach(CM contents, CM cm) {
return null;
}
interface Marker<A> {}
static class Parent<S> {}
static class Child1<D> extends Parent<ChildAttr1> implements Marker<D> {}
interface ChildAttr1 {}
static class Child2<S> extends Parent<ChildAttr2> implements Marker<S> {}
interface ChildAttr2 {}
}
@@ -487,6 +487,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testTwoDifferentParameterizationCheckWithInterfaceTypeArguments() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(false);
}