generics: raw type should not be equal to param type (IDEA-60170)

This commit is contained in:
anna
2010-10-29 12:46:10 +04:00
parent 201a9b3b21
commit 31cb911e3f
3 changed files with 24 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
import java.util.*;
import Node.Details;
public class Node<E> {
public class Details {
public E data;
}
public Details addNode(Node<E> child) {
return new Details();
}
}
class Test {
public static void main(String[] args) {
Map<String, Details> m = null;
Map<String, Node.Details> sorted1;
sorted1 = m;
}
}

View File

@@ -101,6 +101,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testWildcardCastConversion() throws Exception { doTest(false); }
public void testTypeWithinItsWildcardBound() throws Exception { doTest(false); }
public void testMethodSignatureEquality() throws Exception { doTest(false); }
public void testInnerClassRef() throws Exception { doTest(false); }
public void testJavaUtilCollections() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));

View File

@@ -73,7 +73,9 @@ public abstract class PsiClassType extends PsiType {
String className = getClassName();
String otherClassName = otherClassType.getClassName();
if (!Comparing.equal(className, otherClassName)) return false;
final PsiType[] parameters = getParameters();
final PsiType[] otherParameters = otherClassType.getParameters();
if (parameters.length != otherParameters.length) return false;
final ClassResolveResult result = resolveGenerics();
final ClassResolveResult otherResult = otherClassType.resolveGenerics();
if (result == otherResult) return true;
@@ -84,7 +86,7 @@ public abstract class PsiClassType extends PsiType {
return aClass == otherClass;
}
return aClass.getManager().areElementsEquivalent(aClass, otherClass) &&
PsiUtil.equalOnEquivalentClasses(result.getSubstitutor(), aClass, otherResult.getSubstitutor(), otherClass);
(parameters.length == 0 || PsiUtil.equalOnEquivalentClasses(result.getSubstitutor(), aClass, otherResult.getSubstitutor(), otherClass));
}
/**