take into account containing class type params when accepting assignability (IDEA-71582)

This commit is contained in:
anna
2013-10-23 15:50:00 +02:00
parent 02a4914ff4
commit e3a799dff4
3 changed files with 18 additions and 3 deletions

View File

@@ -900,16 +900,17 @@ public class TypeConversionUtil {
PsiClass leftClass = leftResult.getElement();
PsiClass rightClass = rightResult.getElement();
if (!leftClass.hasTypeParameters()) return true;
Iterator<PsiTypeParameter> li = PsiUtil.typeParametersIterator(leftClass);
if (!li.hasNext()) return true;
PsiSubstitutor leftSubstitutor = leftResult.getSubstitutor();
if (!leftClass.getManager().areElementsEquivalent(leftClass, rightClass)) {
rightSubstitutor = getSuperClassSubstitutor(leftClass, rightClass, rightSubstitutor);
rightClass = leftClass;
}
else if (!rightClass.hasTypeParameters()) return true;
else if (!PsiUtil.typeParametersIterator(rightClass).hasNext()) return true;
Iterator<PsiTypeParameter> li = PsiUtil.typeParametersIterator(leftClass);
Iterator<PsiTypeParameter> ri = PsiUtil.typeParametersIterator(rightClass);
while (li.hasNext()) {
if (!ri.hasNext()) return false;

View File

@@ -0,0 +1,13 @@
class Main {
static class C<T>
{
class D{}
}
void test()
{
C<String>.D o1 = null;
C<Object>.D o2 = null;
<error descr="Incompatible types. Found: 'Main.C<java.lang.Object>.D', required: 'Main.C<java.lang.String>.D'">o1 = o2</error>;
}
}

View File

@@ -328,6 +328,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA63331() { doTest5(false); }
public void testIDEA60836() { doTest5(false); }
public void testIDEA54197() { doTest5(false); }
public void testIDEA71582() { doTest5(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));