[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
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.calls.mpp.ExpectActualMatchingContext
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
@@ -467,10 +468,14 @@ internal abstract class IrExpectActualMatchingContext(
get() = irElement.type.getClass()?.classId
override val isRetentionSource: Boolean
get() {
val annotationClass = irElement.symbol.owner.parent as? IrClass ?: return false
return annotationClass.getAnnotationRetention() == KotlinRetention.SOURCE
}
get() = getAnnotationClass()?.getAnnotationRetention() == KotlinRetention.SOURCE
override val isOptIn: Boolean
get() = getAnnotationClass()?.hasAnnotation(OptInNames.REQUIRES_OPT_IN_FQ_NAME) ?: false
private fun getAnnotationClass(): IrClass? {
return irElement.symbol.owner.parent as? IrClass
}
}
override val DeclarationSymbolMarker.hasSourceAnnotationsErased: Boolean