diff --git a/compiler/testData/experimental/jsExperimentalModule/output.txt b/compiler/testData/experimental/jsExperimentalModule/output.txt index 0ceee7a6fce..09053fceb69 100644 --- a/compiler/testData/experimental/jsExperimentalModule/output.txt +++ b/compiler/testData/experimental/jsExperimentalModule/output.txt @@ -1,7 +1,7 @@ -compiler/testData/experimental/jsExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@UseExperimental(lib.ExperimentalAPI::class)' +compiler/testData/experimental/jsExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@OptIn(lib.ExperimentalAPI::class)' fun fail(foo: Foo) { ^ -compiler/testData/experimental/jsExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@UseExperimental(lib.ExperimentalAPI::class)' +compiler/testData/experimental/jsExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@OptIn(lib.ExperimentalAPI::class)' bar() ^ COMPILATION_ERROR diff --git a/compiler/testData/experimental/jvmExperimentalModule/output.txt b/compiler/testData/experimental/jvmExperimentalModule/output.txt index 80c78afe57d..c835c1f29c7 100644 --- a/compiler/testData/experimental/jvmExperimentalModule/output.txt +++ b/compiler/testData/experimental/jvmExperimentalModule/output.txt @@ -1,7 +1,7 @@ -compiler/testData/experimental/jvmExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@UseExperimental(lib.ExperimentalAPI::class)' +compiler/testData/experimental/jvmExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@OptIn(lib.ExperimentalAPI::class)' fun fail(foo: Foo) { ^ -compiler/testData/experimental/jvmExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@UseExperimental(lib.ExperimentalAPI::class)' +compiler/testData/experimental/jvmExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@OptIn(lib.ExperimentalAPI::class)' bar() ^ COMPILATION_ERROR diff --git a/idea/testData/quickfix/experimental/basicFunctionNotApplicable.kt b/idea/testData/quickfix/experimental/basicFunctionNotApplicable.kt index 488f55d3b29..d075fd675dd 100644 --- a/idea/testData/quickfix/experimental/basicFunctionNotApplicable.kt +++ b/idea/testData/quickfix/experimental/basicFunctionNotApplicable.kt @@ -2,10 +2,10 @@ // COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental // WITH_RUNTIME // ACTION: Add '@MyExperimentalAPI' annotation to containing class 'Bar' -// ACTION: Add '@UseExperimental(MyExperimentalAPI::class)' annotation to 'bar' +// ACTION: Add '@OptIn(MyExperimentalAPI::class)' annotation to 'bar' // ACTION: Add '-Xuse-experimental=MyExperimentalAPI' to module light_idea_test_case compiler arguments -// ERROR: This declaration is experimental and its usage must be marked with '@MyExperimentalAPI' or '@UseExperimental(MyExperimentalAPI::class)' -// ERROR: This declaration is experimental and its usage must be marked with '@MyExperimentalAPI' or '@UseExperimental(MyExperimentalAPI::class)' +// ERROR: This declaration is experimental and its usage must be marked with '@MyExperimentalAPI' or '@OptIn(MyExperimentalAPI::class)' +// ERROR: This declaration is experimental and its usage must be marked with '@MyExperimentalAPI' or '@OptIn(MyExperimentalAPI::class)' @Experimental @Target(AnnotationTarget.CLASS) @@ -20,4 +20,4 @@ class Bar { fun bar() { Some().foo() } -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/experimental/basicUseExperimental.kt b/idea/testData/quickfix/experimental/basicUseExperimental.kt index 23cd4c4838d..f03a2b7316d 100644 --- a/idea/testData/quickfix/experimental/basicUseExperimental.kt +++ b/idea/testData/quickfix/experimental/basicUseExperimental.kt @@ -1,4 +1,4 @@ -// "Add '@UseExperimental(MyExperimentalAPI::class)' annotation to 'bar'" "true" +// "Add '@OptIn(MyExperimentalAPI::class)' annotation to 'bar'" "true" // COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental // WITH_RUNTIME @@ -17,4 +17,4 @@ class Bar { fun bar() { Some().foo() } -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/experimental/basicUseExperimental.kt.after b/idea/testData/quickfix/experimental/basicUseExperimental.kt.after index 4ddddedf975..900a98825cd 100644 --- a/idea/testData/quickfix/experimental/basicUseExperimental.kt.after +++ b/idea/testData/quickfix/experimental/basicUseExperimental.kt.after @@ -1,4 +1,4 @@ -// "Add '@UseExperimental(MyExperimentalAPI::class)' annotation to 'bar'" "true" +// "Add '@OptIn(MyExperimentalAPI::class)' annotation to 'bar'" "true" // COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental // WITH_RUNTIME @@ -14,8 +14,8 @@ class Some { } class Bar { - @UseExperimental(MyExperimentalAPI::class) + @OptIn(MyExperimentalAPI::class) fun bar() { Some().foo() } -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/experimental/classUseExperimental.kt b/idea/testData/quickfix/experimental/classUseExperimental.kt index 8be0c6e3b0c..1c45438fbe2 100644 --- a/idea/testData/quickfix/experimental/classUseExperimental.kt +++ b/idea/testData/quickfix/experimental/classUseExperimental.kt @@ -1,4 +1,4 @@ -// "Add '@UseExperimental(MyExperimentalAPI::class)' annotation to containing class 'Bar'" "true" +// "Add '@OptIn(MyExperimentalAPI::class)' annotation to containing class 'Bar'" "true" // COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental // WITH_RUNTIME @@ -15,4 +15,4 @@ class Bar { fun bar() { foo() } -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/experimental/classUseExperimental.kt.after b/idea/testData/quickfix/experimental/classUseExperimental.kt.after index 217c445c4cb..cae5389ad7d 100644 --- a/idea/testData/quickfix/experimental/classUseExperimental.kt.after +++ b/idea/testData/quickfix/experimental/classUseExperimental.kt.after @@ -1,4 +1,4 @@ -// "Add '@UseExperimental(MyExperimentalAPI::class)' annotation to containing class 'Bar'" "true" +// "Add '@OptIn(MyExperimentalAPI::class)' annotation to containing class 'Bar'" "true" // COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental // WITH_RUNTIME @@ -11,9 +11,9 @@ annotation class MyExperimentalAPI @MyExperimentalAPI fun foo() {} -@UseExperimental(MyExperimentalAPI::class) +@OptIn(MyExperimentalAPI::class) class Bar { fun bar() { foo() } -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/experimental/nestedClasses.kt b/idea/testData/quickfix/experimental/nestedClasses.kt index 1f99d772513..ca02eed0590 100644 --- a/idea/testData/quickfix/experimental/nestedClasses.kt +++ b/idea/testData/quickfix/experimental/nestedClasses.kt @@ -3,10 +3,10 @@ // WITH_RUNTIME // ACTION: Add '@MyExperimentalAPI' annotation to 'bar' // ACTION: Add '@MyExperimentalAPI' annotation to containing class 'Inner' -// ACTION: Add '@UseExperimental(MyExperimentalAPI::class)' annotation to 'bar' +// ACTION: Add '@OptIn(MyExperimentalAPI::class)' annotation to 'bar' // ACTION: Add '-Xuse-experimental=MyExperimentalAPI' to module light_idea_test_case compiler arguments // ACTION: Introduce import alias -// ERROR: This declaration is experimental and its usage must be marked with '@MyExperimentalAPI' or '@UseExperimental(MyExperimentalAPI::class)' +// ERROR: This declaration is experimental and its usage must be marked with '@MyExperimentalAPI' or '@OptIn(MyExperimentalAPI::class)' @Experimental annotation class MyExperimentalAPI @@ -22,4 +22,4 @@ class Outer { } } } -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/experimental/override.kt b/idea/testData/quickfix/experimental/override.kt index 7f85a7faca5..9bab0d83464 100644 --- a/idea/testData/quickfix/experimental/override.kt +++ b/idea/testData/quickfix/experimental/override.kt @@ -2,8 +2,8 @@ // COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental // WITH_RUNTIME // ACTION: Add '@MyExperimentalAPI' annotation to 'foo' -// ACTION: Add '@UseExperimental(MyExperimentalAPI::class)' annotation to 'foo' -// ACTION: Add '@UseExperimental(MyExperimentalAPI::class)' annotation to containing class 'Derived' +// ACTION: Add '@OptIn(MyExperimentalAPI::class)' annotation to 'foo' +// ACTION: Add '@OptIn(MyExperimentalAPI::class)' annotation to containing class 'Derived' // ACTION: Add '-Xuse-experimental=MyExperimentalAPI' to module light_idea_test_case compiler arguments // ERROR: This declaration overrides experimental member of supertype 'Base' and must be annotated with '@MyExperimentalAPI' @@ -18,4 +18,4 @@ open class Base { class Derived : Base() { override fun foo() {} -} \ No newline at end of file +} diff --git a/idea/testData/quickfix/experimental/switchOn.kt b/idea/testData/quickfix/experimental/switchOn.kt index f8fa5eb86f4..e4488e252b9 100644 --- a/idea/testData/quickfix/experimental/switchOn.kt +++ b/idea/testData/quickfix/experimental/switchOn.kt @@ -1,8 +1,8 @@ -// "Add '-Xuse-experimental=kotlin.Experimental' to module light_idea_test_case compiler arguments" "true" +// "Add '-Xuse-experimental=kotlin.RequiresOptIn' to module light_idea_test_case compiler arguments" "true" // COMPILER_ARGUMENTS: -version -// COMPILER_ARGUMENTS_AFTER: -version -Xuse-experimental=kotlin.Experimental +// COMPILER_ARGUMENTS_AFTER: -version -Xuse-experimental=kotlin.RequiresOptIn // DISABLE-ERRORS // WITH_RUNTIME @Experimental -annotation class MyExperimentalAPI \ No newline at end of file +annotation class MyExperimentalAPI diff --git a/idea/testData/quickfix/experimental/switchOn.kt.after b/idea/testData/quickfix/experimental/switchOn.kt.after index c841c4a2906..79539d18ffb 100644 --- a/idea/testData/quickfix/experimental/switchOn.kt.after +++ b/idea/testData/quickfix/experimental/switchOn.kt.after @@ -1,8 +1,8 @@ -// "Add '-Xuse-experimental=kotlin.Experimental' to module light_idea_test_case compiler arguments" "true" +// "Add '-Xuse-experimental=kotlin.RequiresOptIn' to module light_idea_test_case compiler arguments" "true" // COMPILER_ARGUMENTS: -version -// COMPILER_ARGUMENTS_AFTER: -version -Xuse-experimental=kotlin.Experimental +// COMPILER_ARGUMENTS_AFTER: -version -Xuse-experimental=kotlin.RequiresOptIn // DISABLE-ERRORS // WITH_RUNTIME @Experimental -annotation class MyExperimentalAPI \ No newline at end of file +annotation class MyExperimentalAPI diff --git a/idea/testData/quickfix/experimental/typeAlias.kt b/idea/testData/quickfix/experimental/typeAlias.kt index c0cf890e5d3..52a3c8551ec 100644 --- a/idea/testData/quickfix/experimental/typeAlias.kt +++ b/idea/testData/quickfix/experimental/typeAlias.kt @@ -1,4 +1,4 @@ -// "Add '@UseExperimental(AliasMarker::class)' annotation to 'AliasMarkerUsage'" "true" +// "Add '@OptIn(AliasMarker::class)' annotation to 'AliasMarkerUsage'" "true" // COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental // WITH_RUNTIME // ACTION: Add '-Xuse-experimental=AliasMarker' to module light_idea_test_case compiler arguments @@ -9,4 +9,4 @@ annotation class AliasMarker @AliasMarker class AliasTarget -typealias AliasMarkerUsage = AliasTarget \ No newline at end of file +typealias AliasMarkerUsage = AliasTarget diff --git a/idea/testData/quickfix/experimental/typeAlias.kt.after b/idea/testData/quickfix/experimental/typeAlias.kt.after index 4e2dcc4c1d9..a59facd8d07 100644 --- a/idea/testData/quickfix/experimental/typeAlias.kt.after +++ b/idea/testData/quickfix/experimental/typeAlias.kt.after @@ -1,4 +1,4 @@ -// "Add '@UseExperimental(AliasMarker::class)' annotation to 'AliasMarkerUsage'" "true" +// "Add '@OptIn(AliasMarker::class)' annotation to 'AliasMarkerUsage'" "true" // COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental // WITH_RUNTIME // ACTION: Add '-Xuse-experimental=AliasMarker' to module light_idea_test_case compiler arguments @@ -9,5 +9,5 @@ annotation class AliasMarker @AliasMarker class AliasTarget -@UseExperimental(AliasMarker::class) -typealias AliasMarkerUsage = AliasTarget \ No newline at end of file +@OptIn(AliasMarker::class) +typealias AliasMarkerUsage = AliasTarget diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt index 9c0fd8a730a..886a10b0a5c 100644 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt +++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt @@ -126,6 +126,10 @@ public final class kotlin/NumbersKt { public static final fun rotateRight (SI)S } +public abstract interface annotation class kotlin/OptIn : java/lang/annotation/Annotation { + public abstract fun markerClass ()[Ljava/lang/Class; +} + public abstract interface annotation class kotlin/OptionalExpectation : java/lang/annotation/Annotation { } @@ -154,6 +158,17 @@ public abstract interface annotation class kotlin/ReplaceWith : java/lang/annota public abstract fun imports ()[Ljava/lang/String; } +public abstract interface annotation class kotlin/RequiresOptIn : java/lang/annotation/Annotation { + public abstract fun level ()Lkotlin/RequiresOptIn$Level; +} + +public final class kotlin/RequiresOptIn$Level : java/lang/Enum { + public static final field ERROR Lkotlin/RequiresOptIn$Level; + public static final field WARNING Lkotlin/RequiresOptIn$Level; + public static fun valueOf (Ljava/lang/String;)Lkotlin/RequiresOptIn$Level; + public static fun values ()[Lkotlin/RequiresOptIn$Level; +} + public final class kotlin/Result : java/io/Serializable { public static final field Companion Lkotlin/Result$Companion; public static final synthetic fun box-impl (Ljava/lang/Object;)Lkotlin/Result;