如何在解构声明之前抑制未经检查的施法警告?

时间:2017-09-18 03:58:03

标签: kotlin

IDE向我展示@Suppress在解构声明之前无法放置的提示

@Suppress("UNCHECKED_CAST")
var test = authentication.details as Pair<String?,String?>
@Suppress("UNCHECKED_CAST")
val (token,role) = authentication.details as Pair<String?,String?>

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以像这样注释表达式:

val (token,role) = @Suppress("UNCHECKED_CAST") (authentication.details as Pair<String?,String?>)