Prohibit to use enum entry as a type
#KT-14179 Fixed
This commit is contained in:
+41
-21
@@ -1,34 +1,54 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
enum class Color { RED }
|
||||
enum class Color {
|
||||
RED {
|
||||
fun <T : <!ENUM_ENTRY_AS_TYPE, FINAL_UPPER_BOUND!>RED<!>> simpleName(): <!ENUM_ENTRY_AS_TYPE!>RED<!> = null!!
|
||||
}
|
||||
}
|
||||
|
||||
class MyColor(val x: <!ENUM_ENTRY_AS_TYPE!>Color.RED<!>, y: <!ENUM_ENTRY_AS_TYPE!>Color.RED<!>) : <!ENUM_ENTRY_AS_TYPE!>Color.RED<!> {
|
||||
class MyColor(val x: Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>, y: Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>) : Color.<!ENUM_ENTRY_AS_TYPE!>RED<!> {
|
||||
|
||||
var z: <!ENUM_ENTRY_AS_TYPE!>Color.RED<!> = <!TYPE_MISMATCH!>Color.RED<!>
|
||||
set(arg: <!ENUM_ENTRY_AS_TYPE!>Color.RED<!>) { z = arg }
|
||||
var z: Color.<!ENUM_ENTRY_AS_TYPE!>RED<!> = <!TYPE_MISMATCH!>Color.RED<!>
|
||||
set(arg: Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>) { z = arg }
|
||||
|
||||
fun foo(arg: <!ENUM_ENTRY_AS_TYPE!>Color.RED<!>): <!ENUM_ENTRY_AS_TYPE!>Color.RED<!> = arg
|
||||
fun foo(arg: Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>): Color.<!ENUM_ENTRY_AS_TYPE!>RED<!> = arg
|
||||
|
||||
fun bar(): <!ENUM_ENTRY_AS_TYPE!>Color.RED<!> {
|
||||
class Local : <!ENUM_ENTRY_AS_TYPE!>Color.RED<!>
|
||||
fun local(arg: <!ENUM_ENTRY_AS_TYPE!>Color.RED<!>): <!ENUM_ENTRY_AS_TYPE!>Color.RED<!> = arg
|
||||
val temp: <!ENUM_ENTRY_AS_TYPE!>Color.RED<!> = <!TYPE_MISMATCH!>Color.RED<!>
|
||||
temp <!USELESS_CAST!>as? <!ENUM_ENTRY_AS_TYPE!>Color.RED<!><!>
|
||||
if (temp is <!IS_ENUM_ENTRY!>Color.RED<!>) {
|
||||
return temp <!USELESS_CAST!>as <!ENUM_ENTRY_AS_TYPE!>Color.RED<!><!>
|
||||
}
|
||||
val obj = object : <!ENUM_ENTRY_AS_TYPE!>Color.RED<!> {}
|
||||
if (obj is <!IS_ENUM_ENTRY!>Color.RED<!>) {
|
||||
return obj
|
||||
}
|
||||
fun bar(): Color.<!ENUM_ENTRY_AS_TYPE!>RED<!> {
|
||||
class Local : Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>
|
||||
fun local(arg: Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>): Color.<!ENUM_ENTRY_AS_TYPE!>RED<!> = arg
|
||||
val temp: Color.<!ENUM_ENTRY_AS_TYPE!>RED<!> = <!TYPE_MISMATCH!>Color.RED<!>
|
||||
temp <!USELESS_CAST!>as? Color.<!ENUM_ENTRY_AS_TYPE!>RED<!><!>
|
||||
if (temp is <!IS_ENUM_ENTRY!>Color.<!ENUM_ENTRY_AS_TYPE!>RED<!><!>) {
|
||||
return temp <!USELESS_CAST!>as Color.<!ENUM_ENTRY_AS_TYPE!>RED<!><!>
|
||||
}
|
||||
val obj = object : Color.<!ENUM_ENTRY_AS_TYPE!>RED<!> {}
|
||||
if (obj is <!IS_ENUM_ENTRY!>Color.<!ENUM_ENTRY_AS_TYPE!>RED<!><!>) {
|
||||
return obj
|
||||
}
|
||||
return <!TYPE_MISMATCH!>Color.RED<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun create(): Array<<!ENUM_ENTRY_AS_TYPE!>Color.RED<!>>? = null
|
||||
fun create(): Array<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>>? = null
|
||||
|
||||
interface Your<T : <!ENUM_ENTRY_AS_TYPE!>Color.RED<!>>
|
||||
interface Your<T : <!FINAL_UPPER_BOUND!>Color.<!ENUM_ENTRY_AS_TYPE!>RED<!><!>>
|
||||
|
||||
class His : Your<<!ENUM_ENTRY_AS_TYPE!>Color.RED<!>>
|
||||
class His : Your<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>>
|
||||
|
||||
fun <T : <!ENUM_ENTRY_AS_TYPE!>Color.RED<!>> otherCreate(): Array<T>? = null
|
||||
fun <T : <!FINAL_UPPER_BOUND!>Color.<!ENUM_ENTRY_AS_TYPE!>RED<!><!>> otherCreate(): Array<T>? = null
|
||||
|
||||
typealias RedAlias = Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>
|
||||
|
||||
typealias ArrayOfEnumEntry = Array<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>>
|
||||
|
||||
typealias ArrayOfEnumEntryAlias = Array<RedAlias>
|
||||
|
||||
fun <T> bar(a: Any): T = <!UNCHECKED_CAST!>a as T<!>
|
||||
|
||||
fun <T> foo() {
|
||||
foo<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>>()
|
||||
foo<RedAlias>()
|
||||
bar<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>>(Color.RED)
|
||||
}
|
||||
|
||||
fun Array<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>>.foo(entries: Array<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>>): Array<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>> = null!!
|
||||
@@ -1,7 +1,10 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> bar(/*0*/ a: kotlin.Any): T
|
||||
public fun create(): kotlin.Array<Color.RED>?
|
||||
public fun </*0*/ T> foo(): kotlin.Unit
|
||||
public fun </*0*/ T : Color.RED> otherCreate(): kotlin.Array<T>?
|
||||
public fun kotlin.Array<Color.RED>.foo(/*0*/ entries: kotlin.Array<Color.RED>): kotlin.Array<Color.RED>
|
||||
|
||||
public final enum class Color : kotlin.Enum<Color> {
|
||||
enum entry RED
|
||||
@@ -43,6 +46,7 @@ public final class MyColor : Color.RED {
|
||||
public final fun foo(/*0*/ arg: Color.RED): Color.RED
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<Color!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun </*0*/ T : Color.RED> simpleName(): Color.RED
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@@ -51,3 +55,6 @@ public interface Your</*0*/ T : Color.RED> {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
public typealias ArrayOfEnumEntry = kotlin.Array<Color.RED>
|
||||
public typealias ArrayOfEnumEntryAlias = kotlin.Array<RedAlias>
|
||||
public typealias RedAlias = Color.RED
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@ enum class MyEnum {
|
||||
SECOND
|
||||
}
|
||||
|
||||
fun foo(me: MyEnum): Boolean = if (me is <!IS_ENUM_ENTRY!>MyEnum.FIRST<!>) true else false
|
||||
fun foo(me: MyEnum): Boolean = if (me is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>FIRST<!><!>) true else false
|
||||
@@ -2,4 +2,4 @@ enum class E {
|
||||
ENTRY
|
||||
}
|
||||
|
||||
class A : <!ENUM_ENTRY_AS_TYPE!>E.ENTRY<!>
|
||||
class A : E.<!ENUM_ENTRY_AS_TYPE!>ENTRY<!>
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@ enum class MyEnum {
|
||||
SECOND
|
||||
}
|
||||
|
||||
fun foo(me: MyEnum): Boolean = me is <!IS_ENUM_ENTRY!>MyEnum.FIRST<!>
|
||||
fun foo(me: MyEnum): Boolean = me is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>FIRST<!><!>
|
||||
@@ -4,8 +4,8 @@ enum class MyEnum {
|
||||
|
||||
fun foo(x: MyEnum): Int {
|
||||
return when (x) {
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.A<!> -> 1
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.B<!> -> 2
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.C<!> -> 3
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>A<!><!> -> 1
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>B<!><!> -> 2
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>C<!><!> -> 3
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ enum class MyEnum {
|
||||
fun foo(x: MyEnum): Int {
|
||||
return when (x) {
|
||||
MyEnum.A -> 1
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.B<!> -> 2
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.C<!> -> 3
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>B<!><!> -> 2
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>C<!><!> -> 3
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user