mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use thread local to store modified upper bounds instead of non-physical type parameters as methods could come from foreign languages (IDEA-151194)
This commit is contained in:
@@ -1032,6 +1032,9 @@ public class PsiClassImplUtil {
|
||||
return new PsiClassType[]{getAnnotationSuperType(psiClass, JavaPsiFacade.getInstance(psiClass.getProject()).getElementFactory())};
|
||||
}
|
||||
PsiType upperBound = psiClass.getUserData(InferenceSession.UPPER_BOUND);
|
||||
if (upperBound == null && psiClass instanceof PsiTypeParameter) {
|
||||
upperBound = LambdaUtil.getFunctionalTypeMap().get(psiClass);
|
||||
}
|
||||
if (upperBound instanceof PsiIntersectionType) {
|
||||
final PsiType[] conjuncts = ((PsiIntersectionType)upperBound).getConjuncts();
|
||||
final List<PsiClassType> result = new ArrayList<PsiClassType>();
|
||||
|
||||
+3
-15
@@ -1501,18 +1501,6 @@ public class InferenceSession {
|
||||
final PsiElement context,
|
||||
final boolean varargs) {
|
||||
try {
|
||||
//push site substitutor to parameter bounds
|
||||
final String text;
|
||||
if (m1 instanceof ClsMethodImpl) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
((ClsMethodImpl)m1).appendMirrorText(0, builder);
|
||||
text = builder.toString();
|
||||
}
|
||||
else {
|
||||
text = m1.getText();
|
||||
}
|
||||
|
||||
m1 = JavaPsiFacade.getElementFactory(m1.getProject()).createMethodFromText(text, m1);
|
||||
for (PsiTypeParameter parameter : m1.getTypeParameters()) {
|
||||
final PsiClassType[] types = parameter.getExtendsListTypes();
|
||||
if (types.length > 0) {
|
||||
@@ -1525,14 +1513,14 @@ public class InferenceSession {
|
||||
//don't glb to avoid flattening = Object&Interface would be preserved
|
||||
//otherwise methods with different signatures could get same erasure
|
||||
final PsiType upperBound = PsiIntersectionType.createIntersection(false, conjuncts.toArray(new PsiType[conjuncts.size()]));
|
||||
parameter.putUserData(UPPER_BOUND, upperBound);
|
||||
LambdaUtil.getFunctionalTypeMap().put(parameter, upperBound);
|
||||
}
|
||||
}
|
||||
return isMoreSpecificInternal(m1, m2, siteSubstitutor1, args, context, varargs);
|
||||
}
|
||||
finally {
|
||||
for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(m1)) {
|
||||
parameter.putUserData(UPPER_BOUND, null);
|
||||
for (PsiTypeParameter parameter : m1.getTypeParameters()) {
|
||||
LambdaUtil.getFunctionalTypeMap().remove(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user