[FIR] FirScriptConfigurationExtensionImpl: change source element for result$$ property
We should use the source from replaced `FirAnonymousInitializer` as it is more equivalent. Another point – the previous implementation duplicated the source between generated FirProperty and initializer ^KT-65344
This commit is contained in:
committed by
Space Team
parent
f972c8d239
commit
338c533a58
+2
-3
@@ -1,10 +1,9 @@
|
||||
KT element: KtCallExpression
|
||||
FIR element: FirPropertyImpl
|
||||
FIR element: FirFunctionCallImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
public final [ResolvedTo(BODY_RESOLVE)] val $$result: R|kotlin/Int| = R|/foo|()
|
||||
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
R|/foo|()
|
||||
|
||||
FIR FILE:
|
||||
FILE: [ResolvedTo(IMPORTS)] syntheticResultDeclaration.kts
|
||||
|
||||
Vendored
+3
-11
@@ -1,18 +1,10 @@
|
||||
KT element: KtScriptInitializer
|
||||
FIR element: FirScriptImpl
|
||||
FIR element: FirPropertyImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
context(<script>@R|kotlin/script/templates/standard/ScriptTemplateWithArgs|)
|
||||
SCRIPT: [ResolvedTo(BODY_RESOLVE)] <script-syntheticResultDeclarationInitializer.kts>
|
||||
[ResolvedTo(BODY_RESOLVE)] lval args: R|kotlin/Array<kotlin/String>|
|
||||
|
||||
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun foo(): R|kotlin/Int| {
|
||||
^foo Int(24)
|
||||
}
|
||||
|
||||
public final [ResolvedTo(BODY_RESOLVE)] val $$result: R|kotlin/Int| = R|/foo|()
|
||||
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
public final [ResolvedTo(BODY_RESOLVE)] val $$result: R|kotlin/Int| = R|/foo|()
|
||||
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
|
||||
FIR FILE:
|
||||
FILE: [ResolvedTo(IMPORTS)] syntheticResultDeclarationInitializer.kts
|
||||
|
||||
+3
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
|
||||
import org.jetbrains.kotlin.fir.declarations.primaryConstructorIfAny
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.SCRIPT_SPECIAL_NAME_STRING
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildLazyExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
||||
import org.jetbrains.kotlin.fir.moduleData
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.dependenciesSymbolProvider
|
||||
@@ -157,13 +156,13 @@ class FirScriptConfiguratorExtensionImpl(
|
||||
buildProperty {
|
||||
this.name = Name.identifier(resultFieldName)
|
||||
this.symbol = FirPropertySymbol(this.name)
|
||||
source = lastExpression.source
|
||||
source = lastScriptBlock?.source
|
||||
moduleData = session.moduleData
|
||||
origin = FirDeclarationOrigin.ScriptCustomization.ResultProperty
|
||||
initializer = lastExpression
|
||||
returnTypeRef = lastExpressionTypeRef
|
||||
getter = FirDefaultPropertyGetter(
|
||||
lastExpression.source,
|
||||
lastScriptBlock?.source?.fakeElement(KtFakeSourceElementKind.DefaultAccessor),
|
||||
session.moduleData,
|
||||
FirDeclarationOrigin.ScriptCustomization.ResultProperty,
|
||||
lastExpressionTypeRef,
|
||||
|
||||
Reference in New Issue
Block a user