Remove obsolete errors related to 'invoke' called on extension
This commit is contained in:
@@ -526,8 +526,6 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> CANNOT_COMPLETE_RESOLVE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> UNRESOLVED_REFERENCE_WRONG_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtExpression> INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> INVOKE_ON_EXTENSION_FUNCTION_WITH_EXPLICIT_DISPATCH_RECEIVER = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
-2
@@ -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);
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
-40
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-5
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+2
-7
@@ -180,7 +180,7 @@ public class ControlStructureTypingUtils {
|
||||
return function;
|
||||
}
|
||||
|
||||
/*package*/ static MutableDataFlowInfoForArguments createIndependentDataFlowInfoForArgumentsForCall(
|
||||
private static MutableDataFlowInfoForArguments createIndependentDataFlowInfoForArgumentsForCall(
|
||||
@NotNull DataFlowInfo initialDataFlowInfo,
|
||||
final Map<ValueArgument, DataFlowInfo> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user