[FIR] Rename applyToActualCapturedTypeParameters to appendOuterTypeParameters

This commit is contained in:
Ivan Kochurkin
2021-08-17 13:29:55 +03:00
committed by TeamCityServer
parent d4a11fc295
commit 09510633c7
3 changed files with 7 additions and 14 deletions
@@ -449,9 +449,7 @@ class DeclarationsConverter(
annotations += modifiers.annotations annotations += modifiers.annotations
typeParameters += firTypeParameters typeParameters += firTypeParameters
context.applyToActualCapturedTypeParameters(true) { context.appendOuterTypeParameters(ignoreLastLevel = true, typeParameters)
typeParameters += buildOuterClassTypeParameterRef { symbol = it }
}
val selfType = classNode.toDelegatedSelfType(this) val selfType = classNode.toDelegatedSelfType(this)
registerSelfType(selfType) registerSelfType(selfType)
@@ -588,9 +586,7 @@ class DeclarationsConverter(
scopeProvider = baseScopeProvider scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol() symbol = FirAnonymousObjectSymbol()
status = FirDeclarationStatusImpl(Visibilities.Local, Modality.FINAL) status = FirDeclarationStatusImpl(Visibilities.Local, Modality.FINAL)
context.applyToActualCapturedTypeParameters(false) { context.appendOuterTypeParameters(ignoreLastLevel = false, typeParameters)
typeParameters += buildOuterClassTypeParameterRef { this.symbol = it }
}
val delegatedSelfType = objectLiteral.toDelegatedSelfType(this) val delegatedSelfType = objectLiteral.toDelegatedSelfType(this)
registerSelfType(delegatedSelfType) registerSelfType(delegatedSelfType)
@@ -1058,9 +1058,7 @@ open class RawFirBuilder(
classOrObject.extractAnnotationsTo(this) classOrObject.extractAnnotationsTo(this)
classOrObject.extractTypeParametersTo(this, symbol) classOrObject.extractTypeParametersTo(this, symbol)
context.applyToActualCapturedTypeParameters(true) { context.appendOuterTypeParameters(ignoreLastLevel = true, typeParameters)
typeParameters += buildOuterClassTypeParameterRef { symbol = it }
}
context.pushFirTypeParameters( context.pushFirTypeParameters(
status.isInner, status.isInner,
typeParameters.subList(0, classOrObject.typeParameters.size) typeParameters.subList(0, classOrObject.typeParameters.size)
@@ -1158,9 +1156,7 @@ open class RawFirBuilder(
scopeProvider = baseScopeProvider scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol() symbol = FirAnonymousObjectSymbol()
status = FirDeclarationStatusImpl(Visibilities.Local, Modality.FINAL) status = FirDeclarationStatusImpl(Visibilities.Local, Modality.FINAL)
context.applyToActualCapturedTypeParameters(false) { context.appendOuterTypeParameters(ignoreLastLevel = false, typeParameters)
typeParameters += buildOuterClassTypeParameterRef { symbol = it }
}
val delegatedSelfType = objectDeclaration.toDelegatedSelfType(this) val delegatedSelfType = objectDeclaration.toDelegatedSelfType(this)
registerSelfType(delegatedSelfType) registerSelfType(delegatedSelfType)
objectDeclaration.extractAnnotationsTo(this) objectDeclaration.extractAnnotationsTo(this)
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.FirLabel
import org.jetbrains.kotlin.fir.FirLoopTarget import org.jetbrains.kotlin.fir.FirLoopTarget
import org.jetbrains.kotlin.fir.PrivateForInline import org.jetbrains.kotlin.fir.PrivateForInline
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef
import org.jetbrains.kotlin.fir.declarations.builder.buildOuterClassTypeParameterRef
import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.ConeClassLikeType
@@ -57,13 +58,13 @@ class Context<T> {
list.removeAt(list.lastIndex) list.removeAt(list.lastIndex)
} }
inline fun applyToActualCapturedTypeParameters(ignoreLastLevel: Boolean, action: (FirTypeParameterSymbol) -> Unit) { fun appendOuterTypeParameters(ignoreLastLevel: Boolean, typeParameters: MutableList<FirTypeParameterRef>) {
for (index in capturedTypeParameters.lastIndex downTo 0) { for (index in capturedTypeParameters.lastIndex downTo 0) {
val element = capturedTypeParameters[index] val element = capturedTypeParameters[index]
if (index < capturedTypeParameters.lastIndex || !ignoreLastLevel) { if (index < capturedTypeParameters.lastIndex || !ignoreLastLevel) {
for (capturedTypeParameter in element.list) { for (capturedTypeParameter in element.list) {
action(capturedTypeParameter) typeParameters += buildOuterClassTypeParameterRef { symbol = capturedTypeParameter }
} }
} }