mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: throws clause processed
This commit is contained in:
+26
-8
@@ -445,14 +445,18 @@ public class InferenceSession {
|
||||
}
|
||||
else if (acceptObject || upperBounds.size() > 1 || !upperBounds.get(0).equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
|
||||
PsiType glb = null;
|
||||
for (PsiType upperBound : upperBounds) {
|
||||
upperBound = acceptBoundsWithRecursiveDependencies(typeParameter, upperBound, substitutor);
|
||||
if (isProperType(upperBound, false)) {
|
||||
if (glb == null) {
|
||||
glb = upperBound;
|
||||
}
|
||||
else {
|
||||
glb = GenericsUtil.getGreatestLowerBound(glb, upperBound);
|
||||
if (isThrowable(upperBounds)) {
|
||||
glb = PsiType.getJavaLangRuntimeException(myManager, GlobalSearchScope.allScope(myManager.getProject()));
|
||||
} else {
|
||||
for (PsiType upperBound : upperBounds) {
|
||||
upperBound = acceptBoundsWithRecursiveDependencies(typeParameter, upperBound, substitutor);
|
||||
if (isProperType(upperBound, false)) {
|
||||
if (glb == null) {
|
||||
glb = upperBound;
|
||||
}
|
||||
else {
|
||||
glb = GenericsUtil.getGreatestLowerBound(glb, upperBound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -473,6 +477,20 @@ public class InferenceSession {
|
||||
return substitutor;
|
||||
}
|
||||
|
||||
private static boolean isThrowable(List<PsiType> upperBounds) {
|
||||
boolean commonThrowable = false;
|
||||
for (PsiType upperBound : upperBounds) {
|
||||
if (upperBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) continue;
|
||||
if (upperBound.equalsToText(CommonClassNames.JAVA_LANG_EXCEPTION) ||
|
||||
upperBound.equalsToText(CommonClassNames.JAVA_LANG_THROWABLE)) {
|
||||
commonThrowable = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return commonThrowable;
|
||||
}
|
||||
|
||||
private PsiType acceptBoundsWithRecursiveDependencies(PsiTypeParameter typeParameter, PsiType bound, PsiSubstitutor substitutor) {
|
||||
if (!isProperType(bound)) {
|
||||
final PsiSubstitutor subst = PsiUtil.resolveClassInType(bound) != typeParameter ? substitutor.put(typeParameter, null) : substitutor;
|
||||
|
||||
Reference in New Issue
Block a user