mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
optimization: don't try to capture if type was not wildcard parameterized
This commit is contained in:
@@ -770,25 +770,27 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
}
|
||||
}
|
||||
|
||||
Map<PsiTypeParameter, PsiType> substitutionMap = null;
|
||||
for (PsiTypeParameter typeParameter : typeParametersIterable(aClass)) {
|
||||
final PsiType substituted = substitutor.substitute(typeParameter);
|
||||
if (substituted instanceof PsiWildcardType) {
|
||||
if (substitutionMap == null) substitutionMap = new HashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
|
||||
final PsiCapturedWildcardType capturedWildcard = (PsiCapturedWildcardType)captureSubstitutor.substitute(typeParameter);
|
||||
LOG.assertTrue(capturedWildcard != null);
|
||||
final PsiType upperBound = PsiCapturedWildcardType.captureUpperBound(typeParameter, (PsiWildcardType)substituted, captureSubstitutor);
|
||||
if (upperBound != null) {
|
||||
capturedWildcard.setUpperBound(upperBound);
|
||||
if (captureSubstitutor != substitutor) {
|
||||
Map<PsiTypeParameter, PsiType> substitutionMap = null;
|
||||
for (PsiTypeParameter typeParameter : typeParametersIterable(aClass)) {
|
||||
final PsiType substituted = substitutor.substitute(typeParameter);
|
||||
if (substituted instanceof PsiWildcardType) {
|
||||
if (substitutionMap == null) substitutionMap = new HashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
|
||||
final PsiCapturedWildcardType capturedWildcard = (PsiCapturedWildcardType)captureSubstitutor.substitute(typeParameter);
|
||||
LOG.assertTrue(capturedWildcard != null);
|
||||
final PsiType upperBound = PsiCapturedWildcardType.captureUpperBound(typeParameter, (PsiWildcardType)substituted, captureSubstitutor);
|
||||
if (upperBound != null) {
|
||||
capturedWildcard.setUpperBound(upperBound);
|
||||
}
|
||||
substitutionMap.put(typeParameter, capturedWildcard);
|
||||
}
|
||||
substitutionMap.put(typeParameter, capturedWildcard);
|
||||
}
|
||||
}
|
||||
|
||||
if (substitutionMap != null) {
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory();
|
||||
final PsiSubstitutor newSubstitutor = factory.createSubstitutor(substitutionMap);
|
||||
return factory.createType(aClass, newSubstitutor);
|
||||
if (substitutionMap != null) {
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory();
|
||||
final PsiSubstitutor newSubstitutor = factory.createSubstitutor(substitutionMap);
|
||||
return factory.createType(aClass, newSubstitutor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user