[FE] Allow @OptionalExpectation to be present only on expect

^KT-58551
This commit is contained in:
Roman Efremov
2023-06-22 16:37:20 +02:00
committed by Space Team
parent 1a4ab9bb4b
commit b6cae1adcc
5 changed files with 34 additions and 0 deletions
@@ -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)