K1: Force propagating deprecation on NOT_CONSIDERED JDK members to overrides
^KT-60858 Related KT-60659 In Progress ^KT-60769 In Progress
This commit is contained in:
committed by
Space Team
parent
1e86a82ee1
commit
eae97e4f76
@@ -68,7 +68,8 @@ class JvmBuiltInsCustomizer(
|
||||
// Most this properties are lazy because they depends on KotlinBuiltIns initialization that depends on JvmBuiltInsSettings object
|
||||
private val notConsideredDeprecation by storageManager.createLazyValue {
|
||||
val annotation = moduleDescriptor.builtIns.createDeprecatedAnnotation(
|
||||
"This member is not fully supported by Kotlin compiler, so it may be absent or have different signature in next major version"
|
||||
"This member is not fully supported by Kotlin compiler, so it may be absent or have different signature in next major version",
|
||||
forcePropagationDeprecationToOverrides = true,
|
||||
)
|
||||
Annotations.create(listOf(annotation))
|
||||
}
|
||||
|
||||
+2
-1
@@ -27,7 +27,8 @@ import kotlin.LazyThreadSafetyMode.PUBLICATION
|
||||
class BuiltInAnnotationDescriptor(
|
||||
private val builtIns: KotlinBuiltIns,
|
||||
override val fqName: FqName,
|
||||
override val allValueArguments: Map<Name, ConstantValue<*>>
|
||||
override val allValueArguments: Map<Name, ConstantValue<*>>,
|
||||
val forcePropagationDeprecationToOverrides: Boolean = false,
|
||||
) : AnnotationDescriptor {
|
||||
override val type: KotlinType by lazy(PUBLICATION) {
|
||||
builtIns.getBuiltInClassByFqName(fqName).defaultType
|
||||
|
||||
+15
-2
@@ -29,7 +29,8 @@ import org.jetbrains.kotlin.types.Variance
|
||||
fun KotlinBuiltIns.createDeprecatedAnnotation(
|
||||
message: String,
|
||||
replaceWith: String = "",
|
||||
level: String = "WARNING"
|
||||
level: String = "WARNING",
|
||||
forcePropagationDeprecationToOverrides: Boolean = false,
|
||||
): AnnotationDescriptor {
|
||||
val replaceWithAnnotation = BuiltInAnnotationDescriptor(
|
||||
this,
|
||||
@@ -52,10 +53,22 @@ fun KotlinBuiltIns.createDeprecatedAnnotation(
|
||||
ClassId.topLevel(StandardNames.FqNames.deprecationLevel),
|
||||
Name.identifier(level)
|
||||
)
|
||||
)
|
||||
),
|
||||
forcePropagationDeprecationToOverrides,
|
||||
)
|
||||
}
|
||||
|
||||
// Temporary workaround for kotlinx-serialization-cbor compilation.
|
||||
// We need some kotlinx-serialization components to be resolved to that function instead of one with default argument
|
||||
// because for some time, they have a new version at compile time, but the old core in the classpath.
|
||||
// Might be removed after K/N version is advanced (KT-60858 to track)
|
||||
@Suppress("unused")
|
||||
fun KotlinBuiltIns.createDeprecatedAnnotation(
|
||||
message: String,
|
||||
replaceWith: String = "",
|
||||
level: String = "WARNING",
|
||||
): AnnotationDescriptor = createDeprecatedAnnotation(message, replaceWith, level, forcePropagationDeprecationToOverrides = false)
|
||||
|
||||
private val DEPRECATED_MESSAGE_NAME = Name.identifier("message")
|
||||
private val DEPRECATED_REPLACE_WITH_NAME = Name.identifier("replaceWith")
|
||||
private val DEPRECATED_LEVEL_NAME = Name.identifier("level")
|
||||
|
||||
+14
-1
@@ -10,7 +10,20 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
|
||||
abstract class DescriptorBasedDeprecationInfo : DeprecationInfo() {
|
||||
override val propagatesToOverrides: Boolean
|
||||
get() = true
|
||||
get() = forcePropagationToOverrides
|
||||
|
||||
/**
|
||||
* Marks deprecation as necessary to propagate to overrides
|
||||
* even if LanguageFeature.StopPropagatingDeprecationThroughOverrides is disabled or one of the overrides "undeprecated"
|
||||
* See DeprecationResolver.deprecationByOverridden for details.
|
||||
*
|
||||
* Currently, it's only expected to be true for deprecation from unsupported JDK members that might be removed in future versions:
|
||||
* we'd like to mark their overrides as unsafe as well.
|
||||
*
|
||||
* Also, there's an implicit contract that if `forcePropagationToOverrides`, then `propagatesToOverrides` should also be true
|
||||
*/
|
||||
open val forcePropagationToOverrides: Boolean
|
||||
get() = false
|
||||
|
||||
abstract val target: DeclarationDescriptor
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user