From ad285d5ca267d74c1b7e2a0ce4ddc724beac5b9c Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Tue, 21 Jun 2016 16:29:33 +0300 Subject: [PATCH] KT-11679 Fixed exception at ResolvedCallImpl.getArgumentMapping() #KT-11679 Fixed Also fixed EA-75913 EA-78908 --- .../kotlin/resolve/calls/CallExpressionResolver.kt | 9 +++++++++ idea/testData/intentions/addNameToArgument/kt11679.kt | 8 ++++++++ .../kotlin/idea/intentions/IntentionTestGenerated.java | 6 ++++++ 3 files changed, 23 insertions(+) create mode 100644 idea/testData/intentions/addNameToArgument/kt11679.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.kt index 6ebbf8b1b43..dcbe5e216ad 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.recordDataFlowInfo import org.jetbrains.kotlin.resolve.bindingContextUtil.recordScope import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny +import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode import org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT @@ -38,10 +39,12 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.resolve.calls.context.TemporaryTraceAndCache import org.jetbrains.kotlin.resolve.calls.model.DataFlowInfoForArgumentsImpl import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall +import org.jetbrains.kotlin.resolve.calls.model.ResolvedCallImpl import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.CANDIDATES_WITH_WRONG_RECEIVER import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.NAME_NOT_FOUND import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsUtil +import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory @@ -246,6 +249,12 @@ class CallExpressionResolver( context.replaceTraceAndCache(temporaryForVariable)) val qualifier = temporaryForVariable.trace.get(BindingContext.QUALIFIER, calleeExpression) if (notNothing && (qualifier == null || qualifier !is PackageQualifier)) { + + // mark property call as unsuccessful to avoid exceptions + callExpression.getResolvedCall(temporaryForVariable.trace.bindingContext).let { + (it as? ResolvedCallImpl)?.addStatus(ResolutionStatus.OTHER_ERROR) + } + temporaryForVariable.commit() context.trace.report(FUNCTION_EXPECTED.on(calleeExpression, calleeExpression, type ?: ErrorUtils.createErrorType(""))) diff --git a/idea/testData/intentions/addNameToArgument/kt11679.kt b/idea/testData/intentions/addNameToArgument/kt11679.kt new file mode 100644 index 00000000000..03e6ee4a65c --- /dev/null +++ b/idea/testData/intentions/addNameToArgument/kt11679.kt @@ -0,0 +1,8 @@ +// ERROR: Expression 'f' of type 'String' cannot be invoked as a function. The function 'invoke()' is not found +// IS_APPLICABLE: false +class Paren(val f: String) { +} + +fun nonSimple() { + Paren("").f(6) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index dbfd90b8314..ea01b78300e 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -295,6 +295,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("kt11679.kt") + public void testKt11679() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addNameToArgument/kt11679.kt"); + doTest(fileName); + } + @TestMetadata("notInsideIndices.kt") public void testNotInsideIndices() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addNameToArgument/notInsideIndices.kt");