Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the possible values that can be given to `@Suppress` in Kotlin?

Tags:

kotlin

The Kotlin compiler gave me the following warning:

Warning:(399, 1) Kotlin: Expected performance impact of inlining '...' can be insignificant. Inlining works best for functions with lambda parameters

In this case I would like to suppress this warning. I don't know what value to give to @Suppress, however, and I can't find any documentation for what values @Suppress accepts.

What are the possible values that can be given to @Suppress, and what do they mean?

like image 970
Laurence Gonsalves Avatar asked Nov 15 '16 07:11

Laurence Gonsalves


People also ask

What is suppress annotation in Kotlin?

Suppresses the given compilation warnings in the annotated element. <init>(vararg names: String)

How do you stop Detekt?

detekt supports the Java ( @SuppressWarnings ) and Kotlin ( @Suppress ) style suppression. If both annotations are present, Kotlin's annotation is favored! To suppress an issue, the id of the issue must be written inside the values field of the annotation.

How do you stop deprecation warning in Kotlin?

Instead of a single statement, you can also mark a function, a class or a file ( @file:Suppress("DEPRECATION") in its beginning) with the annotation to suppress all the deprecation warnings issued there. In IntelliJ IDEA this can also be done through Alt + Enter menu with caret placed on code with deprecation warning.

How do you stop unchecked cast Kotlin?

1 Answer. Show activity on this post. Adding @Suppress("UNCHECKED_CAST") (also possible through IDEA's Alt + Enter menu) to any of statement, function, class and file should help.


1 Answers

IntelliJ gives you nice help here:

enter image description here

Which adds @Suppress("NOTHING_TO_INLINE") to resolve the warning.

Some of the possible names of the compiler diagnostics to suppress can be found in Errors.java and DefaultErrorMessages.java i.e.:

REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present" 
like image 116
miensol Avatar answered Oct 02 '22 11:10

miensol