[FIR] Create proper error name references for invoke receivers
In this example, when processing
the `jso` property candidate form
the `dynamic` scope we get
`DslScopeViolation`.
When we later create the
receiver for the invoke call
(since we still call `jso {}` as
a function), we create a non-error
named reference which fails at
`toResolvedReference()`.
The included test should not fail
with exception.
^KT-65255 Fixed
This commit is contained in:
committed by
Space Team
parent
be6ab943f4
commit
183c263c55
+7
-5
@@ -317,11 +317,13 @@ private fun BodyResolveComponents.createExplicitReceiverForInvokeByCallable(
|
||||
): FirExpression {
|
||||
return FirPropertyAccessExpressionBuilder().apply {
|
||||
val fakeSource = info.fakeSourceForImplicitInvokeCallReceiver
|
||||
calleeReference = FirNamedReferenceWithCandidate(
|
||||
fakeSource,
|
||||
symbol.callableId.callableName,
|
||||
candidate
|
||||
)
|
||||
calleeReference = when {
|
||||
candidate.isSuccessful -> FirNamedReferenceWithCandidate(fakeSource, symbol.callableId.callableName, candidate)
|
||||
else -> FirErrorReferenceWithCandidate(
|
||||
fakeSource, symbol.callableId.callableName, candidate,
|
||||
createConeDiagnosticForCandidateWithError(candidate.applicability, candidate),
|
||||
)
|
||||
}
|
||||
dispatchReceiver = candidate.dispatchReceiverExpression()
|
||||
coneTypeOrNull = returnTypeCalculator.tryCalculateReturnType(symbol.fir).type
|
||||
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-65255
|
||||
// DIAGNOSTICS: -NOTHING_TO_INLINE -UNUSED_ANONYMOUS_PARAMETER
|
||||
|
||||
@DslMarker
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class JsoDsl
|
||||
|
||||
inline fun <T : Any> jso(): T = js("({})")
|
||||
inline fun <T : Any> jso(block: @JsoDsl T.() -> Unit): T = jso<T>().apply(block)
|
||||
|
||||
val value = { int: Int? ->
|
||||
jso<dynamic> {
|
||||
foo = jso {
|
||||
bar = jso { // line 7
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -25,6 +25,12 @@ public class FirLightTreeJsOldFrontendDiagnosticsTestGenerated extends AbstractF
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib"), Pattern.compile("^([^_](.+))\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("candidateNotSuccessfulButNoContradiction.kt")
|
||||
public void testCandidateNotSuccessfulButNoContradiction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithJsStdLib/candidateNotSuccessfulButNoContradiction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicUnresolved.kt")
|
||||
public void testDynamicUnresolved() throws Exception {
|
||||
|
||||
+6
@@ -25,6 +25,12 @@ public class FirPsiJsOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiJ
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib"), Pattern.compile("^([^_](.+))\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("candidateNotSuccessfulButNoContradiction.kt")
|
||||
public void testCandidateNotSuccessfulButNoContradiction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithJsStdLib/candidateNotSuccessfulButNoContradiction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicUnresolved.kt")
|
||||
public void testDynamicUnresolved() throws Exception {
|
||||
|
||||
Generated
+6
@@ -25,6 +25,12 @@ public class DiagnosticsWithJsStdLibTestGenerated extends AbstractDiagnosticsTes
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib"), Pattern.compile("^([^_](.+))\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("candidateNotSuccessfulButNoContradiction.kt")
|
||||
public void testCandidateNotSuccessfulButNoContradiction() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithJsStdLib/candidateNotSuccessfulButNoContradiction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicUnresolved.kt")
|
||||
public void testDynamicUnresolved() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user