diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java index 8b4565290f7..c37a59c965d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java @@ -938,6 +938,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typealiasToKtLibrary.kt"); } + @Test + @TestMetadata("unresolvedReference.kt") + public void testUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/unresolvedReference.kt"); + } + @Test @TestMetadata("valueParameters.kt") public void testValueParameters() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java index b4cb32c6cb7..9f45429befd 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java @@ -938,6 +938,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typealiasToKtLibrary.kt"); } + @Test + @TestMetadata("unresolvedReference.kt") + public void testUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/unresolvedReference.kt"); + } + @Test @TestMetadata("valueParameters.kt") public void testValueParameters() throws Exception { diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt index bd48e01284e..8cc73b033db 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.* +import org.jetbrains.kotlin.types.error.ErrorClassDescriptor import org.jetbrains.kotlin.types.model.KotlinTypeMarker import org.jetbrains.kotlin.types.model.TypeConstructorMarker import org.jetbrains.kotlin.types.model.TypeSubstitutorMarker @@ -389,6 +390,9 @@ class ClassicExpectActualMatchingContext( private fun getAnnotationClassDescriptor(): ClassDescriptor? { val classDescriptor = annotationDescriptor.annotationClass ?: return null + if (classDescriptor is ErrorClassDescriptor) { + return null + } if (!classDescriptor.isExpect) { return classDescriptor } diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/unresolvedReference.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/unresolvedReference.fir.kt new file mode 100644 index 00000000000..1b09ad7bb56 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/unresolvedReference.fir.kt @@ -0,0 +1,9 @@ +// DIAGNOSTICS: -UNRESOLVED_REFERENCE +// MODULE: m1-common +// FILE: common.kt +@NonExistingClass +expect fun foo() + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual fun foo() {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/unresolvedReference.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/unresolvedReference.kt new file mode 100644 index 00000000000..3e56ba789c7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/unresolvedReference.kt @@ -0,0 +1,9 @@ +// DIAGNOSTICS: -UNRESOLVED_REFERENCE +// MODULE: m1-common +// FILE: common.kt +@NonExistingClass +expect fun foo() + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual fun foo() {} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index c9777c7116c..7e4fa6f4f5a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -23939,6 +23939,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/typealiasToKtLibrary.kt"); } + @Test + @TestMetadata("unresolvedReference.kt") + public void testUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/unresolvedReference.kt"); + } + @Test @TestMetadata("valueParameters.kt") public void testValueParameters() throws Exception {