[FIR] Render deprecation message if it's not a named argument.
This commit is contained in:
committed by
Space Team
parent
8aa32d9f45
commit
6b049df87c
@@ -806,11 +806,11 @@ KtKotlinPropertySymbol:
|
||||
getContainingFileSymbol: KtFileSymbol(deprecated.kt)
|
||||
getContainingJvmClassName: DeprecatedKt
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: DeprecationInfo(deprecationLevel=ERROR, propagatesToOverrides=true, message=null)
|
||||
getterDeprecationStatus: DeprecationInfo(deprecationLevel=ERROR, propagatesToOverrides=true, message=null)
|
||||
deprecationStatus: DeprecationInfo(deprecationLevel=ERROR, propagatesToOverrides=true, message=don't use j)
|
||||
getterDeprecationStatus: DeprecationInfo(deprecationLevel=ERROR, propagatesToOverrides=true, message=don't use j)
|
||||
javaGetterName: getJ
|
||||
javaSetterName: null
|
||||
setterDeprecationStatus: DeprecationInfo(deprecationLevel=ERROR, propagatesToOverrides=true, message=null)
|
||||
setterDeprecationStatus: DeprecationInfo(deprecationLevel=ERROR, propagatesToOverrides=true, message=don't use j)
|
||||
|
||||
KtKotlinPropertySymbol:
|
||||
annotationsList: [
|
||||
@@ -892,11 +892,11 @@ KtKotlinPropertySymbol:
|
||||
getContainingFileSymbol: KtFileSymbol(deprecated.kt)
|
||||
getContainingJvmClassName: DeprecatedKt
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: DeprecationInfo(deprecationLevel=HIDDEN, propagatesToOverrides=true, message=null)
|
||||
getterDeprecationStatus: DeprecationInfo(deprecationLevel=HIDDEN, propagatesToOverrides=true, message=null)
|
||||
deprecationStatus: DeprecationInfo(deprecationLevel=HIDDEN, propagatesToOverrides=true, message=don't use j2)
|
||||
getterDeprecationStatus: DeprecationInfo(deprecationLevel=HIDDEN, propagatesToOverrides=true, message=don't use j2)
|
||||
javaGetterName: getJ2
|
||||
javaSetterName: null
|
||||
setterDeprecationStatus: DeprecationInfo(deprecationLevel=HIDDEN, propagatesToOverrides=true, message=null)
|
||||
setterDeprecationStatus: DeprecationInfo(deprecationLevel=HIDDEN, propagatesToOverrides=true, message=don't use j2)
|
||||
|
||||
KtKotlinPropertySymbol:
|
||||
annotationsList: []
|
||||
|
||||
+2
-2
@@ -764,8 +764,8 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
map.put(VAL_OR_VAR_ON_FUN_PARAMETER, "''{0}'' on function parameter is prohibited.", TO_STRING)
|
||||
map.put(VAL_OR_VAR_ON_CATCH_PARAMETER, "''{0}'' on catch parameter is prohibited.", TO_STRING)
|
||||
map.put(VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER, "''{0}'' on secondary constructor parameter is prohibited.", TO_STRING)
|
||||
map.put(DEPRECATION, "''{0}'' is deprecated. {1}.", SYMBOL, STRING)
|
||||
map.put(DEPRECATION_ERROR, "''{0}'' is deprecated. {1}.", SYMBOL, STRING)
|
||||
map.put(DEPRECATION, "''{0}'' is deprecated.{1}", SYMBOL, OPTIONAL_SENTENCE)
|
||||
map.put(DEPRECATION_ERROR, "''{0}'' is deprecated.{1}", SYMBOL, OPTIONAL_SENTENCE)
|
||||
map.put(VERSION_REQUIREMENT_DEPRECATION, "''{0}''{1} should not be used in Kotlin {2}.{3}", SYMBOL, REQUIRE_KOTLIN_VERSION, STRING, OPTIONAL_SENTENCE)
|
||||
map.put(VERSION_REQUIREMENT_DEPRECATION_ERROR, "''{0}''{1} cannot be used in Kotlin {2}.{3}", SYMBOL, REQUIRE_KOTLIN_VERSION, STRING, OPTIONAL_SENTENCE)
|
||||
map.put(TYPEALIAS_EXPANSION_DEPRECATION, "''{0}'' uses ''{1}'', which is deprecated. {2}.", SYMBOL, SYMBOL, STRING)
|
||||
|
||||
@@ -287,6 +287,7 @@ private fun List<FirAnnotation>.extractDeprecationAnnotationInfoPerUseSite(
|
||||
it.unexpandedClassId == StandardClassIds.Annotations.DeprecatedSinceKotlin
|
||||
}
|
||||
val message = deprecated.getStringArgument(ParameterNames.deprecatedMessage)
|
||||
?: deprecated.getFirstArgumentStringIfNotNamed()
|
||||
|
||||
val deprecatedInfo =
|
||||
if (deprecatedSinceKotlin == null) {
|
||||
@@ -310,6 +311,12 @@ private fun List<FirAnnotation>.extractDeprecationAnnotationInfoPerUseSite(
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirAnnotation.getFirstArgumentStringIfNotNamed(): String? {
|
||||
if (this !is FirAnnotationCall) return null
|
||||
val firstArgument = argumentList.arguments.firstOrNull() ?: return null
|
||||
return (firstArgument as? FirConstExpression<*>)?.value?.toString()
|
||||
}
|
||||
|
||||
|
||||
fun FirBasedSymbol<*>.isDeprecationLevelHidden(languageVersionSettings: LanguageVersionSettings): Boolean =
|
||||
when (this) {
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
error: opt-in requirement marker org.test.Error is deprecated
|
||||
error: opt-in requirement marker org.test.Hidden is deprecated
|
||||
error: opt-in requirement marker org.test.Error is deprecated. Error
|
||||
error: opt-in requirement marker org.test.Hidden is deprecated. Hidden
|
||||
COMPILATION_ERROR
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
warning: argument -Xopt-in is deprecated. Please use -opt-in instead
|
||||
warning: opt-in requirement marker org.test.Warning is deprecated
|
||||
warning: opt-in requirement marker org.test.Warning is deprecated. Warning
|
||||
OK
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/deprecatedError.kt:10:13: error: using 'C' is an error. alas
|
||||
fun test(c: C) {
|
||||
^
|
||||
/deprecatedError.kt:11:5: error: using 'foo(String): Unit' is an error. alas
|
||||
foo("")
|
||||
^
|
||||
/deprecatedError.kt:12:5: error: using 'C' is an error. alas
|
||||
C()
|
||||
^
|
||||
@@ -0,0 +1,5 @@
|
||||
/deprecatedError.kt:(237,238): error: '@Deprecated(...) class C : Any' is deprecated. alas.
|
||||
|
||||
/deprecatedError.kt:(246,249): error: '@Deprecated(...) fun foo(s: @R|Foo|() String): Unit' is deprecated. alas.
|
||||
|
||||
/deprecatedError.kt:(258,259): error: 'constructor(): C' is deprecated. alas.
|
||||
@@ -1,12 +1,16 @@
|
||||
// FIR_IDENTICAL
|
||||
// RENDER_DIAGNOSTICS_FULL_TEXT
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@Deprecated("alas", level = DeprecationLevel.ERROR)
|
||||
fun foo() {}
|
||||
fun foo(s: @Foo String) {}
|
||||
|
||||
@Deprecated("alas", level = DeprecationLevel.ERROR)
|
||||
class C
|
||||
|
||||
fun test(c: <!DEPRECATION_ERROR!>C<!>) {
|
||||
<!DEPRECATION_ERROR!>foo<!>()
|
||||
<!DEPRECATION_ERROR!>foo<!>("")
|
||||
<!DEPRECATION_ERROR!>C<!>()
|
||||
}
|
||||
}
|
||||
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Foo
|
||||
@@ -1,11 +0,0 @@
|
||||
package
|
||||
|
||||
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "alas") public fun foo(): kotlin.Unit
|
||||
public fun test(/*0*/ c: C): kotlin.Unit
|
||||
|
||||
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "alas") public final class C {
|
||||
public constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user