diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt index 6afe5cb5cea..d5a1d2561c3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt @@ -178,7 +178,9 @@ class DoubleColonExpressionResolver( val traceAndCache = TemporaryTraceAndCache.create(c, "Resolve expression on LHS of callable reference", simpleNameExpression) val resolutionResult = callExpressionResolver.resolveSimpleName(c.replaceTraceAndCache(traceAndCache), simpleNameExpression) - val resultingCalls = resolutionResult.resultingCalls.filter { call -> call.status.possibleTransformToSuccess() } + val resultingCalls = resolutionResult.resultingCalls.filter { call -> + call.status.possibleTransformToSuccess() && !ErrorUtils.isError(call.resultingDescriptor) + } if (resultingCalls.isEmpty()) return if (resultingCalls.singleOrNull()?.resultingDescriptor is FakeCallableDescriptorForObject) return diff --git a/compiler/testData/diagnostics/tests/callableReference/ea81649_errorPropertyLHS.kt b/compiler/testData/diagnostics/tests/callableReference/ea81649_errorPropertyLHS.kt new file mode 100644 index 00000000000..9eda16b6015 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/ea81649_errorPropertyLHS.kt @@ -0,0 +1,20 @@ +// Different modules are important for this test because otherwise everything is analyzed at once and some errors +// already exist in the binding context when we're analyzing "User::surname". +// (The assertion at DoubleColonExpressionResolver.checkNoExpressionOnLHS is only performed when there are no errors in the binding context) + +// MODULE: m1 +// FILE: bar.kt + +fun bar(ff: Err.() -> Unit) { +} + +// MODULE: m2(m1) +// FILE: foo.kt + +data class User(val surname: String) + +fun foo() { + bar { + User::surname + } +} diff --git a/compiler/testData/diagnostics/tests/callableReference/ea81649_errorPropertyLHS.txt b/compiler/testData/diagnostics/tests/callableReference/ea81649_errorPropertyLHS.txt new file mode 100644 index 00000000000..26647d8f03d --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/ea81649_errorPropertyLHS.txt @@ -0,0 +1,21 @@ +// -- Module: -- +package + +public fun bar(/*0*/ ff: [ERROR : Err].() -> kotlin.Unit): kotlin.Unit + + +// -- Module: -- +package + +public fun bar(/*0*/ ff: [ERROR : Err].() -> kotlin.Unit): kotlin.Unit +public fun foo(): kotlin.Unit + +public final data class User { + public constructor User(/*0*/ surname: kotlin.String) + public final val surname: kotlin.String + public final operator /*synthesized*/ fun component1(): kotlin.String + public final /*synthesized*/ fun copy(/*0*/ surname: kotlin.String = ...): User + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index bfbd3c4d70b..d966294dfca 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -1647,6 +1647,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("ea81649_errorPropertyLHS.kt") + public void testEa81649_errorPropertyLHS() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/ea81649_errorPropertyLHS.kt"); + doTest(fileName); + } + @TestMetadata("emptyLhs.kt") public void testEmptyLhs() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt");