Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

java - How to suppress specific Kotlinc/Javac compiler warnings?

How to suppress deprecations in for KotlinCompile in Gradle similar to JavaCompile?

JavaCompile(works):

tasks.withType(JavaCompile) {
    configure(options) {
        compilerArgs << '-Xlint:-deprecation'
    }
}

KotlinCompile(does not work):

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
    kotlinOptions {
        freeCompilerArgs = ["-Xjavac-arguments=-Xlint:-deprecation"]
    }
}

References:

Similar questions:

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Currently Kotlin does not support Surpressing compiler warnings. They do have some categories to surpress. But different then that the only way none is:

@Suppress("DEPRECATION")

Sometimes Surpress will not work by just inputing the annotation which should work on runtime. You might need to add something like the following

val foo = error.asDynamic().response
if (foo is AxiosResponse<String>) {
    @Suppress("UNCHECKED_CAST")
    val response = foo as AxiosResponse<String>
}

Which is not your case. But apparently other people have had the similar issue. I suggest taking a brief look at reddit. Which also not the case above but can lead you.

https://www.reddit.com/r/Kotlin/comments/bsgk5w/what_do_i_have_to_do_to_suppress_my_unchecked/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...