KT-10295: long enum (sealed) special case
This commit is contained in:
@@ -411,11 +411,14 @@ object Renderers {
|
||||
append("(").append(renderTypes(inferenceErrorData.valueArgumentsTypes)).append(")")
|
||||
}
|
||||
|
||||
private val WHEN_MISSING_LIMIT = 7
|
||||
|
||||
@JvmField val RENDER_WHEN_MISSING_CASES: Renderer<List<WhenMissingCase>> = Renderer {
|
||||
if (!it.hasUnknown) {
|
||||
val list = it.map { "'$it'" }.joinToString(", ")
|
||||
val list = it.take(WHEN_MISSING_LIMIT).map { "'$it'" }.joinToString(", ")
|
||||
val branches = if (it.size > 1) "branches" else "branch"
|
||||
"$list $branches or 'else' branch instead"
|
||||
val others = if (it.size > WHEN_MISSING_LIMIT) ", ..." else ""
|
||||
"$list$others $branches or 'else' branch instead"
|
||||
}
|
||||
else {
|
||||
"'else' branch"
|
||||
|
||||
+8
@@ -28,6 +28,14 @@ fun whenOnEnum(c: Color) {
|
||||
}
|
||||
}
|
||||
|
||||
enum class EnumInt {
|
||||
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15
|
||||
}
|
||||
|
||||
fun whenOnLongEnum(i: EnumInt) = <error descr="[NO_ELSE_IN_WHEN] when expression must be exhaustive, add necessary 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', ... branches or 'else' branch instead">when</error> (i) {
|
||||
EnumInt.A7 -> 7
|
||||
}
|
||||
|
||||
sealed class Variant {
|
||||
object Singleton : Variant()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user