[IR] Prevent duplicated reports of ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT
...on property accessors and enum entries. ^KT-62559
This commit is contained in:
committed by
Space Team
parent
2b120f6cdc
commit
29c82c668f
+13
@@ -559,6 +559,19 @@ internal abstract class IrExpectActualMatchingContext(
|
|||||||
// IR checker traverses member scope itself and collects mappings
|
// IR checker traverses member scope itself and collects mappings
|
||||||
override val checkClassScopesForAnnotationCompatibility = false
|
override val checkClassScopesForAnnotationCompatibility = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From IR checker point of view geter and seter are usual methods, so they don't need
|
||||||
|
* special handling inside checker.
|
||||||
|
* This is to prevent duplicated reports of diagnostic.
|
||||||
|
*/
|
||||||
|
override val checkPropertyAccessorsForAnnotationsCompatibility = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as [checkPropertyAccessorsForAnnotationsCompatibility], enum entries are usual
|
||||||
|
* callables for IR checker, so they don't need special handling.
|
||||||
|
*/
|
||||||
|
override val checkEnumEntriesForAnnotationsCompatibility = false
|
||||||
|
|
||||||
override fun skipCheckingAnnotationsOfActualClassMember(actualMember: DeclarationSymbolMarker): Boolean = error("Should not be called")
|
override fun skipCheckingAnnotationsOfActualClassMember(actualMember: DeclarationSymbolMarker): Boolean = error("Should not be called")
|
||||||
|
|
||||||
override fun findPotentialExpectClassMembersForActual(
|
override fun findPotentialExpectClassMembersForActual(
|
||||||
|
|||||||
+6
-2
@@ -87,7 +87,9 @@ object AbstractExpectActualAnnotationMatchChecker {
|
|||||||
commonForClassAndCallableChecks(expectSymbol, actualSymbol)?.let { return it }
|
commonForClassAndCallableChecks(expectSymbol, actualSymbol)?.let { return it }
|
||||||
areAnnotationsOnValueParametersCompatible(expectSymbol, actualSymbol)?.let { return it }
|
areAnnotationsOnValueParametersCompatible(expectSymbol, actualSymbol)?.let { return it }
|
||||||
|
|
||||||
if (expectSymbol is PropertySymbolMarker && actualSymbol is PropertySymbolMarker) {
|
if (checkPropertyAccessorsForAnnotationsCompatibility
|
||||||
|
&& expectSymbol is PropertySymbolMarker && actualSymbol is PropertySymbolMarker
|
||||||
|
) {
|
||||||
arePropertyGetterAndSetterAnnotationsCompatible(expectSymbol, actualSymbol)?.let { return it }
|
arePropertyGetterAndSetterAnnotationsCompatible(expectSymbol, actualSymbol)?.let { return it }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +138,9 @@ object AbstractExpectActualAnnotationMatchChecker {
|
|||||||
if (checkClassScopesForAnnotationCompatibility) {
|
if (checkClassScopesForAnnotationCompatibility) {
|
||||||
checkAnnotationsInClassMemberScope(expectSymbol, actualSymbol)?.let { return it }
|
checkAnnotationsInClassMemberScope(expectSymbol, actualSymbol)?.let { return it }
|
||||||
}
|
}
|
||||||
if (expectSymbol.classKind == ClassKind.ENUM_CLASS && actualSymbol.classKind == ClassKind.ENUM_CLASS) {
|
if (checkEnumEntriesForAnnotationsCompatibility && expectSymbol.classKind == ClassKind.ENUM_CLASS &&
|
||||||
|
actualSymbol.classKind == ClassKind.ENUM_CLASS
|
||||||
|
) {
|
||||||
checkAnnotationsOnEnumEntries(expectSymbol, actualSymbol)?.let { return it }
|
checkAnnotationsOnEnumEntries(expectSymbol, actualSymbol)?.let { return it }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
@@ -203,6 +203,18 @@ interface ExpectActualMatchingContext<T : DeclarationSymbolMarker> : TypeSystemC
|
|||||||
|
|
||||||
val checkClassScopesForAnnotationCompatibility: Boolean
|
val checkClassScopesForAnnotationCompatibility: Boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether it is needed to check getters and setters in [AbstractExpectActualAnnotationMatchChecker].
|
||||||
|
*/
|
||||||
|
val checkPropertyAccessorsForAnnotationsCompatibility: Boolean
|
||||||
|
get() = true
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether it is needed to check enum entries in [AbstractExpectActualAnnotationMatchChecker].
|
||||||
|
*/
|
||||||
|
val checkEnumEntriesForAnnotationsCompatibility: Boolean
|
||||||
|
get() = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether it is needed to skip checking annotations on class member in [AbstractExpectActualAnnotationMatchChecker].
|
* Determines whether it is needed to skip checking annotations on class member in [AbstractExpectActualAnnotationMatchChecker].
|
||||||
*
|
*
|
||||||
|
|||||||
-3
@@ -19,9 +19,6 @@ All annotations from expect `inValueParam` must be present with the same argumen
|
|||||||
/jvm.kt:(470,501): warning: Annotation `Ann` is missing on actual declaration.
|
/jvm.kt:(470,501): warning: Annotation `Ann` is missing on actual declaration.
|
||||||
All annotations from expect `inTypeParam` must be present with the same arguments on actual `inTypeParam`, otherwise they might behave incorrectly.
|
All annotations from expect `inTypeParam` must be present with the same arguments on actual `inTypeParam`, otherwise they might behave incorrectly.
|
||||||
|
|
||||||
/jvm.kt:(503,535): warning: Annotation `Ann` is missing on actual declaration.
|
|
||||||
All annotations from expect `onGetter` must be present with the same arguments on actual `onGetter`, otherwise they might behave incorrectly.
|
|
||||||
|
|
||||||
/jvm.kt:(503,535): warning: Annotation `Ann` is missing on actual declaration.
|
/jvm.kt:(503,535): warning: Annotation `Ann` is missing on actual declaration.
|
||||||
All annotations from expect `<get-onGetter>` must be present with the same arguments on actual `<get-onGetter>`, otherwise they might behave incorrectly.
|
All annotations from expect `<get-onGetter>` must be present with the same arguments on actual `<get-onGetter>`, otherwise they might behave incorrectly.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -67,6 +67,6 @@ actual fun withDifferentArg() {}<!>
|
|||||||
|
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual fun <T> inTypeParam() {}<!>
|
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual fun <T> inTypeParam() {}<!>
|
||||||
|
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT, ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual val onGetter: String = ""<!>
|
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual val onGetter: String = ""<!>
|
||||||
|
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual fun onType(param: Any) {}<!>
|
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual fun onType(param: Any) {}<!>
|
||||||
|
|||||||
compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/enumEntries.fir.kt
Vendored
+2
-2
@@ -10,6 +10,6 @@ annotation class Ann
|
|||||||
|
|
||||||
// MODULE: m1-jvm()()(m1-common)
|
// MODULE: m1-jvm()()(m1-common)
|
||||||
// FILE: jvm.kt
|
// FILE: jvm.kt
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual enum class <!ACTUAL_WITHOUT_EXPECT!>E<!> {
|
actual enum class <!ACTUAL_WITHOUT_EXPECT!>E<!> {
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>FOO<!>
|
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>FOO<!>
|
||||||
}<!>
|
}
|
||||||
|
|||||||
+8
-8
@@ -23,20 +23,20 @@ expect var onSetter: String
|
|||||||
|
|
||||||
// MODULE: m1-jvm()()(m1-common)
|
// MODULE: m1-jvm()()(m1-common)
|
||||||
// FILE: jvm.kt
|
// FILE: jvm.kt
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual val onGetter: String
|
actual val onGetter: String
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>get() = ""<!><!>
|
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>get() = ""<!>
|
||||||
|
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT, ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual val onGetterImplicit: String = ""<!>
|
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual val onGetterImplicit: String = ""<!>
|
||||||
|
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual val onGetterWithExplicitTarget: String
|
actual val onGetterWithExplicitTarget: String
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>get() = ""<!><!>
|
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>get() = ""<!>
|
||||||
|
|
||||||
actual val explicitTargetMatchesWithoutTarget: String
|
actual val explicitTargetMatchesWithoutTarget: String
|
||||||
@Ann get() = ""
|
@Ann get() = ""
|
||||||
|
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT, ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>@Ann
|
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>@Ann
|
||||||
actual val setOnPropertyWithoutTargetNotMatch: String = ""<!>
|
actual val setOnPropertyWithoutTargetNotMatch: String = ""<!>
|
||||||
|
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>actual var onSetter: String
|
actual var onSetter: String
|
||||||
get() = ""
|
get() = ""
|
||||||
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>set(_) {}<!><!>
|
<!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>set(_) {}<!>
|
||||||
|
|||||||
Reference in New Issue
Block a user