FIR: Support typeRef-name label for this
This commit is contained in:
+15
-9
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -168,11 +168,11 @@ class FirTowerDataContext private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
fun addReceiver(name: Name?, implicitReceiverValue: ImplicitReceiverValue<*>): FirTowerDataContext {
|
||||
fun addReceiver(name: Name?, implicitReceiverValue: ImplicitReceiverValue<*>, additionalLabName: Name? = null): FirTowerDataContext {
|
||||
val element = implicitReceiverValue.asTowerDataElement()
|
||||
return FirTowerDataContext(
|
||||
towerDataElements.add(element),
|
||||
implicitReceiverStack.add(name, implicitReceiverValue),
|
||||
implicitReceiverStack.add(name, implicitReceiverValue, additionalLabName),
|
||||
localScopes,
|
||||
nonLocalTowerDataElements.add(element)
|
||||
)
|
||||
|
||||
+7
-1
@@ -42,7 +42,7 @@ class PersistentImplicitReceiverStack private constructor(
|
||||
val stack = stack.add(value)
|
||||
val originalTypes = originalTypes.add(value.originalType)
|
||||
val index = stack.size - 1
|
||||
val receiversPerLabel = name?.let { receiversPerLabel.put(it, value) } ?: receiversPerLabel
|
||||
val receiversPerLabel = receiversPerLabel.putIfNameIsNotNull(name, value).putIfNameIsNotNull(aliasLabel, value)
|
||||
val indexesPerSymbol = indexesPerSymbol.put(value.boundSymbol, index)
|
||||
|
||||
return PersistentImplicitReceiverStack(
|
||||
@@ -53,6 +53,12 @@ class PersistentImplicitReceiverStack private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun PersistentSetMultimap<Name, ImplicitReceiverValue<*>>.putIfNameIsNotNull(name: Name?, value: ImplicitReceiverValue<*>) =
|
||||
if (name != null)
|
||||
put(name, value)
|
||||
else
|
||||
this
|
||||
|
||||
fun addContextReceiver(value: ContextReceiverValue<*>): PersistentImplicitReceiverStack {
|
||||
val labelName = value.labelName ?: return this
|
||||
|
||||
|
||||
Reference in New Issue
Block a user