From 291f1f6c3a102c987ef97661b383a62c26d14dac Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 27 Jun 2016 17:12:43 +0300 Subject: [PATCH] Remove obsolete errors related to 'invoke' called on extension --- .../jetbrains/kotlin/diagnostics/Errors.java | 2 - .../rendering/DefaultErrorMessages.java | 2 - .../kotlin/resolve/TargetPlatform.kt | 2 +- .../kotlin/resolve/calls/CandidateResolver.kt | 16 -------- .../calls/checkers/InvokeConventionChecker.kt | 40 ------------------- .../calls/tasks/AbstractTracingStrategy.java | 5 --- .../resolve/calls/tasks/TracingStrategy.java | 5 --- .../ControlStructureTypingUtils.java | 9 +---- 8 files changed, 3 insertions(+), 78 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/InvokeConventionChecker.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 017a83a7506..b49e69db0e6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -526,8 +526,6 @@ public interface Errors { DiagnosticFactory1>> NONE_APPLICABLE = DiagnosticFactory1.create(ERROR); DiagnosticFactory1>> CANNOT_COMPLETE_RESOLVE = DiagnosticFactory1.create(ERROR); DiagnosticFactory1>> UNRESOLVED_REFERENCE_WRONG_RECEIVER = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION = DiagnosticFactory1.create(ERROR); - DiagnosticFactory0 INVOKE_ON_EXTENSION_FUNCTION_WITH_EXPLICIT_DISPATCH_RECEIVER = DiagnosticFactory0.create(WARNING); DiagnosticFactory1 TYPE_PARAMETER_AS_REIFIED = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 2491c2c4616..c4fb7c989b9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -657,8 +657,6 @@ public class DefaultErrorMessages { MAP.put(NONE_APPLICABLE, "None of the following functions can be called with the arguments supplied: {0}", AMBIGUOUS_CALLS); MAP.put(CANNOT_COMPLETE_RESOLVE, "Cannot choose among the following candidates without completing type inference: {0}", AMBIGUOUS_CALLS); MAP.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, "Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: {0}", AMBIGUOUS_CALLS); - MAP.put(INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION, "Impossible call as extension because {0} is not an extension function.", ELEMENT_TEXT); - MAP.put(INVOKE_ON_EXTENSION_FUNCTION_WITH_EXPLICIT_DISPATCH_RECEIVER, "Such calls are no longer supported, surround callee with parenthesis or pass receiver as first argument"); MAP.put(NO_VALUE_FOR_PARAMETER, "No value passed for parameter {0}", NAME); MAP.put(MISSING_RECEIVER, "A receiver of type {0} is required", RENDER_TYPE); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt index 47009959a0b..9fbd5ffeb3a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt @@ -66,7 +66,7 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf( private val DEFAULT_CALL_CHECKERS = listOf( CapturingInClosureChecker(), InlineCheckerWrapper(), ReifiedTypeParameterSubstitutionChecker(), SafeCallChecker(), - InvokeConventionChecker(), CallReturnsArrayOfNothingChecker(), InfixCallChecker(), OperatorCallChecker(), + CallReturnsArrayOfNothingChecker(), InfixCallChecker(), OperatorCallChecker(), ConstructorHeaderCallChecker, ProtectedConstructorCallChecker, CoroutineSuspendCallChecker, BuilderFunctionsCallChecker ) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt index 3eb613b0806..2d1e64b66ed 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.resolve.calls import com.google.common.collect.Lists import com.google.common.collect.Sets import org.jetbrains.kotlin.builtins.ReflectionTypes -import org.jetbrains.kotlin.builtins.isExtensionFunctionType import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor import org.jetbrains.kotlin.diagnostics.Errors @@ -95,7 +94,6 @@ class CandidateResolver( checkValueArguments() checkAbstractAndSuper() - checkNonExtensionCalledWithReceiver() } private fun CallCandidateResolutionContext<*>.checkValueArguments() = checkAndReport { @@ -298,20 +296,6 @@ class CandidateResolver( } } - private fun CallCandidateResolutionContext<*>.checkNonExtensionCalledWithReceiver() = checkAndReport { - val call = candidateCall.call - if (call is CallTransformer.CallForImplicitInvoke && - candidateCall.extensionReceiver != null && - candidateCall.dispatchReceiver != null - ) { - if (call.dispatchReceiver == candidateCall.dispatchReceiver && !call.dispatchReceiver.type.isExtensionFunctionType) { - tracing.nonExtensionFunctionCalledAsExtension(trace) - return@checkAndReport OTHER_ERROR - } - } - SUCCESS - } - private fun getReceiverSuper(receiver: Receiver?): KtSuperExpression? { if (receiver is ExpressionReceiver) { val expression = receiver.expression diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/InvokeConventionChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/InvokeConventionChecker.kt deleted file mode 100644 index 57f06fd62d8..00000000000 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/InvokeConventionChecker.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2010-2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.resolve.calls.checkers - -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.builtins.isExtensionFunctionType -import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCallImpl -import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver - -class InvokeConventionChecker : CallChecker { - override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) { - if (resolvedCall is VariableAsFunctionResolvedCallImpl) { - val functionCall = resolvedCall.functionCall - val variableCall = resolvedCall.variableCall - if (functionCall.dispatchReceiver != null && functionCall.extensionReceiver != null && - variableCall.resultingDescriptor.type.isExtensionFunctionType) { - if (variableCall.dispatchReceiver is ExpressionReceiver || variableCall.extensionReceiver is ExpressionReceiver) { - val callElement = variableCall.call.callElement - context.trace.report(Errors.INVOKE_ON_EXTENSION_FUNCTION_WITH_EXPLICIT_DISPATCH_RECEIVER.on(callElement)) - } - } - } - } -} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java index dc52f9f316e..960fd477bb0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java @@ -251,9 +251,4 @@ public abstract class AbstractTracingStrategy implements TracingStrategy { trace.report(TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER.on(reference, data)); } } - - @Override - public void nonExtensionFunctionCalledAsExtension(@NotNull BindingTrace trace) { - trace.report(INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION.on(reference, reference)); - } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategy.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategy.java index 2c9d699fad1..b20f8206012 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategy.java @@ -102,9 +102,6 @@ public interface TracingStrategy { @Override public void typeInferenceFailed(@NotNull ResolutionContext context, @NotNull InferenceErrorData inferenceErrorData) {} - - @Override - public void nonExtensionFunctionCalledAsExtension(@NotNull BindingTrace trace) { } }; void bindCall(@NotNull BindingTrace trace, @NotNull Call call); @@ -162,6 +159,4 @@ public interface TracingStrategy { void invisibleMember(@NotNull BindingTrace trace, @NotNull DeclarationDescriptorWithVisibility descriptor); void typeInferenceFailed(@NotNull ResolutionContext context, @NotNull InferenceErrorData inferenceErrorData); - - void nonExtensionFunctionCalledAsExtension(@NotNull BindingTrace trace); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java index 7df7fd7788d..95998bf7578 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java @@ -180,7 +180,7 @@ public class ControlStructureTypingUtils { return function; } - /*package*/ static MutableDataFlowInfoForArguments createIndependentDataFlowInfoForArgumentsForCall( + private static MutableDataFlowInfoForArguments createIndependentDataFlowInfoForArgumentsForCall( @NotNull DataFlowInfo initialDataFlowInfo, final Map dataFlowInfoForArgumentsMap ) { @@ -304,7 +304,7 @@ public class ControlStructureTypingUtils { } @NotNull - /*package*/ TracingStrategy createTracingForSpecialConstruction( + private TracingStrategy createTracingForSpecialConstruction( final @NotNull Call call, @NotNull String constructionName, final @NotNull ExpressionTypingContext context @@ -606,10 +606,5 @@ public class ControlStructureTypingUtils { ) { logError(); } - - @Override - public void nonExtensionFunctionCalledAsExtension(@NotNull BindingTrace trace) { - logError(); - } } }