[FE, IR] Don't check SOURCE annotations if actual declaration has no source
^KT-58551
This commit is contained in:
committed by
Space Team
parent
59f1a0dd8e
commit
234f453173
+4
@@ -28,12 +28,16 @@ object AbstractExpectActualAnnotationMatchChecker {
|
||||
return areAnnotationsCompatible(expectSymbol, expanded)
|
||||
}
|
||||
|
||||
val skipSourceAnnotations = !actualSymbol.hasSourceAnnotationsErased
|
||||
val actualAnnotationsByName = actualSymbol.annotations.groupBy { it.classId }
|
||||
|
||||
for (expectAnnotation in expectSymbol.annotations) {
|
||||
if (expectAnnotation.classId == StandardClassIds.Annotations.OptionalExpectation) {
|
||||
continue
|
||||
}
|
||||
if (expectAnnotation.isRetentionSource && skipSourceAnnotations) {
|
||||
continue
|
||||
}
|
||||
val actualAnnotationsWithSameClassId = actualAnnotationsByName[expectAnnotation.classId] ?: emptyList()
|
||||
if (actualAnnotationsWithSameClassId.none { areAnnotationArgumentsEqual(expectAnnotation, it) }) {
|
||||
return Incompatibility(expectSymbol, actualSymbol)
|
||||
|
||||
+3
-1
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.mpp.*
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualCompatibility
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
@@ -163,7 +162,10 @@ interface ExpectActualMatchingContext<T : DeclarationSymbolMarker> : TypeSystemC
|
||||
|
||||
fun areAnnotationArgumentsEqual(annotation1: AnnotationCallInfo, annotation2: AnnotationCallInfo): Boolean
|
||||
|
||||
val DeclarationSymbolMarker.hasSourceAnnotationsErased: Boolean
|
||||
|
||||
interface AnnotationCallInfo {
|
||||
val classId: ClassId?
|
||||
val isRetentionSource: Boolean
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user