erasure: use before subst for type param bound (IDEA-98092)

This commit is contained in:
anna
2013-01-03 16:04:53 +01:00
parent dac993580a
commit 8d97155040
3 changed files with 18 additions and 3 deletions
@@ -1245,7 +1245,7 @@ public class TypeConversionUtil {
if (beforeSubstitutor.getSubstitutionMap().containsKey(boundTypeParameter)) {
return erasure(beforeSubstitutor.substitute(boundTypeParameter));
}
return typeParameterErasureInner(boundTypeParameter, visited);
return typeParameterErasureInner(boundTypeParameter, visited, beforeSubstitutor);
}
else if (psiClass != null) {
return JavaPsiFacade.getInstance(typeParameter.getProject()).getElementFactory().createType(psiClass);
@@ -1254,14 +1254,19 @@ public class TypeConversionUtil {
return PsiType.getJavaLangObject(typeParameter.getManager(), typeParameter.getResolveScope());
}
private static PsiClassType typeParameterErasureInner(PsiTypeParameter typeParameter, Set<PsiClass> visited) {
private static PsiClassType typeParameterErasureInner(PsiTypeParameter typeParameter,
Set<PsiClass> visited,
PsiSubstitutor beforeSubstitutor) {
final PsiClassType[] extendsList = typeParameter.getExtendsList().getReferencedTypes();
if (extendsList.length > 0) {
final PsiClass psiClass = extendsList[0].resolve();
if (psiClass instanceof PsiTypeParameter) {
if (!visited.contains(psiClass)) {
visited.add(psiClass);
return typeParameterErasureInner((PsiTypeParameter)psiClass, visited);
if (beforeSubstitutor.getSubstitutionMap().containsKey(psiClass)) {
return (PsiClassType)erasure(beforeSubstitutor.substitute((PsiTypeParameter)psiClass));
}
return typeParameterErasureInner((PsiTypeParameter)psiClass, visited, beforeSubstitutor);
}
}
else if (psiClass != null) {
@@ -0,0 +1,9 @@
interface Foo<T> {
public <A extends T, B extends A> void bar(Class<A> key, B value);
}
class FooImpl implements Foo<String>{
public <A extends String, B extends A> void bar(Class<A> key, B value) {
}
}
@@ -193,6 +193,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA97888() { doTest7Incompatibility(false); }
public void testMethodCallParamsOnRawType() { doTest5(false); }
public void testIDEA98421() { doTest5(false); }
public void testErasureTypeParameterBound() { doTest5(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));