[FIR] Add diagnostic when annotation argument is resolved ambiguously
Annotation arguments that are resolved in COMPILER_REQUIRED_ANNOTATIONS phase are resolved again in ANNOTATION_ARGUMENTS phase. If they resolve to a different symbol, report an error. KT-56177
This commit is contained in:
committed by
Space Team
parent
9dda5e4fcd
commit
2139914061
compiler/testData/diagnostics/testsWithStdLib/annotations/annotationTargetResolvedAmbiguously.fir.kt
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
import kotlin.annotation.AnnotationTarget.FIELD
|
||||
|
||||
object Some {
|
||||
@Target(<!ARGUMENT_TYPE_MISMATCH!>AnnotationTarget.<!AMBIGUOUS_ANNOTATION_ARGUMENT!>CLASS<!><!>)
|
||||
annotation class Ann
|
||||
|
||||
enum class AnnotationTarget {
|
||||
CLASS
|
||||
}
|
||||
|
||||
@Target(<!AMBIGUOUS_ANNOTATION_ARGUMENT!>FIELD<!>)
|
||||
annotation class Ann2
|
||||
|
||||
const val FIELD = ""
|
||||
}
|
||||
|
||||
object SomeMore {
|
||||
@Target(<!ARGUMENT_TYPE_MISMATCH!>kotlin.annotation.AnnotationTarget.<!AMBIGUOUS_ANNOTATION_ARGUMENT!>FUNCTION<!><!>)
|
||||
annotation class Ann3
|
||||
|
||||
object kotlin {
|
||||
object annotation {
|
||||
enum class AnnotationTarget {
|
||||
FUNCTION
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Base {
|
||||
annotation class Target(val target: AnnotationTarget)
|
||||
|
||||
enum class AnnotationTarget {
|
||||
TYPE
|
||||
}
|
||||
}
|
||||
|
||||
class Derived : Base() {
|
||||
@<!PLUGIN_ANNOTATION_AMBIGUITY!>Target<!>(<!ARGUMENT_TYPE_MISMATCH!>AnnotationTarget.<!AMBIGUOUS_ANNOTATION_ARGUMENT!>TYPE<!><!>)
|
||||
annotation class Ann
|
||||
|
||||
fun foo(x: <!WRONG_ANNOTATION_TARGET!>@Ann<!> String) {}
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
import kotlin.annotation.AnnotationTarget.FIELD
|
||||
|
||||
object Some {
|
||||
@Target(<!TYPE_MISMATCH!>AnnotationTarget.CLASS<!>)
|
||||
annotation class Ann
|
||||
|
||||
enum class AnnotationTarget {
|
||||
CLASS
|
||||
}
|
||||
|
||||
@Target(<!TYPE_MISMATCH!>FIELD<!>)
|
||||
annotation class Ann2
|
||||
|
||||
const val FIELD = ""
|
||||
}
|
||||
|
||||
object SomeMore {
|
||||
@Target(<!TYPE_MISMATCH!>kotlin.annotation.AnnotationTarget.FUNCTION<!>)
|
||||
annotation class Ann3
|
||||
|
||||
object kotlin {
|
||||
object annotation {
|
||||
enum class AnnotationTarget {
|
||||
FUNCTION
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Base {
|
||||
annotation class Target(val target: AnnotationTarget)
|
||||
|
||||
enum class AnnotationTarget {
|
||||
TYPE
|
||||
}
|
||||
}
|
||||
|
||||
class Derived : Base() {
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann
|
||||
|
||||
fun foo(x: <!WRONG_ANNOTATION_TARGET!>@Ann<!> String) {}
|
||||
}
|
||||
Reference in New Issue
Block a user