FIR: Support typeRef-name label for this

This commit is contained in:
Denis.Zharkov
2022-03-24 14:58:11 +03:00
committed by teamcity
parent ac399321f0
commit 512446843b
13 changed files with 38 additions and 108 deletions
@@ -36,10 +36,7 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirWhenSubjectImportingScope
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames.UNDERSCORE_FOR_UNUSED_VAR
@@ -204,8 +201,8 @@ class BodyResolveContext(
}
@PrivateForInline
fun addReceiver(name: Name?, implicitReceiverValue: ImplicitReceiverValue<*>) {
replaceTowerDataContext(towerDataContext.addReceiver(name, implicitReceiverValue))
fun addReceiver(name: Name?, implicitReceiverValue: ImplicitReceiverValue<*>, additionalLabelName: Name? = null) {
replaceTowerDataContext(towerDataContext.addReceiver(name, implicitReceiverValue, additionalLabelName))
}
@PrivateForInline
@@ -225,6 +222,7 @@ class BodyResolveContext(
owner: FirCallableDeclaration,
type: ConeKotlinType?,
holder: SessionHolder,
additionalLabelName: Name? = null,
f: () -> T
): T = withTowerDataCleanup {
replaceTowerDataContext(towerDataContext.addContextReceiverGroup(owner.createContextReceiverValues(holder)))
@@ -236,7 +234,7 @@ class BodyResolveContext(
holder.session,
holder.scopeSession
)
addReceiver(labelName, receiver)
addReceiver(labelName, receiver, additionalLabelName)
}
f()
@@ -575,13 +573,19 @@ class BodyResolveContext(
storeVariable(parameter, holder.session)
}
val receiverTypeRef = function.receiverTypeRef
withLabelAndReceiverType(function.name, function, receiverTypeRef?.coneType, holder, f)
val type = receiverTypeRef?.coneType
val additionalLabelName = type?.labelName()
withLabelAndReceiverType(function.name, function, type, holder, additionalLabelName, f)
} else {
f()
}
}
}
private fun ConeKotlinType.labelName(): Name? {
return (this as? ConeLookupTagBasedType)?.lookupTag?.name
}
@OptIn(PrivateForInline::class)
fun <T> forConstructorBody(
constructor: FirConstructor,
@@ -714,7 +718,9 @@ class BodyResolveContext(
storeBackingField(property, holder.session)
}
withContainer(accessor) {
withLabelAndReceiverType(property.name, property, receiverTypeRef?.coneType, holder, f)
val type = receiverTypeRef?.coneType
val additionalLabelName = type?.labelName()
withLabelAndReceiverType(property.name, property, type, holder, additionalLabelName, f)
}
}
}