Refactoring. Remove isSafeCall from ResolvedCall.
This commit is contained in:
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getTargetFunctionDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.ValueArgumentsToParametersMapper
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getExplicitReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
@@ -61,7 +62,7 @@ fun getReceiverTypePredicate(resolvedCall: ResolvedCall<*>, receiverValue: Recei
|
||||
resolvedCall.getDispatchReceiver() -> {
|
||||
val rootCallableDescriptors = callableDescriptor.findTopMostOverriddenDescriptors()
|
||||
return or(rootCallableDescriptors.mapNotNull {
|
||||
it.getDispatchReceiverParameter()?.getType()?.let { TypeUtils.makeNullableIfNeeded(it, resolvedCall.isSafeCall()) }?.getSubtypesPredicate()
|
||||
it.getDispatchReceiverParameter()?.getType()?.let { TypeUtils.makeNullableIfNeeded(it, resolvedCall.call.isSafeCall()) }?.getSubtypesPredicate()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.*
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
@@ -79,7 +80,7 @@ class GenericCandidateResolver(private val argumentTypeResolver: ArgumentTypeRes
|
||||
val receiverParameter = candidate.extensionReceiverParameter
|
||||
if (receiverArgument != null && receiverParameter != null) {
|
||||
val receiverArgumentType = receiverArgument.type
|
||||
var receiverType: KotlinType? = if (context.candidateCall.isSafeCall)
|
||||
var receiverType: KotlinType? = if (context.candidateCall.call.isSafeCall())
|
||||
TypeUtils.makeNotNullable(receiverArgumentType)
|
||||
else
|
||||
receiverArgumentType
|
||||
|
||||
-5
@@ -110,11 +110,6 @@ public abstract class DelegatingResolvedCall<D extends CallableDescriptor> imple
|
||||
return resolvedCall.getDataFlowInfoForArguments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSafeCall() {
|
||||
return resolvedCall.isSafeCall();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KotlinType getSmartCastDispatchReceiverType() {
|
||||
|
||||
@@ -79,8 +79,6 @@ public interface ResolvedCall<D extends CallableDescriptor> {
|
||||
@NotNull
|
||||
DataFlowInfoForArguments getDataFlowInfoForArguments();
|
||||
|
||||
boolean isSafeCall();
|
||||
|
||||
@Nullable
|
||||
KotlinType getSmartCastDispatchReceiverType();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.psi.Call;
|
||||
import org.jetbrains.kotlin.psi.ValueArgument;
|
||||
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
@@ -348,11 +347,6 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
return typeArguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSafeCall() {
|
||||
return CallUtilKt.isSafeCall(call);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MutableDataFlowInfoForArguments getDataFlowInfoForArguments() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import org.jetbrains.kotlin.psi.KtThisExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
@@ -78,7 +79,7 @@ fun ResolvedCall<*>.getImplicitReceiverValue(): ReceiverValue? {
|
||||
}
|
||||
|
||||
private fun ResolvedCall<*>.hasSafeNullableReceiver(context: CallResolutionContext<*>): Boolean {
|
||||
if (!isSafeCall) return false
|
||||
if (!call.isSafeCall()) return false
|
||||
val receiverValue = getExplicitReceiverValue()?.let { DataFlowValueFactory.createDataFlowValue(it, context) }
|
||||
?: return false
|
||||
return context.dataFlowInfo.getPredictableNullability(receiverValue).canBeNull()
|
||||
|
||||
Reference in New Issue
Block a user