diff --git a/compiler/ir/ir.actualization/src/main/kotlin/org/jetbrains/kotlin/backend/common/actualizer/IrExpectActualMatchingContext.kt b/compiler/ir/ir.actualization/src/main/kotlin/org/jetbrains/kotlin/backend/common/actualizer/IrExpectActualMatchingContext.kt index 4ca417f5fb4..ed6326d138e 100644 --- a/compiler/ir/ir.actualization/src/main/kotlin/org/jetbrains/kotlin/backend/common/actualizer/IrExpectActualMatchingContext.kt +++ b/compiler/ir/ir.actualization/src/main/kotlin/org/jetbrains/kotlin/backend/common/actualizer/IrExpectActualMatchingContext.kt @@ -559,6 +559,19 @@ internal abstract class IrExpectActualMatchingContext( // IR checker traverses member scope itself and collects mappings 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 findPotentialExpectClassMembersForActual( diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualAnnotationMatchChecker.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualAnnotationMatchChecker.kt index 53e3da7c786..bff841a3554 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualAnnotationMatchChecker.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualAnnotationMatchChecker.kt @@ -87,7 +87,9 @@ object AbstractExpectActualAnnotationMatchChecker { commonForClassAndCallableChecks(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 } } @@ -136,7 +138,9 @@ object AbstractExpectActualAnnotationMatchChecker { if (checkClassScopesForAnnotationCompatibility) { 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 } } diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualMatchingContext.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualMatchingContext.kt index 8cd445cdaa5..44dc5e06754 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualMatchingContext.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualMatchingContext.kt @@ -203,6 +203,18 @@ interface ExpectActualMatchingContext : TypeSystemC 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]. * diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.ir.diag.txt b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.ir.diag.txt index 2b6212af002..e5b043f4e02 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.ir.diag.txt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.ir.diag.txt @@ -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. 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. All annotations from expect `` must be present with the same arguments on actual ``, otherwise they might behave incorrectly. diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.kt index d76007eb6b5..7c79b839da7 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/checkDiagnosticFullText.fir.kt @@ -67,6 +67,6 @@ actual fun withDifferentArg() {} actual fun inTypeParam() {} -actual val onGetter: String = "" +actual val onGetter: String = "" actual fun onType(param: Any) {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/enumEntries.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/enumEntries.fir.kt index 0d109b398aa..a582f4d6288 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/enumEntries.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/enumEntries.fir.kt @@ -10,6 +10,6 @@ annotation class Ann // MODULE: m1-jvm()()(m1-common) // FILE: jvm.kt -actual enum class E { +actual enum class E { FOO -} +} diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/gettersAndSetters.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/gettersAndSetters.fir.kt index 9bb94f1b0ec..217b41ff3e6 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/gettersAndSetters.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualAnnotationsNotMatchExpect/gettersAndSetters.fir.kt @@ -23,20 +23,20 @@ expect var onSetter: String // MODULE: m1-jvm()()(m1-common) // FILE: jvm.kt -actual val onGetter: String - get() = "" +actual val onGetter: String + get() = "" -actual val onGetterImplicit: String = "" +actual val onGetterImplicit: String = "" -actual val onGetterWithExplicitTarget: String - get() = "" +actual val onGetterWithExplicitTarget: String + get() = "" actual val explicitTargetMatchesWithoutTarget: String @Ann get() = "" -@Ann +@Ann actual val setOnPropertyWithoutTargetNotMatch: String = "" -actual var onSetter: String +actual var onSetter: String get() = "" - set(_) {} + set(_) {}