Do not consider error results successful in '::' LHS resolution
Fixes EA-81649
This commit is contained in:
+3
-1
@@ -178,7 +178,9 @@ class DoubleColonExpressionResolver(
|
|||||||
val traceAndCache = TemporaryTraceAndCache.create(c, "Resolve expression on LHS of callable reference", simpleNameExpression)
|
val traceAndCache = TemporaryTraceAndCache.create(c, "Resolve expression on LHS of callable reference", simpleNameExpression)
|
||||||
val resolutionResult = callExpressionResolver.resolveSimpleName(c.replaceTraceAndCache(traceAndCache), 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.isEmpty()) return
|
||||||
|
|
||||||
if (resultingCalls.singleOrNull()?.resultingDescriptor is FakeCallableDescriptorForObject) return
|
if (resultingCalls.singleOrNull()?.resultingDescriptor is FakeCallableDescriptorForObject) return
|
||||||
|
|||||||
+20
@@ -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 <T> bar(<!UNUSED_PARAMETER!>ff<!>: <!UNRESOLVED_REFERENCE!>Err<!>.() -> Unit) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: m2(m1)
|
||||||
|
// FILE: foo.kt
|
||||||
|
|
||||||
|
data class User(val surname: String)
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
bar<String> {
|
||||||
|
<!UNUSED_EXPRESSION!>User::surname<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
// -- Module: <m1> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ T> bar(/*0*/ ff: [ERROR : Err].() -> kotlin.Unit): kotlin.Unit
|
||||||
|
|
||||||
|
|
||||||
|
// -- Module: <m2> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ T> 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
|
||||||
|
}
|
||||||
@@ -1647,6 +1647,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference"), Pattern.compile("^(.+)\\.kt$"), true);
|
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")
|
@TestMetadata("emptyLhs.kt")
|
||||||
public void testEmptyLhs() throws Exception {
|
public void testEmptyLhs() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user