[FE] Relax rules of matching @Target annotation on expect and actual

Allow `expect` targets to be subset of `actual`.

^KT-58551
This commit is contained in:
Roman Efremov
2023-07-17 14:55:03 +02:00
committed by Space Team
parent ad84c83ee9
commit 6611a55a60
15 changed files with 202 additions and 21 deletions
@@ -226,6 +226,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgumentsDefaults.kt");
}
@Test
@TestMetadata("annotationTarget.kt")
public void testAnnotationTarget() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationTarget.kt");
}
@Test
@TestMetadata("annotationTypeParameters.kt")
public void testAnnotationTypeParameters() throws Exception {
@@ -226,6 +226,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationArgumentsDefaults.kt");
}
@Test
@TestMetadata("annotationTarget.kt")
public void testAnnotationTarget() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/annotationTarget.kt");
}
@Test
@TestMetadata("annotationTypeParameters.kt")
public void testAnnotationTypeParameters() throws Exception {
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.mpp.*
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.calls.mpp.ExpectActualCollectionArgumentsCompatibilityCheckStrategy
import org.jetbrains.kotlin.resolve.calls.mpp.ExpectActualMatchingContext.AnnotationCallInfo
import org.jetbrains.kotlin.resolve.checkers.OptInNames
import org.jetbrains.kotlin.types.AbstractTypeChecker
@@ -317,7 +318,11 @@ class FirExpectActualMatchingContextImpl private constructor(
override val DeclarationSymbolMarker.annotations: List<AnnotationCallInfo>
get() = asSymbol().resolvedAnnotationsWithArguments.map(::AnnotationCallInfoImpl)
override fun areAnnotationArgumentsEqual(annotation1: AnnotationCallInfo, annotation2: AnnotationCallInfo): Boolean {
override fun areAnnotationArgumentsEqual(
annotation1: AnnotationCallInfo,
annotation2: AnnotationCallInfo,
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
): Boolean {
fun AnnotationCallInfo.getFirAnnotation(): FirAnnotation {
return (this as AnnotationCallInfoImpl).annotation
}