mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
beware of null in IDEA-130746 Incorrect cast after completion in evaluate dialog
This commit is contained in:
@@ -448,12 +448,15 @@ public class JavaCompletionUtil {
|
||||
PsiSubstitutor plainSub = plainResult.getSubstitutor();
|
||||
PsiSubstitutor castSub = TypeConversionUtil.getSuperClassSubstitutor(plainClass, (PsiClassType)castType);
|
||||
PsiType returnType = method.getReturnType();
|
||||
if (method.getSignature(plainSub).equals(method.getSignature(castSub)) &&
|
||||
returnType != null &&
|
||||
toRaw(castSub.substitute(returnType)).isAssignableFrom(toRaw(plainSub.substitute(returnType))) &&
|
||||
processor.isAccessible(plainClass.findMethodBySignature(method, true))
|
||||
) {
|
||||
return item;
|
||||
if (method.getSignature(plainSub).equals(method.getSignature(castSub))) {
|
||||
PsiType typeAfterCast = toRaw(castSub.substitute(returnType));
|
||||
PsiType typeDeclared = toRaw(plainSub.substitute(returnType));
|
||||
if (typeAfterCast != null && typeDeclared != null &&
|
||||
typeAfterCast.isAssignableFrom(typeDeclared) &&
|
||||
processor.isAccessible(plainClass.findMethodBySignature(method, true))
|
||||
) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -495,7 +498,8 @@ public class JavaCompletionUtil {
|
||||
});
|
||||
}
|
||||
|
||||
private static PsiType toRaw(@NotNull PsiType type) {
|
||||
@Nullable
|
||||
private static PsiType toRaw(@Nullable PsiType type) {
|
||||
return type instanceof PsiClassType ? ((PsiClassType)type).rawType() : type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user