FIR: Initialize dispatchReceiverType and containingClassAttr for callable members
This commit is contained in:
+11
-3
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeAttributes
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
@@ -161,6 +162,8 @@ fun deserializeClassToSymbol(
|
||||
isStatic = true
|
||||
}
|
||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||
}.apply {
|
||||
containingClassAttr = context.dispatchReceiver!!.lookupTag
|
||||
}
|
||||
|
||||
property
|
||||
@@ -168,11 +171,15 @@ fun deserializeClassToSymbol(
|
||||
)
|
||||
|
||||
if (classKind == ClassKind.ENUM_CLASS) {
|
||||
generateValuesFunction(session, classId.packageFqName, classId.relativeClassName)
|
||||
generateValuesFunction(
|
||||
session,
|
||||
classId.packageFqName,
|
||||
classId.relativeClassName
|
||||
)
|
||||
generateValueOfFunction(session, classId.packageFqName, classId.relativeClassName)
|
||||
}
|
||||
|
||||
addCloneForArrayIfNeeded(classId)
|
||||
addCloneForArrayIfNeeded(classId, context.dispatchReceiver)
|
||||
addSerializableIfNeeded(classId)
|
||||
|
||||
declarations.sortWith(object : Comparator<FirDeclaration> {
|
||||
@@ -224,7 +231,7 @@ private fun FirRegularClassBuilder.addSerializableIfNeeded(classId: ClassId) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId) {
|
||||
private fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId, dispatchReceiver: ConeClassLikeType?) {
|
||||
if (classId.packageFqName != StandardNames.BUILT_INS_PACKAGE_FQ_NAME) return
|
||||
if (classId.shortClassName !in ARRAY_CLASSES) return
|
||||
superTypeRefs += buildResolvedTypeRef {
|
||||
@@ -259,5 +266,6 @@ private fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId) {
|
||||
}
|
||||
name = CLONE
|
||||
symbol = FirNamedFunctionSymbol(CallableId(classId, CLONE))
|
||||
dispatchReceiverType = dispatchReceiver!!
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -7,12 +7,14 @@ package org.jetbrains.kotlin.fir.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.containingClassAttr
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub
|
||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
@@ -64,6 +66,7 @@ class FirDeserializationContext(
|
||||
)
|
||||
|
||||
val memberDeserializer: FirMemberDeserializer = FirMemberDeserializer(this)
|
||||
val dispatchReceiver = relativeClassName?.let { ClassId(packageFqName, it, false).defaultType(allTypeParameters) }
|
||||
|
||||
companion object {
|
||||
fun createForPackage(
|
||||
@@ -225,6 +228,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
isExternal = Flags.IS_EXTERNAL_ACCESSOR.get(getterFlags)
|
||||
}
|
||||
this.symbol = FirPropertyAccessorSymbol()
|
||||
dispatchReceiverType = c.dispatchReceiver
|
||||
}.apply {
|
||||
versionRequirementsTable = c.versionRequirementTable
|
||||
}
|
||||
@@ -256,6 +260,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
isExternal = Flags.IS_EXTERNAL_ACCESSOR.get(setterFlags)
|
||||
}
|
||||
this.symbol = FirPropertyAccessorSymbol()
|
||||
dispatchReceiverType = c.dispatchReceiver
|
||||
valueParameters += local.memberDeserializer.valueParameters(
|
||||
listOf(proto.setterValueParameter),
|
||||
proto,
|
||||
@@ -288,6 +293,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
name = callableName
|
||||
this.isVar = isVar
|
||||
this.symbol = symbol
|
||||
dispatchReceiverType = c.dispatchReceiver
|
||||
isLocal = false
|
||||
status = FirResolvedDeclarationStatusImpl(
|
||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||
@@ -365,6 +371,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
isSuspend = Flags.IS_SUSPEND.get(flags)
|
||||
}
|
||||
this.symbol = symbol
|
||||
dispatchReceiverType = c.dispatchReceiver
|
||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
|
||||
valueParameters += local.memberDeserializer.valueParameters(
|
||||
@@ -443,6 +450,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
annotations +=
|
||||
c.annotationDeserializer.loadConstructorAnnotations(c.containerSource, proto, local.nameResolver, local.typeTable)
|
||||
}.build().apply {
|
||||
containingClassAttr = c.dispatchReceiver!!.lookupTag
|
||||
versionRequirementsTable = c.versionRequirementTable
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.fir.deserialization.FirBuiltinAnnotationDeserializer
|
||||
import org.jetbrains.kotlin.fir.deserialization.FirConstDeserializer
|
||||
import org.jetbrains.kotlin.fir.deserialization.FirDeserializationContext
|
||||
import org.jetbrains.kotlin.fir.deserialization.deserializeClassToSymbol
|
||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProviderInternals
|
||||
import org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider
|
||||
@@ -225,6 +226,7 @@ class FirBuiltinSymbolProvider(session: FirSession, val kotlinScopeProvider: Kot
|
||||
isVararg = false
|
||||
}
|
||||
}
|
||||
dispatchReceiverType = classId.defaultType(typeParameters.map { it.symbol })
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user