Files
kotlin-fork/compiler/testData/asJava/ultraLightClasses/enums.kt
T
Denis Zharkov 206466f6ce Support enums in ultra-light classes
There's no need to add "values"/"valueOf" methods for them
(see com.intellij.psi.impl.compiled.StubBuildingVisitor#visitMethod that ignores them too)

We already have tests that check enum entries/synthetic methods
are properly resolved in Java:
idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/*Enum*
2018-11-26 11:36:28 +03:00

42 lines
783 B
Kotlin
Vendored

import java.util.function.*
enum class Direction {
NORTH, SOUTH, WEST, EAST
}
enum class Color(val rgb: Int = 5) {
RED(0xFF0000),
GREEN(0x00FF00),
BLUE("0x0000FF");
constructor(y: String) : this(y.toInt())
}
enum class ProtocolState {
WAITING {
override fun signal() = TALKING
},
TALKING {
override fun signal() = WAITING
};
abstract fun signal(): ProtocolState
}
enum class IntArithmetics : BinaryOperator<Int>, IntBinaryOperator {
PLUS {
override fun apply(t: Int, u: Int): Int = t + u
},
TIMES {
override fun apply(t: Int, u: Int): Int = t * u
};
override fun applyAsInt(t: Int, u: Int) = apply(t, u)
}
class C {
val enumConst: Direction? = Direction.EAST
}