K2: Support for inter-module interaction for @SubclassOptInRequired

The inter-module interaction was partially supported, but the
DiagnosticCompilerTestFE10TestdataTestGenerated and
LFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated were
failing. This is because the arguments of annotations were not fully
resolved in loadExperimentalitiesFromAnnotationTo function.

^KT-60262 Fixed
This commit is contained in:
Anastasia.Nekrasova
2024-01-15 21:23:47 +02:00
committed by Space Team
parent d66b38b7a9
commit 7429dd4b94
8 changed files with 61 additions and 0 deletions
@@ -42301,6 +42301,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/JavaKotlinInterop.kt");
}
@Test
@TestMetadata("Module.kt")
public void testModule() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/Module.kt");
}
@Test
@TestMetadata("NestedClasses.kt")
public void testNestedClasses() throws Exception {
@@ -42301,6 +42301,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/JavaKotlinInterop.kt");
}
@Test
@TestMetadata("Module.kt")
public void testModule() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/Module.kt");
}
@Test
@TestMetadata("NestedClasses.kt")
public void testNestedClasses() throws Exception {
@@ -40015,6 +40015,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/JavaKotlinInterop.kt");
}
@Test
@TestMetadata("Module.kt")
public void testModule() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/Module.kt");
}
@Test
@TestMetadata("NestedClasses.kt")
public void testNestedClasses() throws Exception {
@@ -40135,6 +40135,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/JavaKotlinInterop.kt");
}
@Test
@TestMetadata("Module.kt")
public void testModule() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/Module.kt");
}
@Test
@TestMetadata("NestedClasses.kt")
public void testNestedClasses() throws Exception {
@@ -175,6 +175,7 @@ object FirOptInUsageBaseChecker {
is FirAnonymousInitializer, is FirDanglingModifierList, is FirFile, is FirTypeParameter, is FirScript, is FirCodeFragment -> {}
}
lazyResolveToPhase(FirResolvePhase.ANNOTATION_ARGUMENTS)
fir.loadExperimentalitiesFromAnnotationTo(session, result, fromSupertype)
if (fir.getAnnotationByClassId(OptInNames.WAS_EXPERIMENTAL_CLASS_ID, session) != null) {
@@ -0,0 +1,15 @@
// MODULE: a
@file:OptIn(ExperimentalSubclassOptIn::class)
package a
@RequiresOptIn
annotation class Boom
@SubclassOptInRequired(Boom::class)
open class B {}
// MODULE: b(a)
package b
import a.B
class C : <!OPT_IN_USAGE_ERROR!>B<!>()
@@ -0,0 +1,15 @@
// MODULE: a
@file:OptIn(ExperimentalSubclassOptIn::class)
package a
@RequiresOptIn
annotation class Boom
@SubclassOptInRequired(Boom::class)
open class B {}
// MODULE: b(a)
package b
import a.B
class C : B()
@@ -42301,6 +42301,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/JavaKotlinInterop.kt");
}
@Test
@TestMetadata("Module.kt")
public void testModule() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/Module.kt");
}
@Test
@TestMetadata("NestedClasses.kt")
public void testNestedClasses() throws Exception {