Migrate UseExperimental->OptIn, -Xuse-experimental -> -Xopt-in

This commit is contained in:
Ilya Gorbunov
2020-03-21 01:46:48 +03:00
committed by ilya-g
parent 5937145558
commit 8e1cabed35
17 changed files with 35 additions and 35 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ sourceSets.main.kotlin.srcDirs += "src/jvm/kotlin"
compileKotlin { compileKotlin {
kotlinOptions { kotlinOptions {
freeCompilerArgs = ['-Xuse-experimental=kotlin.ExperimentalUnsignedTypes', "-XXLanguage:+InlineClasses"] freeCompilerArgs = ['-Xopt-in=kotlin.ExperimentalUnsignedTypes', '-Xinline-classes']
} }
} }
@@ -560,7 +560,7 @@ public fun CPointer<IntVar>.toKStringFromUtf32(): String {
* *
* Malformed byte sequences are replaced by the replacement char `\uFFFD`. * Malformed byte sequences are replaced by the replacement char `\uFFFD`.
*/ */
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
@SinceKotlin("1.3") @SinceKotlin("1.3")
public fun ByteArray.toKString() : String { public fun ByteArray.toKString() : String {
val realEndIndex = realEndIndex(this, 0, this.size) val realEndIndex = realEndIndex(this, 0, this.size)
@@ -579,7 +579,7 @@ public fun ByteArray.toKString() : String {
* @throws IllegalArgumentException if [startIndex] is greater than [endIndex]. * @throws IllegalArgumentException if [startIndex] is greater than [endIndex].
* @throws CharacterCodingException if the byte array contains malformed UTF-8 byte sequence and [throwOnInvalidSequence] is true. * @throws CharacterCodingException if the byte array contains malformed UTF-8 byte sequence and [throwOnInvalidSequence] is true.
*/ */
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
@SinceKotlin("1.3") @SinceKotlin("1.3")
public fun ByteArray.toKString( public fun ByteArray.toKString(
startIndex: Int = 0, startIndex: Int = 0,
+1 -1
View File
@@ -44,6 +44,6 @@ dependencies {
compileKotlin { compileKotlin {
kotlinOptions { kotlinOptions {
freeCompilerArgs = ['-Xuse-experimental=kotlin.ExperimentalUnsignedTypes', '-Xskip-metadata-version-check'] freeCompilerArgs = ['-Xopt-in=kotlin.ExperimentalUnsignedTypes', '-Xskip-metadata-version-check']
} }
} }
+3 -3
View File
@@ -219,9 +219,9 @@ targetList.each { target ->
args = [*konanArgs, args = [*konanArgs,
'-output', project(':runtime').file("build/${target}Stdlib"), '-output', project(':runtime').file("build/${target}Stdlib"),
'-produce', 'library', '-module-name', 'stdlib', '-XXLanguage:+AllowContractsForCustomFunctions', '-produce', 'library', '-module-name', 'stdlib', '-XXLanguage:+AllowContractsForCustomFunctions',
'-Xmulti-platform', '-Xuse-experimental=kotlin.Experimental', '-XXLanguage:+InlineClasses', '-Xmulti-platform', '-Xopt-in=kotlin.RequiresOptIn', '-Xinline-classes',
'-Xuse-experimental=kotlin.contracts.ExperimentalContracts', '-Xopt-in=kotlin.contracts.ExperimentalContracts',
'-Xuse-experimental=kotlin.ExperimentalMultiplatform', '-Xopt-in=kotlin.ExperimentalMultiplatform',
'-Xallow-result-return-type', '-Xallow-result-return-type',
commonSrc.absolutePath, commonSrc.absolutePath,
"-Xcommon-sources=${commonSrc.absolutePath}", "-Xcommon-sources=${commonSrc.absolutePath}",
+2 -2
View File
@@ -1446,7 +1446,7 @@ linkTest("classDelegation_linkTest") {
} }
standaloneTest("contracts") { standaloneTest("contracts") {
flags = [ '-Xuse-experimental=kotlin.Experimental', '-tr' ] flags = [ '-Xopt-in=kotlin.RequiresOptIn', '-tr' ]
source = "codegen/contracts/contracts.kt" source = "codegen/contracts/contracts.kt"
} }
@@ -4180,7 +4180,7 @@ KotlinNativeTestKt.createTest(project, 'stdlibTest', KonanGTest) { task ->
baseDir "$testOutputStdlib/stdlibTest" baseDir "$testOutputStdlib/stdlibTest"
enableMultiplatform true enableMultiplatform true
extraOpts '-tr', extraOpts '-tr',
'-Xuse-experimental=kotlin.Experimental,kotlin.ExperimentalStdlibApi', '-Xopt-in=kotlin.RequiresOptIn,kotlin.ExperimentalStdlibApi',
"-friend-modules", project.rootProject.file("${project.properties['konan.home']}/klib/common/stdlib").absolutePath "-friend-modules", project.rootProject.file("${project.properties['konan.home']}/klib/common/stdlib").absolutePath
extraOpts project.globalTestArgs extraOpts project.globalTestArgs
} }
@@ -9,7 +9,7 @@ import kotlin.test.*
import kotlin.reflect.* import kotlin.reflect.*
@Test @Test
@UseExperimental(ExperimentalAssociatedObjects::class) @OptIn(ExperimentalAssociatedObjects::class)
fun testBasics1() { fun testBasics1() {
assertSame(Bar, Foo::class.findAssociatedObject<Associated1>()) assertSame(Bar, Foo::class.findAssociatedObject<Associated1>())
assertSame(Baz, Foo::class.findAssociatedObject<Associated2>()) assertSame(Baz, Foo::class.findAssociatedObject<Associated2>())
@@ -18,17 +18,17 @@ fun testBasics1() {
assertSame(null, Bar::class.findAssociatedObject<Associated1>()) assertSame(null, Bar::class.findAssociatedObject<Associated1>())
} }
@UseExperimental(ExperimentalAssociatedObjects::class) @OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey @AssociatedObjectKey
@Retention(AnnotationRetention.BINARY) @Retention(AnnotationRetention.BINARY)
annotation class Associated1(val kClass: KClass<*>) annotation class Associated1(val kClass: KClass<*>)
@UseExperimental(ExperimentalAssociatedObjects::class) @OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey @AssociatedObjectKey
@Retention(AnnotationRetention.BINARY) @Retention(AnnotationRetention.BINARY)
annotation class Associated2(val kClass: KClass<*>) annotation class Associated2(val kClass: KClass<*>)
@UseExperimental(ExperimentalAssociatedObjects::class) @OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey @AssociatedObjectKey
@Retention(AnnotationRetention.BINARY) @Retention(AnnotationRetention.BINARY)
annotation class Associated3(val kClass: KClass<*>) annotation class Associated3(val kClass: KClass<*>)
@@ -41,7 +41,7 @@ object Bar
object Baz object Baz
@Test @Test
@UseExperimental(ExperimentalAssociatedObjects::class) @OptIn(ExperimentalAssociatedObjects::class)
fun testGlobalOptimizations1() { fun testGlobalOptimizations1() {
val i1 = I1ImplHolder::class.findAssociatedObject<Associated1>()!! as I1 val i1 = I1ImplHolder::class.findAssociatedObject<Associated1>()!! as I1
assertEquals(42, i1.foo()) assertEquals(42, i1.foo())
@@ -68,7 +68,7 @@ private object I1Impl : I1 {
private class I1ImplHolder private class I1ImplHolder
@Test @Test
@UseExperimental(ExperimentalAssociatedObjects::class) @OptIn(ExperimentalAssociatedObjects::class)
fun testGlobalOptimizations2() { fun testGlobalOptimizations2() {
val i2 = I2ImplHolder()::class.findAssociatedObject<Associated1>()!! as I2 val i2 = I2ImplHolder()::class.findAssociatedObject<Associated1>()!! as I2
assertEquals(17, i2.foo()) assertEquals(17, i2.foo())
@@ -4,7 +4,7 @@ import kotlin.contracts.*
open class S open class S
class P(val str: String = "P") : S() class P(val str: String = "P") : S()
@UseExperimental(kotlin.contracts.ExperimentalContracts::class) @OptIn(kotlin.contracts.ExperimentalContracts::class)
fun check(actual: Boolean) { fun check(actual: Boolean) {
contract { returns() implies actual } contract { returns() implies actual }
assertTrue(actual) assertTrue(actual)
+1 -1
View File
@@ -8,7 +8,7 @@ package codegen.ktype.ktype1
import kotlin.test.* import kotlin.test.*
import kotlin.reflect.* import kotlin.reflect.*
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
inline fun <reified R> kType() = typeOf<R>() inline fun <reified R> kType() = typeOf<R>()
inline fun <reified R> kType(obj: R) = kType<R>() inline fun <reified R> kType(obj: R) = kType<R>()
@@ -332,7 +332,7 @@ class RunExternalTestGroup extends OldKonanTest {
def experimentalSettings = findLinesWithPrefixesRemoved(text, "// !USE_EXPERIMENTAL: ") def experimentalSettings = findLinesWithPrefixesRemoved(text, "// !USE_EXPERIMENTAL: ")
if (experimentalSettings.size() != 0) { if (experimentalSettings.size() != 0) {
experimentalSettings.forEach { line -> experimentalSettings.forEach { line ->
line.split(" ").toList().forEach { flags.add("-Xuse-experimental=$it") } line.split(" ").toList().forEach { flags.add("-Xopt-in=$it") }
} }
} }
} }
+3 -3
View File
@@ -60,7 +60,7 @@ kotlin {
jvm().compilations.all { jvm().compilations.all {
kotlinOptions { kotlinOptions {
freeCompilerArgs = ["-Xuse-experimental=kotlinx.cli.ExperimentalCli"] freeCompilerArgs = ["-Xopt-in=kotlinx.cli.ExperimentalCli"]
suppressWarnings = true suppressWarnings = true
} }
} }
@@ -92,8 +92,8 @@ targetList.each { target ->
args = [*konanArgs, args = [*konanArgs,
'-output', project.file("build/${target}KotlinxCli"), '-output', project.file("build/${target}KotlinxCli"),
'-produce', 'library', '-module-name', 'kotlinx-cli', '-XXLanguage:+AllowContractsForCustomFunctions', '-produce', 'library', '-module-name', 'kotlinx-cli', '-XXLanguage:+AllowContractsForCustomFunctions',
'-Xmulti-platform', '-Xuse-experimental=kotlinx.cli.ExperimentalCli', '-Xmulti-platform', '-Xopt-in=kotlinx.cli.ExperimentalCli',
'-Xuse-experimental=kotlin.ExperimentalMultiplatform', '-Xopt-in=kotlin.ExperimentalMultiplatform',
'-Xallow-result-return-type', '-Xallow-result-return-type',
commonSrc.absolutePath, commonSrc.absolutePath,
"-Xcommon-sources=${commonSrc.absolutePath}", "-Xcommon-sources=${commonSrc.absolutePath}",
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
@file:UseExperimental(ExperimentalCli::class) @file:OptIn(ExperimentalCli::class)
package org.jetbrains.benchmarksLauncher package org.jetbrains.benchmarksLauncher
import org.jetbrains.report.BenchmarkResult import org.jetbrains.report.BenchmarkResult
@@ -45,7 +45,7 @@ public inline fun <T> Array<out T>.subarrayContentToString(offset: Int, length:
* If any of arrays contains itself on any nesting level the behavior is undefined. * If any of arrays contains itself on any nesting level the behavior is undefined.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@UseExperimental(ExperimentalUnsignedTypes::class) @OptIn(ExperimentalUnsignedTypes::class)
internal fun <T> Array<out T>?.contentDeepHashCodeImpl(): Int { internal fun <T> Array<out T>?.contentDeepHashCodeImpl(): Int {
if (this == null) return 0 if (this == null) return 0
var result = 1 var result = 1
@@ -512,10 +512,10 @@ actual class HashMap<K, V> private constructor(
const val INITIAL_MAX_PROBE_DISTANCE = 2 const val INITIAL_MAX_PROBE_DISTANCE = 2
const val TOMBSTONE = -1 const val TOMBSTONE = -1
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
fun computeHashSize(capacity: Int): Int = (capacity.coerceAtLeast(1) * 3).takeHighestOneBit() fun computeHashSize(capacity: Int): Int = (capacity.coerceAtLeast(1) * 3).takeHighestOneBit()
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
fun computeShift(hashSize: Int): Int = hashSize.countLeadingZeroBits() + 1 fun computeShift(hashSize: Int): Int = hashSize.countLeadingZeroBits() + 1
} }
@@ -11,10 +11,10 @@ import kotlin.native.internal.*
* The experimental marker for associated objects API. * The experimental marker for associated objects API.
* *
* Any usage of a declaration annotated with `@ExperimentalAssociatedObjects` must be accepted either by * Any usage of a declaration annotated with `@ExperimentalAssociatedObjects` must be accepted either by
* annotating that usage with the [UseExperimental] annotation, e.g. `@UseExperimental(ExperimentalAssociatedObjects::class)`, * annotating that usage with the [OptIn] annotation, e.g. `@OptIn(ExperimentalAssociatedObjects::class)`,
* or by using the compiler argument `-Xuse-experimental=kotlin.reflect.ExperimentalAssociatedObjects`. * or by using the compiler argument `-Xopt-in=kotlin.reflect.ExperimentalAssociatedObjects`.
*/ */
@Experimental(level = Experimental.Level.ERROR) @RequiresOptIn(level = RequiresOptIn.Level.ERROR)
@Retention(value = AnnotationRetention.BINARY) @Retention(value = AnnotationRetention.BINARY)
public annotation class ExperimentalAssociatedObjects public annotation class ExperimentalAssociatedObjects
@@ -58,7 +58,7 @@ actual class StringBuilder private constructor (
return append(toAppend, 0, toAppend.length) return append(toAppend, 0, toAppend.length)
} }
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
actual override fun append(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder = this.appendRange(value, startIndex, endIndex) actual override fun append(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder = this.appendRange(value, startIndex, endIndex)
/** /**
@@ -319,7 +319,7 @@ actual class StringBuilder private constructor (
* *
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder. * @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/ */
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
actual fun insert(index: Int, value: CharSequence?): StringBuilder { actual fun insert(index: Int, value: CharSequence?): StringBuilder {
// Kotlin/JVM inserts the "null" string if the argument is null. // Kotlin/JVM inserts the "null" string if the argument is null.
val toInsert = value ?: "null" val toInsert = value ?: "null"
@@ -887,7 +887,7 @@ public inline fun StringBuilder.setLength(l: Int) = this.setLength(newLength = l
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [start] or [end] is out of range of the [csq] character sequence indices or when `start > end`. * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [start] or [end] is out of range of the [csq] character sequence indices or when `start > end`.
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder. * @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/ */
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun StringBuilder.insert(index: Int, csq: CharSequence?, start: Int, end: Int): StringBuilder = public inline fun StringBuilder.insert(index: Int, csq: CharSequence?, start: Int, end: Int): StringBuilder =
this.insertRange(index, csq, start, end) this.insertRange(index, csq, start, end)
@@ -905,6 +905,6 @@ public inline fun StringBuilder.setCharAt(index: Int, value: Char) = this.set(in
* *
* @throws IndexOutOfBoundsException if [index] is out of bounds of this string builder. * @throws IndexOutOfBoundsException if [index] is out of bounds of this string builder.
*/ */
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun StringBuilder.deleteCharAt(index: Int) = this.deleteAt(index) public inline fun StringBuilder.deleteCharAt(index: Int) = this.deleteAt(index)
@@ -485,7 +485,7 @@ internal class CharClass(val ignoreCase: Boolean = false, negative: Boolean = fa
} }
} }
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
override val instance: AbstractCharClass override val instance: AbstractCharClass
get() { get() {
@@ -519,7 +519,7 @@ internal class CharClass(val ignoreCase: Boolean = false, negative: Boolean = fa
} }
} }
@UseExperimental(ExperimentalStdlibApi::class) @OptIn(ExperimentalStdlibApi::class)
//for debugging purposes only //for debugging purposes only
override fun toString(): String { override fun toString(): String {
val temp = StringBuilder() val temp = StringBuilder()
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
@file:UseExperimental(ExperimentalCli::class) @file:OptIn(ExperimentalCli::class)
import org.jetbrains.analyzer.sendGetRequest import org.jetbrains.analyzer.sendGetRequest
import org.jetbrains.analyzer.readFile import org.jetbrains.analyzer.readFile
import org.jetbrains.analyzer.SummaryBenchmarksReport import org.jetbrains.analyzer.SummaryBenchmarksReport