mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
[java-dfa] Do not check nullability match for primitive methodref return types
DfaPsiUtil returns UNKNOWN nullability for primitive types, but in future we may return NOT_NULL, which is technically more correct. On the other hand, here implicit unboxing is possible, and it's already handled elsewhere, so we won't need an extra warning. Part of IDEA-372347 Java type inference should respect nullability GitOrigin-RevId: b864bfc4995a9b5e0e6a13cba807bd8b5b7d04ca
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5259525948
commit
211321c88a
@@ -77,10 +77,13 @@ public class MethodReferenceInstruction extends ExpressionPushingInstruction {
|
||||
dfType = typedObject(returnType, DfaPsiUtil.getElementNullability(returnType, method));
|
||||
}
|
||||
DfaValue defaultResult = interpreter.getFactory().fromDfType(dfType);
|
||||
Nullability expectedNullability = DfaPsiUtil.getTypeNullability(LambdaUtil.getFunctionalInterfaceReturnType(methodRef));
|
||||
if (expectedNullability == Nullability.NOT_NULL) {
|
||||
CheckNotNullInstruction.checkNotNullable(interpreter, state, defaultResult,
|
||||
NullabilityProblemKind.nullableFunctionReturn.problem(methodRef, null));
|
||||
PsiType type = LambdaUtil.getFunctionalInterfaceReturnType(methodRef);
|
||||
if (!(type instanceof PsiPrimitiveType)) { // primitive type may be subject to boxing and handled separately
|
||||
Nullability expectedNullability = DfaPsiUtil.getTypeNullability(type);
|
||||
if (expectedNullability == Nullability.NOT_NULL) {
|
||||
CheckNotNullInstruction.checkNotNullable(interpreter, state, defaultResult,
|
||||
NullabilityProblemKind.nullableFunctionReturn.problem(methodRef, null));
|
||||
}
|
||||
}
|
||||
if (contracts.isEmpty() || !JavaMethodContractUtil.isPure(method)) return;
|
||||
Set<DfaCallState> currentStates = Collections.singleton(new DfaCallState(state.createClosureState(), callArguments, defaultResult));
|
||||
|
||||
Reference in New Issue
Block a user