FIR: Refactor designated body transformers
The idea is making their mechanics more transparent and clear Namely, we should move to the next level of designation only for declaration's content Otherwise there might be some wrong steps when somebody just randomly calls "transformElement" on the parent declaration. For example, it happens for local classes when we resolve their supertypes, etc.
This commit is contained in:
@@ -214,19 +214,13 @@ private class FirDesignatedBodyResolveTransformerForIDE(
|
||||
scopeSession = scopeSession,
|
||||
returnTypeCalculator = createReturnTypeCalculatorForIDE(session, scopeSession)
|
||||
) {
|
||||
override fun <E : FirElement> transformElement(element: E, data: ResolutionMode): CompositeTransformResult<E> {
|
||||
override fun transformDeclarationContent(declaration: FirDeclaration, data: ResolutionMode): CompositeTransformResult<FirDeclaration> {
|
||||
if (designation.hasNext()) {
|
||||
designation.next().visitNoTransform(this, data)
|
||||
return element.compose()
|
||||
return declaration.compose()
|
||||
}
|
||||
return super.transformElement(element, data)
|
||||
}
|
||||
|
||||
override fun transformDeclaration(declaration: FirDeclaration, data: ResolutionMode): CompositeTransformResult<FirDeclaration> {
|
||||
return context.withContainer(declaration) {
|
||||
declaration.replaceResolvePhase(transformerPhase)
|
||||
transformElement(declaration, data)
|
||||
}
|
||||
return super.transformDeclarationContent(declaration, data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user