From c602ccb33ef3b9febe4dbc4a47f58de4a261cfc3 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 17 Nov 2020 18:40:33 +0300 Subject: [PATCH] Create FIR fake source element for vararg argument expression --- .../fir/resolve/transformers/body/resolve/BodyResolveUtils.kt | 2 +- .../fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt index 1ea0276fd73..3d1c7d0aff2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt @@ -58,7 +58,7 @@ internal fun remapArgumentsWithVararg( ) { arguments += arg if (this.source == null) { - this.source = arg.source + this.source = arg.source?.fakeElement(FirFakeSourceElementKind.VarargArgument) } } else if (arguments.isEmpty()) { // `arg` is BEFORE the vararg arguments. diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt index 64951b8468d..b546acbe5c4 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSourceElement.kt @@ -150,6 +150,10 @@ sealed class FirFakeSourceElementKind : FirSourceElementKind() { // super.foo() --> super.foo() // where `Supertype` has a fake source object SuperCallImplicitType : FirFakeSourceElementKind() + + // fun foo(vararg args: Int) {} + // fun bar(1, 2, 3) --> [resolved] fun bar(VarargArgument(1, 2, 3)) + object VarargArgument : FirFakeSourceElementKind() } sealed class FirSourceElement {