Files
kotlin-fork/compiler/testData/diagnostics/tests/when/ExhaustiveEnumMixed.fir.kt
T
Tianyu Geng c648356887 FIR: report ENUM_ENTRY_AS_TYPE and IS_ENUM_TYPE
These two diagnostics are similar: both are reported on type references
to enum entries. But `IS_ENUM_TYPE` is reported if the type ref is an
operand of `is` operator. To pass along this contextual information, a
boolean is added to FirSpecificTypeResolverTransformer.
2021-07-22 20:39:56 +03:00

22 lines
592 B
Kotlin
Vendored

/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-313
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
* expressions, when-expression -> paragraph 6 -> sentence 1
* expressions, when-expression -> paragraph 6 -> sentence 5
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
*/
enum class MyEnum {
A, B, C
}
fun foo(x: MyEnum): Int {
return <!NO_ELSE_IN_WHEN!>when<!> (x) {
MyEnum.A -> 1
is <!IS_ENUM_ENTRY!>MyEnum.B<!> -> 2
is <!IS_ENUM_ENTRY!>MyEnum.C<!> -> 3
}
}