[FIR] Fix generating fir for invoke calls
This commit is contained in:
+1
-1
@@ -448,7 +448,7 @@ class ExpressionsConverter(
|
|||||||
this.calleeReference = when {
|
this.calleeReference = when {
|
||||||
name != null -> FirSimpleNamedReference(null, name.nameAsSafeName(), null)
|
name != null -> FirSimpleNamedReference(null, name.nameAsSafeName(), null)
|
||||||
additionalArgument != null -> {
|
additionalArgument != null -> {
|
||||||
arguments += additionalArgument!!
|
explicitReceiver = additionalArgument!!
|
||||||
FirSimpleNamedReference(null, OperatorNameConventions.INVOKE, null)
|
FirSimpleNamedReference(null, OperatorNameConventions.INVOKE, null)
|
||||||
}
|
}
|
||||||
else -> FirErrorNamedReferenceImpl(null, FirSimpleDiagnostic("Call has no callee", DiagnosticKind.Syntax))
|
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)
|
null, FirSimpleDiagnostic("Call has no callee", DiagnosticKind.Syntax)
|
||||||
)
|
)
|
||||||
else -> {
|
else -> {
|
||||||
arguments += calleeExpression.toFirExpression("Incorrect invoke receiver")
|
explicitReceiver = calleeExpression.toFirExpression("Incorrect invoke receiver")
|
||||||
FirSimpleNamedReference(
|
FirSimpleNamedReference(
|
||||||
source, OperatorNameConventions.INVOKE, null
|
source, OperatorNameConventions.INVOKE, null
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ FILE: calls.kt
|
|||||||
|
|
||||||
}
|
}
|
||||||
public? final? fun testInvoke(): Int {
|
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| {
|
public? final? fun testQualified(first: My, second: My?): R|kotlin/Unit| {
|
||||||
println#(first#.x#)
|
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");
|
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")
|
@TestMetadata("lambda.kt")
|
||||||
public void testLambda() throws Exception {
|
public void testLambda() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolve/arguments/lambda.kt");
|
runTest("compiler/fir/resolve/testData/resolve/arguments/lambda.kt");
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ FILE fqName:<root> fileName:/variableAsFunctionCall.kt
|
|||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='public final fun test2 (f: kotlin.Function1<kotlin.String, kotlin.Unit>): IrErrorType declared in <root>'
|
RETURN type=kotlin.Nothing from='public final fun test2 (f: kotlin.Function1<kotlin.String, kotlin.Unit>): IrErrorType declared in <root>'
|
||||||
ERROR_CALL 'Unresolved reference: <Unresolved name: f>#' type=IrErrorType
|
ERROR_CALL 'Unresolved reference: <Unresolved name: f>#' type=IrErrorType
|
||||||
FUN name:test3 visibility:public modality:FINAL <> () returnType:IrErrorType
|
FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='public final fun test3 (): IrErrorType declared in <root>'
|
RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.String declared in <root>'
|
||||||
ERROR_CALL 'Unresolved reference: <Unresolved name: invoke>#' type=IrErrorType
|
CALL 'public abstract fun invoke (): kotlin.String declared in kotlin.Function0' type=kotlin.String origin=null
|
||||||
CALL 'public final fun k (): kotlin.Function0<kotlin.String> declared in <root>' type=kotlin.Function0<kotlin.String> origin=null
|
$this: CALL 'public final fun k (): kotlin.Function0<kotlin.String> declared in <root>' type=kotlin.Function0<kotlin.String> origin=null
|
||||||
$receiver: CONST String type=kotlin.String value="hello"
|
$receiver: CONST String type=kotlin.String value="hello"
|
||||||
FUN name:test4 visibility:public modality:FINAL <> (ns:kotlin.String?) returnType:kotlin.String?
|
FUN name:test4 visibility:public modality:FINAL <> (ns:kotlin.String?) returnType:kotlin.String?
|
||||||
VALUE_PARAMETER name:ns index:0 type:kotlin.String?
|
VALUE_PARAMETER name:ns index:0 type:kotlin.String?
|
||||||
|
|||||||
Reference in New Issue
Block a user