Rename UseExperimental->OptIn, Experimental->RequiresOptIn in quickfix and IDE tests

This commit is contained in:
Alexander Udalov
2019-12-27 16:32:19 +01:00
parent da077b5353
commit 9187a85aaf
41 changed files with 104 additions and 104 deletions
@@ -1,6 +1,6 @@
package experimentalApi
@Experimental(Experimental.Level.ERROR)
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
annotation class UnstableApi
@UnstableApi
@@ -28,11 +28,11 @@ class MakeModuleExperimentalFix(
private val module: Module,
private val annotationFqName: FqName
) : KotlinQuickFixAction<KtFile>(file) {
override fun getText(): String = "Add '-Xuse-experimental=$annotationFqName' to module ${module.name} compiler arguments"
override fun getText(): String = "Add '-Xopt-in=$annotationFqName' to module ${module.name} compiler arguments"
override fun getFamilyName(): String = "Make module experimental"
override fun getFamilyName(): String = "Add an opt-in requirement marker compiler argument"
private val compilerArgument = "-Xuse-experimental=$annotationFqName"
private val compilerArgument = "-Xopt-in=$annotationFqName"
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val modelsProvider = IdeModifiableModelsProviderImpl(project)
@@ -60,7 +60,7 @@ class MakeModuleExperimentalFix(
compilerArgument !in compilerSettings.additionalArgumentsAsList
} else {
compilerSettings.additionalArgumentsAsList.none {
it.startsWith("-Xuse-experimental=") || it.startsWith("-Xexperimental=")
it.startsWith("-Xopt-in=") || it.startsWith("-Xuse-experimental=") || it.startsWith("-Xexperimental=")
}
}
}
@@ -1,6 +1,6 @@
// DISABLE-ERRORS
@Experimental
@RequiresOptIn
annotation class FirstExperience
open class ParentTarget {
@@ -1,6 +1,6 @@
// DISABLE-ERRORS
@Experimental
@RequiresOptIn
annotation class FirstExperience
open class ParentTarget {
@@ -4,7 +4,7 @@ package test
import kotlin.contracts.*
@UseExperimental(ExperimentalContracts::class)
@OptIn(ExperimentalContracts::class)
fun myRequire(x: Boolean) {
contract {
returns(true) implies (x)
@@ -1,6 +1,6 @@
package lib
@Experimental
@RequiresOptIn
annotation class ExperimentalAPI
class Foo
@@ -1,6 +1,6 @@
package lib
@Experimental
@RequiresOptIn
annotation class ExperimentalAPI
class Foo
@@ -1,8 +1,8 @@
// "Add '@TopMarker' annotation to 'topUserVal'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class TopMarker
@TopMarker
@@ -12,4 +12,4 @@ class TopClass
@TopMarker
annotation class TopAnn
val topUserVal: @<caret>TopAnn TopClass? = null
val topUserVal: @<caret>TopAnn TopClass? = null
@@ -1,8 +1,8 @@
// "Add '@TopMarker' annotation to 'topUserVal'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class TopMarker
@TopMarker
@@ -13,4 +13,4 @@ class TopClass
annotation class TopAnn
@TopMarker
val topUserVal: @TopAnn TopClass? = null
val topUserVal: @TopAnn TopClass? = null
+3 -3
View File
@@ -1,8 +1,8 @@
// "Add '@MyExperimentalAPI' annotation to 'bar'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
@MyExperimentalAPI
@@ -12,4 +12,4 @@ class Bar {
fun bar() {
foo<caret>()
}
}
}
+3 -3
View File
@@ -1,8 +1,8 @@
// "Add '@MyExperimentalAPI' annotation to 'bar'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
@MyExperimentalAPI
@@ -13,4 +13,4 @@ class Bar {
fun bar() {
foo()
}
}
}
@@ -1,8 +1,8 @@
// "Add '@MyExperimentalAPI' annotation to containing class 'Bar'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
@MyExperimentalAPI
@@ -12,4 +12,4 @@ class Bar {
fun bar() {
foo<caret>()
}
}
}
@@ -1,8 +1,8 @@
// "Add '@MyExperimentalAPI' annotation to containing class 'Bar'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
@MyExperimentalAPI
@@ -13,4 +13,4 @@ class Bar {
fun bar() {
foo()
}
}
}
@@ -1,13 +1,13 @@
// "Add '@MyExperimentalAPI' annotation to 'bar'" "false"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
// ACTION: Add '@MyExperimentalAPI' annotation to containing class 'Bar'
// ACTION: Add '@OptIn(MyExperimentalAPI::class)' annotation to 'bar'
// ACTION: Add '-Xuse-experimental=MyExperimentalAPI' to module light_idea_test_case compiler arguments
// ACTION: Add '-Xopt-in=MyExperimentalAPI' to module light_idea_test_case compiler arguments
// 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
@RequiresOptIn
@Target(AnnotationTarget.CLASS)
annotation class MyExperimentalAPI
+5 -5
View File
@@ -1,12 +1,12 @@
// "Add '-Xuse-experimental=test.MyExperimentalAPI' to module light_idea_test_case compiler arguments" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS_AFTER: -Xuse-experimental=kotlin.Experimental -Xuse-experimental=test.MyExperimentalAPI
// "Add '-Xopt-in=test.MyExperimentalAPI' to module light_idea_test_case compiler arguments" "true"
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// COMPILER_ARGUMENTS_AFTER: -Xopt-in=kotlin.RequiresOptIn -Xopt-in=test.MyExperimentalAPI
// DISABLE-ERRORS
// WITH_RUNTIME
package test
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
@MyExperimentalAPI
@@ -18,4 +18,4 @@ class Bar {
fun bar() {
Some().foo<caret>()
}
}
}
+5 -5
View File
@@ -1,12 +1,12 @@
// "Add '-Xuse-experimental=test.MyExperimentalAPI' to module light_idea_test_case compiler arguments" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS_AFTER: -Xuse-experimental=kotlin.Experimental -Xuse-experimental=test.MyExperimentalAPI
// "Add '-Xopt-in=test.MyExperimentalAPI' to module light_idea_test_case compiler arguments" "true"
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// COMPILER_ARGUMENTS_AFTER: -Xopt-in=kotlin.RequiresOptIn -Xopt-in=test.MyExperimentalAPI
// DISABLE-ERRORS
// WITH_RUNTIME
package test
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
@MyExperimentalAPI
@@ -18,4 +18,4 @@ class Bar {
fun bar() {
Some().foo()
}
}
}
@@ -1,10 +1,10 @@
// "Add '@OptIn(MyExperimentalAPI::class)' annotation to 'bar'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
package a.b
@Experimental
@RequiresOptIn
@Target(AnnotationTarget.CLASS)
annotation class MyExperimentalAPI
@@ -1,10 +1,10 @@
// "Add '@OptIn(MyExperimentalAPI::class)' annotation to 'bar'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
package a.b
@Experimental
@RequiresOptIn
@Target(AnnotationTarget.CLASS)
annotation class MyExperimentalAPI
@@ -1,10 +1,10 @@
// "Add '@OptIn(MyExperimentalAPI::class)' annotation to containing class 'Bar'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
package a.b
@Experimental
@RequiresOptIn
@Target(AnnotationTarget.FUNCTION)
annotation class MyExperimentalAPI
@@ -1,10 +1,10 @@
// "Add '@OptIn(MyExperimentalAPI::class)' annotation to containing class 'Bar'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
package a.b
@Experimental
@RequiresOptIn
@Target(AnnotationTarget.FUNCTION)
annotation class MyExperimentalAPI
+4 -4
View File
@@ -1,10 +1,10 @@
// "Add '-Xuse-experimental=kotlin.Experimental' to module light_idea_test_case compiler arguments" "false"
// COMPILER_ARGUMENTS: -version -Xuse-experimental=Something
// "Add '-Xopt-in=kotlin.RequiresOptIn' to module light_idea_test_case compiler arguments" "false"
// COMPILER_ARGUMENTS: -version -Xopt-in=Something
// DISABLE-ERRORS
// WITH_RUNTIME
// ACTION: Introduce import alias
// ACTION: Make internal
// ACTION: Make private
@Experimental<caret>
annotation class MyExperimentalAPI
@RequiresOptIn<caret>
annotation class MyExperimentalAPI
+2 -2
View File
@@ -1,10 +1,10 @@
// "Safe delete 'Marker'" "false"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental -Xuse-experimental=test.Marker
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn -Xopt-in=test.Marker
// WITH_RUNTIME
// ACTION: Rename file to Marker.kt
// TOOL: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
package test
@Experimental
@RequiresOptIn
annotation class <caret>Marker
+2 -2
View File
@@ -1,10 +1,10 @@
// "Safe delete 'Marker'" "false"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental -Xexperimental=test.Marker
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn -Xexperimental=test.Marker
// WITH_RUNTIME
// ACTION: Rename file to Marker.kt
// TOOL: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
package test
@Experimental
@RequiresOptIn
annotation class <caret>Marker
@@ -1,8 +1,8 @@
// "Add '@MyExperimentalAPI' annotation to 'outer'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
@Target(AnnotationTarget.FUNCTION)
annotation class MyExperimentalAPI
@@ -17,4 +17,4 @@ class Outer {
override fun foo<caret>() {}
}
}
}
}
@@ -1,8 +1,8 @@
// "Add '@MyExperimentalAPI' annotation to 'outer'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
@Target(AnnotationTarget.FUNCTION)
annotation class MyExperimentalAPI
@@ -18,4 +18,4 @@ class Outer {
override fun foo<caret>() {}
}
}
}
}
+3 -3
View File
@@ -1,8 +1,8 @@
// "Add '@MyExperimentalAPI' annotation to 'outer'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
@MyExperimentalAPI
@@ -12,4 +12,4 @@ fun outer() {
fun bar() {
foo<caret>()
}
}
}
+3 -3
View File
@@ -1,8 +1,8 @@
// "Add '@MyExperimentalAPI' annotation to 'outer'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
@MyExperimentalAPI
@@ -13,4 +13,4 @@ fun outer() {
fun bar() {
foo()
}
}
}
+3 -3
View File
@@ -1,14 +1,14 @@
// "Add '@MyExperimentalAPI' annotation to containing class 'Outer'" "false"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
// ACTION: Add '@MyExperimentalAPI' annotation to 'bar'
// ACTION: Add '@MyExperimentalAPI' annotation to containing class 'Inner'
// ACTION: Add '@OptIn(MyExperimentalAPI::class)' annotation to 'bar'
// ACTION: Add '-Xuse-experimental=MyExperimentalAPI' to module light_idea_test_case compiler arguments
// ACTION: Add '-Xopt-in=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 '@OptIn(MyExperimentalAPI::class)'
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
@MyExperimentalAPI
+3 -3
View File
@@ -1,13 +1,13 @@
// "Add '@MyExperimentalAPI' annotation to containing class 'Derived'" "false"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
// ACTION: Add '@MyExperimentalAPI' annotation to 'foo'
// 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
// ACTION: Add '-Xopt-in=MyExperimentalAPI' to module light_idea_test_case compiler arguments
// ERROR: This declaration overrides experimental member of supertype 'Base' and must be annotated with '@MyExperimentalAPI'
@Experimental
@RequiresOptIn
@Target(AnnotationTarget.FUNCTION)
annotation class MyExperimentalAPI
@@ -1,12 +1,12 @@
// "Add '@PropertyTypeMarker' annotation to 'PropertyTypeContainer'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
// ACTION: Add '@PropertyTypeMarker' annotation to containing class 'PropertyTypeContainer'
@Experimental
@RequiresOptIn
annotation class PropertyTypeMarker
@PropertyTypeMarker
class PropertyTypeMarked
class PropertyTypeContainer(val subject: Property<caret>TypeMarked)
class PropertyTypeContainer(val subject: Property<caret>TypeMarked)
@@ -1,12 +1,12 @@
// "Add '@PropertyTypeMarker' annotation to 'PropertyTypeContainer'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
// ACTION: Add '@PropertyTypeMarker' annotation to containing class 'PropertyTypeContainer'
@Experimental
@RequiresOptIn
annotation class PropertyTypeMarker
@PropertyTypeMarker
class PropertyTypeMarked
class PropertyTypeContainer @PropertyTypeMarker constructor(val subject: PropertyTypeMarked)
class PropertyTypeContainer @PropertyTypeMarker constructor(val subject: PropertyTypeMarked)
+3 -3
View File
@@ -1,8 +1,8 @@
// "Add '-Xuse-experimental=kotlin.RequiresOptIn' to module light_idea_test_case compiler arguments" "true"
// "Add '-Xopt-in=kotlin.RequiresOptIn' to module light_idea_test_case compiler arguments" "true"
// COMPILER_ARGUMENTS: -version
// COMPILER_ARGUMENTS_AFTER: -version -Xuse-experimental=kotlin.RequiresOptIn
// COMPILER_ARGUMENTS_AFTER: -version -Xopt-in=kotlin.RequiresOptIn
// DISABLE-ERRORS
// WITH_RUNTIME
@Experimental<caret>
@RequiresOptIn<caret>
annotation class MyExperimentalAPI
+3 -3
View File
@@ -1,8 +1,8 @@
// "Add '-Xuse-experimental=kotlin.RequiresOptIn' to module light_idea_test_case compiler arguments" "true"
// "Add '-Xopt-in=kotlin.RequiresOptIn' to module light_idea_test_case compiler arguments" "true"
// COMPILER_ARGUMENTS: -version
// COMPILER_ARGUMENTS_AFTER: -version -Xuse-experimental=kotlin.RequiresOptIn
// COMPILER_ARGUMENTS_AFTER: -version -Xopt-in=kotlin.RequiresOptIn
// DISABLE-ERRORS
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class MyExperimentalAPI
+3 -3
View File
@@ -1,9 +1,9 @@
// "Add '@OptIn(AliasMarker::class)' annotation to 'AliasMarkerUsage'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
// ACTION: Add '-Xuse-experimental=AliasMarker' to module light_idea_test_case compiler arguments
// ACTION: Add '-Xopt-in=AliasMarker' to module light_idea_test_case compiler arguments
@Experimental
@RequiresOptIn
annotation class AliasMarker
@AliasMarker
+3 -3
View File
@@ -1,9 +1,9 @@
// "Add '@OptIn(AliasMarker::class)' annotation to 'AliasMarkerUsage'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
// ACTION: Add '-Xuse-experimental=AliasMarker' to module light_idea_test_case compiler arguments
// ACTION: Add '-Xopt-in=AliasMarker' to module light_idea_test_case compiler arguments
@Experimental
@RequiresOptIn
annotation class AliasMarker
@AliasMarker
@@ -1,8 +1,8 @@
// "Add '@TopMarker' annotation to 'topUserVal'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class TopMarker
@TopMarker
@@ -12,4 +12,4 @@ class TopClass
@TopMarker
annotation class TopAnn
val topUserVal: @TopAnn <caret>TopClass? = null
val topUserVal: @TopAnn <caret>TopClass? = null
@@ -1,8 +1,8 @@
// "Add '@TopMarker' annotation to 'topUserVal'" "true"
// COMPILER_ARGUMENTS: -Xuse-experimental=kotlin.Experimental
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
// WITH_RUNTIME
@Experimental
@RequiresOptIn
annotation class TopMarker
@TopMarker
@@ -13,4 +13,4 @@ class TopClass
annotation class TopAnn
@TopMarker
val topUserVal: @TopAnn TopClass? = null
val topUserVal: @TopAnn TopClass? = null
@@ -5,7 +5,7 @@ package test
import kotlin.contracts.*
@UseExperimental(ExperimentalContracts::class)
@OptIn(ExperimentalContracts::class)
fun myRequire(x: Boolean) {
contract {
returns() implies x
@@ -5,7 +5,7 @@ package test
import kotlin.contracts.*
@UseExperimental(ExperimentalContracts::class)
@OptIn(ExperimentalContracts::class)
fun myRequire(x: Boolean) {
contract {
returns() implies x
@@ -3,7 +3,7 @@ package test
import kotlin.contracts.*
@UseExperimental(ExperimentalContracts::class)
@OptIn(ExperimentalContracts::class)
fun myRequire(x: Boolean) {
contract {
returns() implies x
@@ -234,7 +234,7 @@ open class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
val lib = MockLibraryUtil.compileJvmLibraryToJar(
testDataPath + "${getTestName(true)}/lib", "lib",
extraOptions = listOf(
"-Xuse-experimental=kotlin.Experimental",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xexperimental=lib.ExperimentalAPI"
)
)
@@ -247,7 +247,7 @@ open class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
val lib = MockLibraryUtil.compileJsLibraryToJar(
testDataPath + "${getTestName(true)}/lib", "lib", false,
extraOptions = listOf(
"-Xuse-experimental=kotlin.Experimental",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xexperimental=lib.ExperimentalAPI"
)
)