New enum syntax: Short constructor syntax introduced for entries, optional commas between entries, semicolon after entries. #KT-7605 Fixed.
Grammar changed accordingly. Semicolons prohibited after an entry except the last one. Only one initializer is allowed per entry. EnumReferenceExpression AST node introduced. Some tests fixed, a pair of new tests written. Kotlin code inside project fixed. Formatter and intendation tests fixed accordingly. Stub version is incremented.
This commit is contained in:
@@ -5,6 +5,6 @@ fun box() = Context.OsType.OK.toString()
|
||||
object Context
|
||||
{
|
||||
public enum class OsType {
|
||||
WIN2000; WINDOWS; MACOSX; LINUX; OTHER; OK
|
||||
WIN2000, WINDOWS, MACOSX, LINUX, OTHER, OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
enum class Color(val rgb: Int) {
|
||||
RED(0xff0000),
|
||||
GREEN(0x00ff00),
|
||||
BLUE(0x0000ff);
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
return Color.RED.rgb + Color.GREEN.rgb + Color.BLUE.rgb
|
||||
}
|
||||
|
||||
fun box() = if (foo() == 0xffffff) "OK" else "Fail: ${foo()}"
|
||||
@@ -5,8 +5,8 @@ public class Context
|
||||
companion object
|
||||
{
|
||||
public enum class OsType {
|
||||
LINUX;
|
||||
OTHER
|
||||
LINUX,
|
||||
OTHER;
|
||||
}
|
||||
|
||||
public val operatingSystemType: OsType
|
||||
|
||||
Reference in New Issue
Block a user