[K2] Disappeared OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN (1)

Added error propagation for the type-aliased type.

^KT-59998
This commit is contained in:
Anastasia.Nekrasova
2023-10-31 11:29:21 +02:00
committed by Space Team
parent 5c7b586dbb
commit 445ed7abc9
8 changed files with 53 additions and 18 deletions
@@ -32,7 +32,7 @@ fun useDataClass(d: DataClass) {
typealias My = <!OPT_IN_USAGE_ERROR!>Some<!>
fun my(my: My) {}
fun my(my: <!OPT_IN_USAGE_ERROR!>My<!>) {}
fun your(my: <!OPT_IN_USAGE_ERROR!>Some<!>) {}
@@ -70,6 +70,10 @@ typealias AList = ArrayList<I>
@Marker
typealias YourList = ArrayList<String>
fun my2(my: MyList) {}
fun my3(my: <!OPT_IN_USAGE_ERROR!>YourList<!>) {}
fun main() {
val x = <!OPT_IN_USAGE_ERROR!>listOf<!>(A(), B())
val y = MyList()
@@ -70,6 +70,10 @@ typealias AList = ArrayList<I>
@Marker
typealias YourList = ArrayList<String>
fun my2(my: <!OPT_IN_USAGE_ERROR!>MyList<!>) {}
fun my3(my: <!OPT_IN_USAGE_ERROR!>YourList<!>) {}
fun main() {
val x = <!OPT_IN_USAGE_ERROR!>listOf<!>(A(), B())
val y = <!OPT_IN_USAGE_ERROR!>MyList<!>()
@@ -3,6 +3,8 @@ package
public val x: kotlin.String
public fun main(): kotlin.Unit
public fun my(/*0*/ my: My /* = Some */): kotlin.Unit
public fun my2(/*0*/ my: MyList /* = java.util.ArrayList<I> */): kotlin.Unit
public fun my3(/*0*/ my: YourList /* = java.util.ArrayList<kotlin.String> */): kotlin.Unit
public fun operatorContainerUsage(/*0*/ s: kotlin.String, /*1*/ a: AnotherContainer): kotlin.Unit
public fun use(/*0*/ arg: NotExperimentalExtension): kotlin.Unit
public fun useDataClass(/*0*/ d: DataClass): kotlin.Unit
@@ -32,7 +32,7 @@ fun useDataClass(d: DataClass) {
typealias My = <!OPT_IN_USAGE_ERROR!>Some<!>
fun my(my: My) {}
fun my(my: <!OPT_IN_USAGE_ERROR!>My<!>) {}
fun your(my: <!OPT_IN_USAGE_ERROR!>Some<!>) {}
@@ -78,6 +78,10 @@ fun main() {
<!OPT_IN_USAGE_ERROR!>YourList<!>().add("")
}
fun my2(my: MyList) {}
fun my3(my: <!OPT_IN_USAGE_ERROR!>YourList<!>) {}
@Marker
class C {
operator fun getValue(x: Any?, y: Any?): String = ""
@@ -78,6 +78,10 @@ fun main() {
<!OPT_IN_USAGE_FUTURE_ERROR!>YourList<!>().add("")
}
fun my2(my: <!OPT_IN_USAGE_FUTURE_ERROR!>MyList<!>) {}
fun my3(my: <!OPT_IN_USAGE_ERROR!>YourList<!>) {}
@Marker
class C {
operator fun getValue(x: Any?, y: Any?): String = ""
@@ -3,6 +3,8 @@ package
public val x: kotlin.String
public fun main(): kotlin.Unit
public fun my(/*0*/ my: My /* = Some */): kotlin.Unit
public fun my2(/*0*/ my: MyList /* = java.util.ArrayList<I> */): kotlin.Unit
public fun my3(/*0*/ my: YourList /* = java.util.ArrayList<kotlin.String> */): kotlin.Unit
public fun operatorContainerUsage(/*0*/ s: kotlin.String, /*1*/ a: AnotherContainer): kotlin.Unit
public fun use(/*0*/ arg: NotExperimentalExtension): kotlin.Unit
public fun useDataClass(/*0*/ d: DataClass): kotlin.Unit
@@ -26,8 +26,8 @@ fun f2(u: <!OPT_IN_CAN_ONLY_BE_USED_AS_ANNOTATION!>OptIn?<!>) {}
typealias Experimental0 = <!OPT_IN_CAN_ONLY_BE_USED_AS_ANNOTATION!>RequiresOptIn<!>
typealias OptIn0 = <!OPT_IN_CAN_ONLY_BE_USED_AS_ANNOTATION!>OptIn<!>
fun f3(e: Experimental0 /* TODO */) {}
fun f4(u: OptIn0 /* TODO */) {}
fun f3(e: <!OPT_IN_CAN_ONLY_BE_USED_AS_ANNOTATION!>Experimental0<!> /* TODO */) {}
fun f4(u: <!OPT_IN_CAN_ONLY_BE_USED_AS_ANNOTATION!>OptIn0<!> /* TODO */) {}
// Usages as ::class literals should be errors
@@ -60,7 +60,7 @@ fun f8(): <!OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN!>
typealias Marker0 = <!OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN!>Marker<!>
fun f9(m: Marker0) {}
fun f9(m: <!OPT_IN_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_OPT_IN!>Marker0<!>) {}
// Usages of markers as qualifiers are errors as well (we can lift this restriction for select cases)