[Test] Add test for ugly K2 reporting of annotation arguments

...in `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic message.

^KT-62585
This commit is contained in:
Roman Efremov
2023-10-13 13:48:59 +02:00
committed by Space Team
parent 67ac985be7
commit b3467353b2
5 changed files with 62 additions and 0 deletions
@@ -0,0 +1,22 @@
// WITH_STDLIB
// MODULE: m1-common
// FILE: common.kt
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
expect annotation class Ann
@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION)
annotation class Ann2(val s: String)
@Ann2("1" + "2")
expect fun stringConcat()
expect fun onType(): @Ann2("") Any?
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual annotation class <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("annotation class Ann : Annotation; annotation class Ann : Annotation; Annotation `@Target(allowedTargets = vararg(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.FUNCTION|, Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.CLASS|))` is missing on actual declaration")!>Ann<!><!>
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun stringConcat(): Unit; fun stringConcat(): Unit; Annotation `@Ann2(s = String(1).R|kotlin/String.plus|(String(2)))` is missing on actual declaration")!>stringConcat<!>() {}<!>
// Not reported in K1, because supported starting from K2
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun onType(): @R|Ann2|(s = String()) Any?; fun onType(): Any?; Annotation `@Ann2(s = String())` is missing on actual declaration")!>onType<!>(): Any? = null<!>
@@ -0,0 +1,22 @@
// WITH_STDLIB
// MODULE: m1-common
// FILE: common.kt
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
expect annotation class Ann
@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION)
annotation class Ann2(val s: String)
@Ann2("1" + "2")
expect fun stringConcat()
expect fun onType(): @Ann2("") Any?
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual annotation class <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("annotation class Ann : Annotation defined in root package in file common.kt; annotation class Ann : Annotation defined in root package in file jvm.kt; Annotation `@Target(allowedTargets = {AnnotationTarget.FUNCTION, AnnotationTarget.CLASS})` is missing on actual declaration")!>Ann<!>
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT("fun stringConcat(): Unit defined in root package in file common.kt; fun stringConcat(): Unit defined in root package in file jvm.kt; Annotation `@Ann2(s = "12")` is missing on actual declaration")!>stringConcat<!>() {}
// Not reported in K1, because supported starting from K2
actual fun onType(): Any? = null