diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt index c16a077bc1e..91ce590670f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt @@ -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() }) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index 1907f26e3e7..981d26c2605 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -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 diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/DelegatingResolvedCall.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/DelegatingResolvedCall.java index 5b46d52e232..f5c2c1a08fd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/DelegatingResolvedCall.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/DelegatingResolvedCall.java @@ -110,11 +110,6 @@ public abstract class DelegatingResolvedCall imple return resolvedCall.getDataFlowInfoForArguments(); } - @Override - public boolean isSafeCall() { - return resolvedCall.isSafeCall(); - } - @Nullable @Override public KotlinType getSmartCastDispatchReceiverType() { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCall.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCall.java index 12eb2dd4396..3f9e85bfa50 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCall.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCall.java @@ -79,8 +79,6 @@ public interface ResolvedCall { @NotNull DataFlowInfoForArguments getDataFlowInfoForArguments(); - boolean isSafeCall(); - @Nullable KotlinType getSmartCastDispatchReceiverType(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java index 4864bcc589d..3f466c0475b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java @@ -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 implements MutableRe return typeArguments; } - @Override - public boolean isSafeCall() { - return CallUtilKt.isSafeCall(call); - } - @NotNull @Override public MutableDataFlowInfoForArguments getDataFlowInfoForArguments() { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/resolvedCallUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/resolvedCallUtil.kt index 348c6a11916..a0756383a72 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/resolvedCallUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/resolvedCallUtil.kt @@ -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() diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt index 8599a61980b..aa78224989f 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getCall import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall +import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind @@ -262,7 +263,7 @@ class KotlinPsiUnifier( !checkSpecialOperations() -> UNMATCHED !matchDescriptors(rc1.candidateDescriptor, rc2.candidateDescriptor) -> UNMATCHED !checkReceivers() -> UNMATCHED - rc1.isSafeCall != rc2.isSafeCall -> UNMATCHED + rc1.call.isSafeCall() != rc2.call.isSafeCall() -> UNMATCHED else -> { val s = checkTypeArguments() if (s != MATCHED) s else checkArguments() diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfo.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfo.kt index 6578ba8607f..23d7c70e1dc 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfo.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfo.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.js.translate.reference.CallArgumentTranslator import org.jetbrains.kotlin.js.translate.utils.JsAstUtils import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils.getReceiverParameterForReceiver import org.jetbrains.kotlin.js.translate.utils.TranslationUtils +import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind.* import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue @@ -126,7 +127,7 @@ private fun TranslationContext.createCallInfo(resolvedCall: ResolvedCall { notNullConditional = TranslationUtils.notNullConditional(extensionReceiver!!, JsLiteral.NULL, this)