[FE] Skip more special annotations in KMP annotation matching

Many errors are reported in stdlib with these annotations
(SinceKotlin, Deprecated, so on).
But having them only on expect is a valid case. E.g. SinceKotlin added
if some old platform-specific API becomes commonized.

^KT-58551
This commit is contained in:
Roman Efremov
2023-06-27 12:39:44 +02:00
committed by Space Team
parent 1dcdcee452
commit ad84c83ee9
11 changed files with 69 additions and 26 deletions
@@ -287,9 +287,9 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/optionalExpectation.kt");
@TestMetadata("skippedAnnotations.kt")
public void testSkippedAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/skippedAnnotations.kt");
}
@Test
@@ -287,9 +287,9 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
}
@Test
@TestMetadata("optionalExpectation.kt")
public void testOptionalExpectation() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/optionalExpectation.kt");
@TestMetadata("skippedAnnotations.kt")
public void testSkippedAnnotations() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/skippedAnnotations.kt");
}
@Test
@@ -28,6 +28,7 @@ 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.ExpectActualMatchingContext.AnnotationCallInfo
import org.jetbrains.kotlin.resolve.checkers.OptInNames
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.TypeCheckerState
import org.jetbrains.kotlin.types.Variance
@@ -357,6 +358,9 @@ class FirExpectActualMatchingContextImpl private constructor(
override val isRetentionSource: Boolean
get() = getAnnotationClass()?.getRetention(actualSession) == AnnotationRetention.SOURCE
override val isOptIn: Boolean
get() = getAnnotationClass()?.hasAnnotation(OptInNames.REQUIRES_OPT_IN_CLASS_ID, actualSession) ?: false
private fun getAnnotationClass(): FirRegularClassSymbol? =
annotation.annotationTypeRef.coneType.toRegularClassSymbol(actualSession)
}