mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
[java-inspections] IDEA-381019 IJ-CR-180490 Invalid local variable type inference in JSpecify mode with generic functions
- check container GitOrigin-RevId: 488ac99791eb9f35592aad23b355945d129f7b15
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a7cc339334
commit
1ac2c9a806
@@ -255,7 +255,6 @@ public abstract class PsiClassType extends PsiType implements JvmReferenceType {
|
||||
|
||||
/**
|
||||
* If class-type is created from the explicit reference in the code returns that reference.
|
||||
* If class-type is inferred (var) from PsiTypeElement, it returns PsiTypeElement
|
||||
* @return reference which the type is created from. Returns null if not applicable.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
|
||||
@@ -55,7 +55,8 @@ public final class JavaTypeNullabilityUtil {
|
||||
}
|
||||
}
|
||||
PsiClass target = type.resolve();
|
||||
if (target instanceof PsiTypeParameter) {
|
||||
//inferred types don't have contexts
|
||||
if (target instanceof PsiTypeParameter && context != null) {
|
||||
PsiTypeParameter typeParameter = (PsiTypeParameter)target;
|
||||
PsiReferenceList extendsList = typeParameter.getExtendsList();
|
||||
PsiClassType[] extendTypes = extendsList.getReferencedTypes();
|
||||
@@ -78,12 +79,9 @@ public final class JavaTypeNullabilityUtil {
|
||||
|
||||
private static boolean isLocal(PsiClassType classType) {
|
||||
PsiElement context = classType.getPsiContext();
|
||||
return ((context instanceof PsiJavaCodeReferenceElement) &&
|
||||
context.getParent() instanceof PsiTypeElement &&
|
||||
context.getParent().getParent() instanceof PsiLocalVariable) ||
|
||||
//inferred PsiTypeElements
|
||||
(context instanceof PsiTypeElement && ((PsiTypeElement)context).isInferredType() &&
|
||||
context.getParent() instanceof PsiLocalVariable);
|
||||
return context instanceof PsiJavaCodeReferenceElement &&
|
||||
context.getParent() instanceof PsiTypeElement &&
|
||||
context.getParent().getParent() instanceof PsiLocalVariable;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user