[K2] Warn about deprecation and opt-in markers for overrides of Any

^KT-62620 Fixed

Include opt-in markers in the diagnostics
This commit is contained in:
Alejandro Serrano Mena
2023-10-16 16:00:40 +02:00
committed by Space Team
parent 6afe716238
commit b9b15cba08
17 changed files with 300 additions and 1 deletions
@@ -0,0 +1,30 @@
annotation class Other
@RequiresOptIn(message = "This is a test.")
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.FUNCTION)
annotation class OptInMarker
class A {
@Other
<!POTENTIALLY_NON_REPORTED_ANNOTATION!>@Deprecated("equals")<!>
<!POTENTIALLY_NON_REPORTED_ANNOTATION!>@SinceKotlin("1.2")<!>
override fun equals(other: Any?): Boolean {
return super.equals(other)
}
<!POTENTIALLY_NON_REPORTED_ANNOTATION!>@SinceKotlin("1.3")<!>
override fun hashCode(): Int {
return super.hashCode()
}
<!POTENTIALLY_NON_REPORTED_ANNOTATION!>@Deprecated("toString")<!>
<!POTENTIALLY_NON_REPORTED_ANNOTATION!>@OptInMarker<!>
override fun toString(): String {
return super.toString()
}
@Deprecated("other")
@OptInMarker
fun test(): Int = 5
}
@@ -0,0 +1,30 @@
annotation class Other
@RequiresOptIn(message = "This is a test.")
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.FUNCTION)
annotation class OptInMarker
class A {
@Other
@Deprecated("equals")
@SinceKotlin("1.2")
override fun equals(other: Any?): Boolean {
return super.equals(other)
}
@SinceKotlin("1.3")
override fun hashCode(): Int {
return super.hashCode()
}
@Deprecated("toString")
@OptInMarker
override fun toString(): String {
return super.toString()
}
@Deprecated("other")
@OptInMarker
fun test(): Int = 5
}