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.
This commit is contained in:
Tianyu Geng
2021-06-08 15:14:41 -07:00
committed by Mikhail Glukhikh
parent 6dc75c2e51
commit c648356887
18 changed files with 157 additions and 45 deletions
@@ -13,8 +13,8 @@ enum class MyEnum {
fun foo(x: MyEnum): Int {
return <!NO_ELSE_IN_WHEN!>when<!> (x) {
is <!UNRESOLVED_REFERENCE!>MyEnum.A<!> -> 1
is <!UNRESOLVED_REFERENCE!>MyEnum.B<!> -> 2
is <!UNRESOLVED_REFERENCE!>MyEnum.C<!> -> 3
is <!IS_ENUM_ENTRY!>MyEnum.A<!> -> 1
is <!IS_ENUM_ENTRY!>MyEnum.B<!> -> 2
is <!IS_ENUM_ENTRY!>MyEnum.C<!> -> 3
}
}
@@ -15,7 +15,7 @@ enum class MyEnum {
fun foo(x: MyEnum): Int {
return <!NO_ELSE_IN_WHEN!>when<!> (x) {
MyEnum.A -> 1
is <!UNRESOLVED_REFERENCE!>MyEnum.B<!> -> 2
is <!UNRESOLVED_REFERENCE!>MyEnum.C<!> -> 3
is <!IS_ENUM_ENTRY!>MyEnum.B<!> -> 2
is <!IS_ENUM_ENTRY!>MyEnum.C<!> -> 3
}
}