[FE] Allow @OptionalExpectation to be present only on expect
^KT-58551
This commit is contained in:
committed by
Space Team
parent
1a4ab9bb4b
commit
b6cae1adcc
+6
@@ -274,6 +274,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/kotlinAnaloguesForJavaAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("optionalExpectation.kt")
|
||||
public void testOptionalExpectation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/optionalExpectation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typealias.kt")
|
||||
public void testTypealias() throws Exception {
|
||||
|
||||
+6
@@ -274,6 +274,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/kotlinAnaloguesForJavaAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("optionalExpectation.kt")
|
||||
public void testOptionalExpectation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/optionalExpectation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typealias.kt")
|
||||
public void testTypealias() throws Exception {
|
||||
|
||||
+4
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.resolve.calls.mpp
|
||||
|
||||
import org.jetbrains.kotlin.mpp.DeclarationSymbolMarker
|
||||
import org.jetbrains.kotlin.mpp.TypeAliasSymbolMarker
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
|
||||
object AbstractExpectActualAnnotationMatchChecker {
|
||||
class Incompatibility(val expectSymbol: DeclarationSymbolMarker, val actualSymbol: DeclarationSymbolMarker)
|
||||
@@ -30,6 +31,9 @@ object AbstractExpectActualAnnotationMatchChecker {
|
||||
val actualAnnotationsByName = actualSymbol.annotations.groupBy { it.classId }
|
||||
|
||||
for (expectAnnotation in expectSymbol.annotations) {
|
||||
if (expectAnnotation.classId == StandardClassIds.Annotations.OptionalExpectation) {
|
||||
continue
|
||||
}
|
||||
val actualAnnotationsWithSameClassId = actualAnnotationsByName[expectAnnotation.classId] ?: emptyList()
|
||||
if (actualAnnotationsWithSameClassId.none { areAnnotationArgumentsEqual(expectAnnotation, it) }) {
|
||||
return Incompatibility(expectSymbol, actualSymbol)
|
||||
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
@OptionalExpectation
|
||||
expect annotation class MyAnnotation
|
||||
|
||||
// MODULE: m1-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
@OptIn(ExperimentalMultiplatform::class)
|
||||
actual annotation class MyAnnotation
|
||||
Generated
+6
@@ -22819,6 +22819,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/kotlinAnaloguesForJavaAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("optionalExpectation.kt")
|
||||
public void testOptionalExpectation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/optionalExpectation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typealias.kt")
|
||||
public void testTypealias() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user