mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
erasure: use before subst for type param bound (IDEA-98092)
This commit is contained in:
@@ -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) {
|
||||
|
||||
+9
@@ -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()));
|
||||
|
||||
Reference in New Issue
Block a user