[FIR] Fix generating fir for invoke calls
This commit is contained in:
+1
-1
@@ -448,7 +448,7 @@ class ExpressionsConverter(
|
||||
this.calleeReference = when {
|
||||
name != null -> FirSimpleNamedReference(null, name.nameAsSafeName(), null)
|
||||
additionalArgument != null -> {
|
||||
arguments += additionalArgument!!
|
||||
explicitReceiver = additionalArgument!!
|
||||
FirSimpleNamedReference(null, OperatorNameConventions.INVOKE, null)
|
||||
}
|
||||
else -> FirErrorNamedReferenceImpl(null, FirSimpleDiagnostic("Call has no callee", DiagnosticKind.Syntax))
|
||||
|
||||
@@ -1242,7 +1242,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
null, FirSimpleDiagnostic("Call has no callee", DiagnosticKind.Syntax)
|
||||
)
|
||||
else -> {
|
||||
arguments += calleeExpression.toFirExpression("Incorrect invoke receiver")
|
||||
explicitReceiver = calleeExpression.toFirExpression("Incorrect invoke receiver")
|
||||
FirSimpleNamedReference(
|
||||
source, OperatorNameConventions.INVOKE, null
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ FILE: calls.kt
|
||||
|
||||
}
|
||||
public? final? fun testInvoke(): Int {
|
||||
^testInvoke invoke#(My#(Int(13)))
|
||||
^testInvoke My#(Int(13)).invoke#()
|
||||
}
|
||||
public? final? fun testQualified(first: My, second: My?): R|kotlin/Unit| {
|
||||
println#(first#.x#)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class My(var x: Int) {
|
||||
operator fun invoke() = x
|
||||
|
||||
fun foo() {}
|
||||
|
||||
fun copy() = My(x)
|
||||
}
|
||||
|
||||
fun testInvoke(): Int = My(13)()
|
||||
@@ -0,0 +1,25 @@
|
||||
FILE: invoke.kt
|
||||
public final class My : R|kotlin/Any| {
|
||||
public constructor(x: R|kotlin/Int|): R|My| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final var x: R|kotlin/Int| = R|<local>/x|
|
||||
public get(): R|kotlin/Int|
|
||||
public set(value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
|
||||
public final operator fun invoke(): R|kotlin/Int| {
|
||||
^invoke this@R|/My|.R|/My.x|
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final fun copy(): R|My| {
|
||||
^copy R|/My.My|(this@R|/My|.R|/My.x|)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun testInvoke(): R|kotlin/Int| {
|
||||
^testInvoke R|/My.My|(Int(13)).R|/My.invoke|()
|
||||
}
|
||||
+5
@@ -230,6 +230,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/resolve/testData/resolve/arguments/default.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invoke.kt")
|
||||
public void testInvoke() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/arguments/invoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/arguments/lambda.kt");
|
||||
|
||||
Reference in New Issue
Block a user