[FIR] Implement VERSION_REQUIREMENT_DEPRECATION diagnostics
This commit is contained in:
committed by
Space Team
parent
65ea9697ab
commit
09f895efe6
+5
-4
@@ -113,6 +113,8 @@ fun deserializeClassToSymbol(
|
||||
}
|
||||
}
|
||||
|
||||
val versionRequirements = VersionRequirement.create(classProto, context)
|
||||
|
||||
buildRegularClass {
|
||||
this.moduleData = moduleData
|
||||
this.origin = origin
|
||||
@@ -140,7 +142,7 @@ fun deserializeClassToSymbol(
|
||||
)
|
||||
|
||||
addDeclarations(
|
||||
classProto.propertiesInOrder(context).map {
|
||||
classProto.propertiesInOrder(versionRequirements).map {
|
||||
classDeserializer.loadProperty(it, classProto, symbol)
|
||||
}
|
||||
)
|
||||
@@ -225,7 +227,7 @@ fun deserializeClassToSymbol(
|
||||
context.annotationDeserializer.loadClassAnnotations(classProto, context.nameResolver)
|
||||
)
|
||||
|
||||
versionRequirementsTable = context.versionRequirementTable
|
||||
this.versionRequirements = versionRequirements
|
||||
|
||||
sourceElement = containerSource
|
||||
|
||||
@@ -296,9 +298,8 @@ fun FirRegularClassBuilder.addCloneForArrayIfNeeded(classId: ClassId, dispatchRe
|
||||
}
|
||||
}
|
||||
|
||||
private fun ProtoBuf.ClassOrBuilder.propertiesInOrder(context: FirDeserializationContext): List<ProtoBuf.Property> {
|
||||
private fun ProtoBuf.ClassOrBuilder.propertiesInOrder(versionRequirements: List<VersionRequirement>): List<ProtoBuf.Property> {
|
||||
val properties = propertyList
|
||||
val versionRequirements = VersionRequirement.create(this, context.nameResolver, context.versionRequirementTable)
|
||||
if (versionRequirements.any { it.version.major >= 2 }) return properties
|
||||
val order = getExtension(SerializationPluginMetadataExtensions.propertiesNamesInProgramOrder)
|
||||
.takeIf { it.isNotEmpty() }
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.metadata.deserialization.VersionRequirement
|
||||
import org.jetbrains.kotlin.protobuf.MessageLiteOrBuilder
|
||||
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
internal fun VersionRequirement.Companion.create(proto: MessageLiteOrBuilder, context: FirDeserializationContext): List<VersionRequirement> =
|
||||
create(proto, context.nameResolver, context.versionRequirementTable)
|
||||
+12
-10
@@ -204,6 +204,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
val classId = ClassId(c.packageFqName, name)
|
||||
val symbol = preComputedSymbol ?: FirTypeAliasSymbol(classId)
|
||||
val local = c.childContext(proto.typeParameterList, containingDeclarationSymbol = symbol)
|
||||
val versionRequirements = VersionRequirement.create(proto, c)
|
||||
return buildTypeAlias {
|
||||
moduleData = c.moduleData
|
||||
origin = FirDeclarationOrigin.Library
|
||||
@@ -223,8 +224,9 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
expandedTypeRef = proto.underlyingType(c.typeTable).toTypeRef(local)
|
||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
|
||||
deprecationsProvider = annotations.getDeprecationsProviderFromAnnotations(c.session, fromJava = false, versionRequirements)
|
||||
}.apply {
|
||||
versionRequirementsTable = c.versionRequirementTable
|
||||
this.versionRequirements = versionRequirements
|
||||
sourceElement = c.containerSource
|
||||
}
|
||||
}
|
||||
@@ -257,7 +259,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
dispatchReceiverType = c.dispatchReceiver
|
||||
this.propertySymbol = propertySymbol
|
||||
}.apply {
|
||||
versionRequirementsTable = c.versionRequirementTable
|
||||
this.versionRequirements = VersionRequirement.create(proto, c)
|
||||
}
|
||||
} else {
|
||||
FirDefaultPropertyGetter(
|
||||
@@ -317,7 +319,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
)
|
||||
this.propertySymbol = propertySymbol
|
||||
}.apply {
|
||||
versionRequirementsTable = c.versionRequirementTable
|
||||
this.versionRequirements = VersionRequirement.create(proto, c)
|
||||
}
|
||||
} else {
|
||||
FirDefaultPropertySetter(
|
||||
@@ -375,6 +377,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
val propertyModality = ProtoEnumFlags.modality(Flags.MODALITY.get(flags))
|
||||
|
||||
val isVar = Flags.IS_VAR.get(flags)
|
||||
val versionRequirements = VersionRequirement.create(proto, c)
|
||||
return buildProperty {
|
||||
moduleData = c.moduleData
|
||||
origin = FirDeclarationOrigin.Library
|
||||
@@ -463,12 +466,12 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
deprecationsProvider = annotations.getDeprecationsProviderFromAnnotations(c.session, fromJava = false)
|
||||
|
||||
proto.contextReceiverTypes(c.typeTable).mapTo(contextReceivers, ::loadContextReceiver)
|
||||
}.apply {
|
||||
initializer?.replaceTypeRef(returnTypeRef)
|
||||
versionRequirementsTable = c.versionRequirementTable
|
||||
this.versionRequirements = versionRequirements
|
||||
replaceDeprecationsProvider(getDeprecationsProvider(c.session))
|
||||
setLazyPublishedVisibility(c.session)
|
||||
getter?.setLazyPublishedVisibility(annotations, this, c.session)
|
||||
setter?.setLazyPublishedVisibility(annotations, this, c.session)
|
||||
@@ -509,6 +512,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
val symbol = FirNamedFunctionSymbol(callableId)
|
||||
val local = c.childContext(proto.typeParameterList, containingDeclarationSymbol = symbol)
|
||||
|
||||
val versionRequirements = VersionRequirement.create(proto, c)
|
||||
val simpleFunction = buildSimpleFunction {
|
||||
moduleData = c.moduleData
|
||||
origin = deserializationOrigin
|
||||
@@ -551,12 +555,12 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
)
|
||||
annotations +=
|
||||
c.annotationDeserializer.loadFunctionAnnotations(c.containerSource, proto, local.nameResolver, local.typeTable)
|
||||
deprecationsProvider = annotations.getDeprecationsProviderFromAnnotations(c.session, fromJava = false)
|
||||
deprecationsProvider = annotations.getDeprecationsProviderFromAnnotations(c.session, fromJava = false, versionRequirements)
|
||||
this.containerSource = c.containerSource
|
||||
|
||||
proto.contextReceiverTypes(c.typeTable).mapTo(contextReceivers, ::loadContextReceiver)
|
||||
}.apply {
|
||||
versionRequirementsTable = c.versionRequirementTable
|
||||
this.versionRequirements = versionRequirements
|
||||
setLazyPublishedVisibility(c.session)
|
||||
}
|
||||
if (proto.hasContract()) {
|
||||
@@ -640,7 +644,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
contextReceivers.addAll(createContextReceiversForClass(classProto))
|
||||
}.build().apply {
|
||||
containingClassForStaticMemberAttr = c.dispatchReceiver!!.lookupTag
|
||||
versionRequirementsTable = c.versionRequirementTable
|
||||
this.versionRequirements = VersionRequirement.create(proto, c)
|
||||
setLazyPublishedVisibility(c.session)
|
||||
}
|
||||
}
|
||||
@@ -688,8 +692,6 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
callableKind,
|
||||
index,
|
||||
)
|
||||
}.apply {
|
||||
versionRequirementsTable = c.versionRequirementTable
|
||||
}
|
||||
}.toList()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user