Kotlin 选择加入:此版本的编译器不支持标志

A1m*_*A1m 4 android kotlin

我按照此处此处的Kotlin 文档选择加入kotlin.ExperimentalUnsignedTypes整个模块。我的模块build.gradle现在看起来像这样:

android {

    ...

    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs += "-Xopt-in=kotlin.ExperimentalUnsignedTypes"
    }
Run Code Online (Sandbox Code Playgroud)

Lint 仍在抱怨 ExperimentalUnsignedTypes,编译时我收到此警告:

> Task :myModule:compileDebugKotlin
w: Flag is not supported by this version of the compiler: -Xopt-in=kotlin.ExperimentalUnsignedTypes
Run Code Online (Sandbox Code Playgroud)

我的科特林版本是:1.3.61

Ani*_*ahu 5

正如这里的文档中提到的

@RequireOptIn@OptIn注释在 1.3.70 中引入,以取代以前使用的@Experimental@UseExperimental;同时,-Xopt-in编译器选项替换为-Xuse-experimental.

@OptIn(...::class)和使用-Xopt-in=...是在 Kotlin 1.3.70 中引入的,但旧版和黄金版-Xuse-experimental在未来版本中仍然可用(在 Kotlin 1.4-M1 中测试)。