Kotlin-Tutorials icon indicating copy to clipboard operation
Kotlin-Tutorials copied to clipboard

@Suppress 注解可以用的 names

Open Kazusa1412 opened this issue 4 years ago • 2 comments

在 kotlin 中 @Suppress 是一个神奇的注解,能消除编译器的警告,甚至还能消除错误,不过这个注解的参数 names 很多时候不知道该怎么写

/**
 * Suppresses the given compilation warnings in the annotated element.
 * @property names names of the compiler diagnostics to suppress.
 */
@Target(CLASS, ANNOTATION_CLASS, TYPE_PARAMETER, PROPERTY, FIELD, LOCAL_VARIABLE, VALUE_PARAMETER,
        CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPE, EXPRESSION, FILE, TYPEALIAS)
@Retention(SOURCE)
public annotation class Suppress(vararg val names: String)

这里 好像有这个names参数的信息,不过我测试过并不是全部都能生效的。

~~视频快水起来~~

Kazusa1412 avatar Jun 28 '21 05:06 Kazusa1412

已加入排期

bennyhuo avatar Aug 03 '21 06:08 bennyhuo

同问

yasuofenglei avatar Oct 12 '23 06:10 yasuofenglei