[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
|
KT element: KtCallExpression
|
||||||
FIR element: FirPropertyImpl
|
FIR element: FirFunctionCallImpl
|
||||||
FIR source kind: KtRealSourceElementKind
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
FIR element rendered:
|
FIR element rendered:
|
||||||
public final [ResolvedTo(BODY_RESOLVE)] val $$result: R|kotlin/Int| = R|/foo|()
|
R|/foo|()
|
||||||
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
|
|
||||||
|
|
||||||
FIR FILE:
|
FIR FILE:
|
||||||
FILE: [ResolvedTo(IMPORTS)] syntheticResultDeclaration.kts
|
FILE: [ResolvedTo(IMPORTS)] syntheticResultDeclaration.kts
|
||||||
|
|||||||
Vendored
+3
-11
@@ -1,18 +1,10 @@
|
|||||||
KT element: KtScriptInitializer
|
KT element: KtScriptInitializer
|
||||||
FIR element: FirScriptImpl
|
FIR element: FirPropertyImpl
|
||||||
FIR source kind: KtRealSourceElementKind
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
FIR element rendered:
|
FIR element rendered:
|
||||||
context(<script>@R|kotlin/script/templates/standard/ScriptTemplateWithArgs|)
|
public final [ResolvedTo(BODY_RESOLVE)] val $$result: R|kotlin/Int| = R|/foo|()
|
||||||
SCRIPT: [ResolvedTo(BODY_RESOLVE)] <script-syntheticResultDeclarationInitializer.kts>
|
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||||
[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|
|
|
||||||
|
|
||||||
FIR FILE:
|
FIR FILE:
|
||||||
FILE: [ResolvedTo(IMPORTS)] syntheticResultDeclarationInitializer.kts
|
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.
|
* 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.primaryConstructorIfAny
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.SCRIPT_SPECIAL_NAME_STRING
|
import org.jetbrains.kotlin.fir.declarations.utils.SCRIPT_SPECIAL_NAME_STRING
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
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.expressions.impl.FirSingleExpressionBlock
|
||||||
import org.jetbrains.kotlin.fir.moduleData
|
import org.jetbrains.kotlin.fir.moduleData
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.dependenciesSymbolProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.dependenciesSymbolProvider
|
||||||
@@ -157,13 +156,13 @@ class FirScriptConfiguratorExtensionImpl(
|
|||||||
buildProperty {
|
buildProperty {
|
||||||
this.name = Name.identifier(resultFieldName)
|
this.name = Name.identifier(resultFieldName)
|
||||||
this.symbol = FirPropertySymbol(this.name)
|
this.symbol = FirPropertySymbol(this.name)
|
||||||
source = lastExpression.source
|
source = lastScriptBlock?.source
|
||||||
moduleData = session.moduleData
|
moduleData = session.moduleData
|
||||||
origin = FirDeclarationOrigin.ScriptCustomization.ResultProperty
|
origin = FirDeclarationOrigin.ScriptCustomization.ResultProperty
|
||||||
initializer = lastExpression
|
initializer = lastExpression
|
||||||
returnTypeRef = lastExpressionTypeRef
|
returnTypeRef = lastExpressionTypeRef
|
||||||
getter = FirDefaultPropertyGetter(
|
getter = FirDefaultPropertyGetter(
|
||||||
lastExpression.source,
|
lastScriptBlock?.source?.fakeElement(KtFakeSourceElementKind.DefaultAccessor),
|
||||||
session.moduleData,
|
session.moduleData,
|
||||||
FirDeclarationOrigin.ScriptCustomization.ResultProperty,
|
FirDeclarationOrigin.ScriptCustomization.ResultProperty,
|
||||||
lastExpressionTypeRef,
|
lastExpressionTypeRef,
|
||||||
|
|||||||
Reference in New Issue
Block a user