K2 opt-in: restore marker annotation check for constructors
This commit is contained in:
committed by
Space Team
parent
a77750a257
commit
b92ce68f32
+6
@@ -37874,6 +37874,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorCheck.kt")
|
||||
public void testConstructorCheck() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constructorCheck.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deeplyNestedClass.kt")
|
||||
public void testDeeplyNestedClass() throws Exception {
|
||||
|
||||
+6
@@ -37874,6 +37874,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorCheck.kt")
|
||||
public void testConstructorCheck() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constructorCheck.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deeplyNestedClass.kt")
|
||||
public void testDeeplyNestedClass() throws Exception {
|
||||
|
||||
+6
@@ -37874,6 +37874,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorCheck.kt")
|
||||
public void testConstructorCheck() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constructorCheck.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deeplyNestedClass.kt")
|
||||
public void testDeeplyNestedClass() throws Exception {
|
||||
|
||||
+3
-5
@@ -154,7 +154,7 @@ object FirOptInUsageBaseChecker {
|
||||
context, result, visited, fromSetter = false, dispatchReceiverType = null, fromSupertype = false
|
||||
)
|
||||
} else {
|
||||
fir.loadOverridableSpecificExperimentalities(session, context, visited, result)
|
||||
fir.loadOverridableSpecificExperimentalities(context, visited, result)
|
||||
}
|
||||
dispatchReceiverType?.addExperimentalities(context, result, visited)
|
||||
if (fromSetter && this is FirPropertySymbol) {
|
||||
@@ -176,9 +176,10 @@ object FirOptInUsageBaseChecker {
|
||||
is FirAnonymousObject -> {
|
||||
}
|
||||
}
|
||||
fir.loadExperimentalitiesFromAnnotationTo(session, result, fromSupertype)
|
||||
}
|
||||
|
||||
fir.loadExperimentalitiesFromAnnotationTo(session, result, fromSupertype)
|
||||
|
||||
if (fir.getAnnotationByClassId(OptInNames.WAS_EXPERIMENTAL_CLASS_ID) != null) {
|
||||
val accessibility = fir.checkSinceKotlinVersionAccessibility(context)
|
||||
if (accessibility is FirSinceKotlinAccessibility.NotAccessibleButWasExperimental) {
|
||||
@@ -194,7 +195,6 @@ object FirOptInUsageBaseChecker {
|
||||
}
|
||||
|
||||
private fun FirCallableDeclaration.loadOverridableSpecificExperimentalities(
|
||||
session: FirSession,
|
||||
context: CheckerContext,
|
||||
visited: MutableSet<FirDeclaration>,
|
||||
result: SmartSet<Experimentality>
|
||||
@@ -207,8 +207,6 @@ object FirOptInUsageBaseChecker {
|
||||
it.returnTypeRef.coneType.addExperimentalities(context, result, visited)
|
||||
}
|
||||
}
|
||||
|
||||
loadExperimentalitiesFromAnnotationTo(session, result, fromSupertype = false)
|
||||
}
|
||||
|
||||
private fun ConeKotlinType?.addExperimentalities(
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FIR_IDENTICAL
|
||||
@RequiresOptIn
|
||||
annotation class Marker
|
||||
|
||||
@Marker
|
||||
class Some(val x: Int)
|
||||
|
||||
class Other(val x: Int) {
|
||||
@OptIn(Marker::class)
|
||||
constructor(some: Some): this(some.x)
|
||||
|
||||
@Marker
|
||||
constructor(): this(42)
|
||||
|
||||
@OptIn(Marker::class)
|
||||
constructor(y: Long, some: Some? = null): this(some?.x ?: y.toInt())
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val o1 = <!OPT_IN_USAGE_ERROR!>Other<!>()
|
||||
val o2 = Other(<!OPT_IN_USAGE_ERROR!>Some<!>(0))
|
||||
val o3 = Other(444L)
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
@kotlin.RequiresOptIn public final annotation class Marker : kotlin.Annotation {
|
||||
public constructor Marker()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Other {
|
||||
@Marker public constructor Other()
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public constructor Other(/*0*/ some: Some)
|
||||
public constructor Other(/*0*/ x: kotlin.Int)
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public constructor Other(/*0*/ y: kotlin.Long, /*1*/ some: Some? = ...)
|
||||
public final val x: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@Marker public final class Some {
|
||||
public constructor Some(/*0*/ x: kotlin.Int)
|
||||
public final val x: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Generated
+6
@@ -37964,6 +37964,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorCheck.kt")
|
||||
public void testConstructorCheck() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constructorCheck.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deeplyNestedClass.kt")
|
||||
public void testDeeplyNestedClass() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user