[K2] Correctly handle case when expect annotation is unresolved

Don't report if annotation has error type.

Review: KT-MR-12250

^KT-62026 Fixed
This commit is contained in:
Roman Efremov
2023-09-18 17:16:16 +02:00
committed by Space Team
parent 04c1bf749c
commit c88b4105c5
3 changed files with 11 additions and 12 deletions
@@ -27,7 +27,6 @@ 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.mpp.SourceElementMarker
import org.jetbrains.kotlin.resolve.checkers.OptInNames
import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualCompatibility
import org.jetbrains.kotlin.types.AbstractTypeChecker
@@ -388,7 +387,7 @@ class FirExpectActualMatchingContextImpl private constructor(
override val annotationSymbol: FirAnnotation = annotation
override val classId: ClassId?
get() = annotation.toAnnotationClassId(actualSession)
get() = getAnnotationConeType()?.lookupTag?.classId
override val isRetentionSource: Boolean
get() = getAnnotationClass()?.getRetention(actualSession) == AnnotationRetention.SOURCE
@@ -397,7 +396,15 @@ class FirExpectActualMatchingContextImpl private constructor(
get() = getAnnotationClass()?.hasAnnotation(OptInNames.REQUIRES_OPT_IN_CLASS_ID, actualSession) ?: false
private fun getAnnotationClass(): FirRegularClassSymbol? =
annotation.annotationTypeRef.coneType.toRegularClassSymbol(actualSession)
getAnnotationConeType()?.toRegularClassSymbol(actualSession)
private fun getAnnotationConeType(): ConeClassLikeType? {
val coneType = annotation.toAnnotationClassLikeType(actualSession)
if (coneType is ConeErrorType) {
return null
}
return coneType
}
}
override val DeclarationSymbolMarker.hasSourceAnnotationsErased: Boolean
@@ -1,9 +0,0 @@
// DIAGNOSTICS: -UNRESOLVED_REFERENCE
// MODULE: m1-common
// FILE: common.kt
@NonExistingClass
expect fun foo()
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual fun <!ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT!>foo<!>() {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// DIAGNOSTICS: -UNRESOLVED_REFERENCE
// MODULE: m1-common
// FILE: common.kt