[FIR] Use a tree with the proper root node
This commit ensures all the conversions inside the lambda expression use the correct tree reference. Otherwise, the problem arises in the `toFirSourceElement()` call: if called form inside the ExpressionsConverter, everything is OK, but calling it from inside DeclarationsConverter will result in the wrong source text range. This happens, because during the lambda expressions conversion a custom ExpressionsConverter is created with the `lambdaTree` tree, but the DeclarationsConverter continues to use the previous tree.
This commit is contained in:
+1
-1
@@ -58,7 +58,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.runUnless
|
||||
|
||||
class DeclarationsConverter(
|
||||
session: FirSession,
|
||||
private val baseScopeProvider: FirScopeProvider,
|
||||
internal val baseScopeProvider: FirScopeProvider,
|
||||
tree: FlyweightCapableTreeStructure<LighterASTNode>,
|
||||
@set:PrivateForInline override var offset: Int = 0,
|
||||
context: Context<LighterASTNode> = Context(),
|
||||
|
||||
+6
-4
@@ -74,10 +74,12 @@ class ExpressionsConverter(
|
||||
val lambdaTree = LightTree2Fir.buildLightTreeLambdaExpression(expression.asText)
|
||||
// Pass on label user to the lambda root
|
||||
context.forwardLabelUsagePermission(expression, lambdaTree.root)
|
||||
declarationsConverter.withOffset(offset + expression.startOffset) {
|
||||
ExpressionsConverter(baseSession, lambdaTree, declarationsConverter, context)
|
||||
.convertLambdaExpression(lambdaTree.root)
|
||||
}
|
||||
val lambdaDeclarationsConverter = DeclarationsConverter(
|
||||
baseSession, declarationsConverter.baseScopeProvider, lambdaTree,
|
||||
offset = offset + expression.startOffset, context
|
||||
)
|
||||
ExpressionsConverter(baseSession, lambdaTree, lambdaDeclarationsConverter, context)
|
||||
.convertLambdaExpression(lambdaTree.root)
|
||||
}
|
||||
BINARY_EXPRESSION -> convertBinaryExpression(expression)
|
||||
BINARY_WITH_TYPE -> convertBinaryWithTypeRHSExpression(expression) {
|
||||
|
||||
Reference in New Issue
Block a user