KTIJ-26024 [Analysis API] Provide correct context for class header from FirTowerDataContextAllElementsCollector
To correctly provide the context for class header resolution, we save the additional copy of the context right before `withRegularClass` wrapper call in `LLFirBodyLazyResolver`. Otherwise we would have to clear the existing context by hand, which is too cumbersome (if at all possible) ^KTIJ-26024 Fixed ^KTIJ-24832 Fixed
This commit is contained in:
committed by
Space Team
parent
d7d2c1f260
commit
88450c69b3
+18
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTowerDataContext
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
|
||||
@@ -17,4 +18,21 @@ interface FirTowerDataContextCollector {
|
||||
fun addFileContext(file: FirFile, context: FirTowerDataContext)
|
||||
fun addStatementContext(statement: FirStatement, context: FirTowerDataContext)
|
||||
fun addDeclarationContext(declaration: FirDeclaration, context: FirTowerDataContext)
|
||||
|
||||
/**
|
||||
* Here by "header" we understand the parts of the class declaration which resolution is not affected
|
||||
* by the class own supertypes.
|
||||
*
|
||||
* It includes any type reference mentioned before the body of the class, except for:
|
||||
* - primary constructor declaration with annotations
|
||||
* - super type constructor **value arguments** with annotations
|
||||
*
|
||||
* Also, it includes class type parameters, because they are available anywhere inside the class declaration.
|
||||
*
|
||||
* N.B. We collect header contexts only for [FirRegularClass]es, ignoring
|
||||
* [org.jetbrains.kotlin.fir.declarations.FirAnonymousObject]s. That's because anonymous objects are in
|
||||
* fact expressions, and it should be enough for [FirTowerDataContextCollector] to have a context for
|
||||
* the containing declaration to correctly process everything inside anonymous objects.
|
||||
*/
|
||||
fun addClassHeaderContext(declaration: FirRegularClass, context: FirTowerDataContext)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user