[FE, IR] Make expect actual annotations diagnostic message more friendly

Print which annotation exactly has a problem instead of
printing whole declarations with all annotations.

^KT-58551
This commit is contained in:
Roman Efremov
2023-07-31 14:05:40 +02:00
committed by Space Team
parent 11ccad7e40
commit 6943d03883
11 changed files with 153 additions and 46 deletions
@@ -1,19 +1,20 @@
// -- Module: <m1-common> --
// -- Module: <m1-jvm> --
/jvm.kt:23:14: warning: all annotations from `expect` must be presented with same arguments on `actual`, otherwise they have no effect.
Expected: @Ann public final expect class OnClass defined in root package in file common.kt
Actual: public final actual class OnClass defined in root package in file jvm.kt
/jvm.kt:27:14: warning: annotation `@Ann` is missing on actual declaration.
All annotations from expect `class OnClass defined in root package in file common.kt` must be present with the same arguments on actual `class OnClass defined in root package in file jvm.kt`, otherwise they might behave incorrectly.
actual class OnClass
^
/jvm.kt:26:16: warning: all annotations from `expect` must be presented with same arguments on `actual`, otherwise they have no effect.
Expected: @Ann public final expect fun onMember(): Unit defined in OnMember
Actual: public final actual fun onMember(): Unit defined in OnMember
/jvm.kt:30:16: warning: annotation `@Ann` is missing on actual declaration.
All annotations from expect `fun onMember(): Unit defined in OnMember` must be present with the same arguments on actual `fun onMember(): Unit defined in OnMember`, otherwise they might behave incorrectly.
actual fun onMember() {}
^
/jvm.kt:33:18: warning: all annotations from `expect` must be presented with same arguments on `actual`, otherwise they have no effect.
Expected: @Ann public final expect class ViaTypealias defined in root package in file common.kt
Actual: public final class ViaTypealiasImpl defined in root package in file jvm.kt
/jvm.kt:37:18: warning: annotation `@Ann` is missing on actual declaration.
All annotations from expect `class ViaTypealias defined in root package in file common.kt` must be present with the same arguments on actual `class ViaTypealiasImpl defined in root package in file jvm.kt`, otherwise they might behave incorrectly.
actual typealias ViaTypealias = ViaTypealiasImpl
^
/jvm.kt:40:12: warning: annotation `@WithArg(s = "str")` has different arguments on actual declaration: `@WithArg(s = "other str")`.
All annotations from expect `fun withDifferentArg(): Unit defined in root package in file common.kt` must be present with the same arguments on actual `fun withDifferentArg(): Unit defined in root package in file jvm.kt`, otherwise they might behave incorrectly.
actual fun withDifferentArg() {}
^
@@ -1,11 +1,11 @@
/jvm.kt:(82,89): warning: All annotations from `expect` must be presented with same arguments on `actual`, otherwise they have no effect.
Expected: @Ann() public final expect class OnClass : Any
Actual: public final actual class OnClass : Any
/jvm.kt:(86,93): warning: Annotation `@Ann()` is missing on actual declaration.
All annotations from expect `class OnClass : Any` must be present with the same arguments on actual `class OnClass : Any`, otherwise they might behave incorrectly.
/jvm.kt:(130,138): warning: All annotations from `expect` must be presented with same arguments on `actual`, otherwise they have no effect.
Expected: @Ann() public final expect fun onMember(): Unit
Actual: public final actual fun onMember(): Unit
/jvm.kt:(134,142): warning: Annotation `@Ann()` is missing on actual declaration.
All annotations from expect `fun onMember(): Unit` must be present with the same arguments on actual `fun onMember(): Unit`, otherwise they might behave incorrectly.
/jvm.kt:(209,221): warning: All annotations from `expect` must be presented with same arguments on `actual`, otherwise they have no effect.
Expected: @Ann() public final expect class ViaTypealias : Any
Actual: public final class ViaTypealiasImpl : Any
/jvm.kt:(213,225): warning: Annotation `@Ann()` is missing on actual declaration.
All annotations from expect `class ViaTypealias : Any` must be present with the same arguments on actual `class ViaTypealiasImpl : Any`, otherwise they might behave incorrectly.
/jvm.kt:(279,295): warning: Annotation `@WithArg(s = String(str))` has different arguments on actual declaration: `@WithArg(s = String(other str))`.
All annotations from expect `fun withDifferentArg(): Unit` must be present with the same arguments on actual `fun withDifferentArg(): Unit`, otherwise they might behave incorrectly.
@@ -17,6 +17,10 @@ expect class ViaTypealias {
fun foo()
}
annotation class WithArg(val s: String)
@WithArg("str")
expect fun withDifferentArg()
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
@@ -31,3 +35,6 @@ class ViaTypealiasImpl {
}
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT, ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual typealias <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>ViaTypealias<!> = ViaTypealiasImpl<!>
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>@WithArg("other str")
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>withDifferentArg<!>() {}<!>
@@ -17,6 +17,10 @@ expect class ViaTypealias {
fun foo()
}
annotation class WithArg(val s: String)
@WithArg("str")
expect fun withDifferentArg()
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
@@ -31,3 +35,6 @@ class ViaTypealiasImpl {
}
actual typealias <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>ViaTypealias<!> = ViaTypealiasImpl
@WithArg("other str")
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>withDifferentArg<!>() {}