1.问题
Kotlin版本升级导致编译报错:'when' expression must be exhaustive, add necessary 'xxx', 'null' branches or 'else' branch instead
2.原因
Kotlin1.7之后when强制封闭问题,1.6及之前的版本只做Waring提示,1.7之后变成了Error导致无法编译通过,
3.解决
所以我们在写when时尽可能的加上else,或者穷举所有可能出现的情况。
Kotlin版本升级导致编译报错:'when' expression must be exhaustive, add necessary 'xxx', 'null' branches or 'else' branch instead
Kotlin1.7之后when强制封闭问题,1.6及之前的版本只做Waring提示,1.7之后变成了Error导致无法编译通过,
所以我们在写when时尽可能的加上else,或者穷举所有可能出现的情况。