Java nullability checker: take type arguments' types from resolution atom if possible, instead of from resolved call directly
^KT-47833 Fixed
This commit is contained in:
committed by
teamcityserver
parent
93f9d9dacd
commit
7567597be6
+10
-1
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.NewResolvedCallImpl
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
@@ -135,10 +136,18 @@ class JavaNullabilityChecker(val upperBoundChecker: UpperBoundChecker) : Additio
|
||||
?: return
|
||||
val resolvedCall = c.trace.bindingContext[BindingContext.RESOLVED_CALL, call] ?: return
|
||||
|
||||
for ((typeParameter, typeArgument) in resolvedCall.typeArguments) {
|
||||
val typeArguments = if (resolvedCall is NewResolvedCallImpl<*>) {
|
||||
resolvedCall.resolvedCallAtom.typeArgumentMappingByOriginal
|
||||
} else {
|
||||
resolvedCall.typeArguments.entries
|
||||
}
|
||||
|
||||
for ((typeParameter, typeArgument) in typeArguments) {
|
||||
// continue if we don't have explicit type arguments
|
||||
val typeReference = call.typeArguments.getOrNull(typeParameter.index)?.typeReference ?: continue
|
||||
|
||||
if (typeArgument == null) continue
|
||||
|
||||
upperBoundChecker.checkBounds(
|
||||
typeReference, typeArgument, typeParameter, TypeSubstitutor.create(typeArgument), c.trace, withOnlyCheckForWarning = true
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user