KT-61245 [LL API] Refactor ContextCollector

Extract visiting class header into a separate function

^KT-61245 Fixed
This commit is contained in:
Roman Golyshev
2023-09-06 00:38:25 +02:00
committed by Space Team
parent 7ddb4f8324
commit efad248d7d
@@ -326,13 +326,7 @@ private class ContextCollectorVisitor(
regularClass.lazyResolveToPhase(FirResolvePhase.STATUS)
context.withContainingClass(regularClass) {
processList(regularClass.contextReceivers)
processList(regularClass.typeParameters)
// we do it before we actually visit the constructors,
// because we don't want to have implicit this receiver
// for supertype callee positions
processList(regularClass.superTypeRefs)
processClassHeader(regularClass)
context.withRegularClass(regularClass, holder) {
dumpContext(regularClass, ContextKind.BODY)
@@ -351,6 +345,19 @@ private class ContextCollectorVisitor(
}
}
/**
* Process the parts of the class declaration which resolution is not affected
* by the class own supertypes.
*
* Processing those parts before adding the implicit receiver of the class
* to the [context] allows to not collect incorrect contexts for them later on.
*/
private fun Processor.processClassHeader(regularClass: FirRegularClass) {
processList(regularClass.contextReceivers)
processList(regularClass.typeParameters)
processList(regularClass.superTypeRefs)
}
override fun visitConstructor(constructor: FirConstructor) = withProcessor {
dumpContext(constructor, ContextKind.SELF)