"is" over enum entry is now an error + new tests + test fixes

This commit is contained in:
Mikhail Glukhikh
2015-06-29 18:11:55 +03:00
parent e1d3b296e9
commit 848c2afdb4
11 changed files with 118 additions and 12 deletions
@@ -29,13 +29,13 @@ class TestLocal(val name: String, val executionType: ExecutionType) : Callable<S
override fun call(): String {
startSignal.await()
return when (executionType) {
is ExecutionType.LOCAL -> local()
is ExecutionType.NON_LOCAL_SIMPLE -> nonLocalSimple()
is ExecutionType.NON_LOCAL_EXCEPTION -> nonLocalWithException()
is ExecutionType.NON_LOCAL_FINALLY -> nonLocalWithFinally()
is ExecutionType.NON_LOCAL_EXCEPTION_AND_FINALLY -> nonLocalWithExceptionAndFinally()
is ExecutionType.NON_LOCAL_EXCEPTION_AND_FINALLY_WITH_RETURN -> nonLocalWithExceptionAndFinallyWithReturn()
is ExecutionType.NON_LOCAL_NESTED -> nonLocalNested()
ExecutionType.LOCAL -> local()
ExecutionType.NON_LOCAL_SIMPLE -> nonLocalSimple()
ExecutionType.NON_LOCAL_EXCEPTION -> nonLocalWithException()
ExecutionType.NON_LOCAL_FINALLY -> nonLocalWithFinally()
ExecutionType.NON_LOCAL_EXCEPTION_AND_FINALLY -> nonLocalWithExceptionAndFinally()
ExecutionType.NON_LOCAL_EXCEPTION_AND_FINALLY_WITH_RETURN -> nonLocalWithExceptionAndFinallyWithReturn()
ExecutionType.NON_LOCAL_NESTED -> nonLocalNested()
else -> "fail"
}
}
@@ -0,0 +1,6 @@
enum class MyEnum {
FIRST,
SECOND
}
fun foo(me: MyEnum): Boolean = if (me is <!IS_ENUM_ENTRY!>MyEnum.FIRST<!>) true else false
@@ -0,0 +1,37 @@
package
internal fun foo(/*0*/ me: MyEnum): kotlin.Boolean
internal final enum class MyEnum : kotlin.Enum<MyEnum> {
public enum entry FIRST : MyEnum {
private constructor FIRST()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry SECOND : MyEnum {
private constructor SECOND()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
private constructor MyEnum()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum>
}
@@ -0,0 +1,6 @@
enum class MyEnum {
FIRST,
SECOND
}
fun foo(me: MyEnum): Boolean = me is <!IS_ENUM_ENTRY!>MyEnum.FIRST<!>
@@ -0,0 +1,37 @@
package
internal fun foo(/*0*/ me: MyEnum): kotlin.Boolean
internal final enum class MyEnum : kotlin.Enum<MyEnum> {
public enum entry FIRST : MyEnum {
private constructor FIRST()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry SECOND : MyEnum {
private constructor SECOND()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
private constructor MyEnum()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum>
}
@@ -4,8 +4,8 @@ enum class MyEnum {
fun foo(x: MyEnum): Int {
return when (x) {
is MyEnum.A -> 1
is MyEnum.B -> 2
is MyEnum.C -> 3
is <!IS_ENUM_ENTRY!>MyEnum.A<!> -> 1
is <!IS_ENUM_ENTRY!>MyEnum.B<!> -> 2
is <!IS_ENUM_ENTRY!>MyEnum.C<!> -> 3
}
}
@@ -5,7 +5,7 @@ enum class MyEnum {
fun foo(x: MyEnum): Int {
return when (x) {
MyEnum.A -> 1
is MyEnum.B -> 2
is MyEnum.C -> 3
is <!IS_ENUM_ENTRY!>MyEnum.B<!> -> 2
is <!IS_ENUM_ENTRY!>MyEnum.C<!> -> 3
}
}