Recompile all enum usages when new entry is added

This commit is contained in:
Alexey Tsvetkov
2015-12-23 15:27:58 +03:00
parent e7f8d7103f
commit 0cf2928761
16 changed files with 129 additions and 4 deletions
@@ -0,0 +1,4 @@
enum class Enum {
A,
B
}
@@ -0,0 +1,5 @@
enum class Enum {
A,
B,
C
}
@@ -0,0 +1,27 @@
Cleaning output files:
out/production/module/Enum.class
End of files
Compiling files:
src/Enum.kt
End of files
Cleaning output files:
out/production/module/GetRandomEnumEntryKt.class
out/production/module/META-INF/module.kotlin_module
out/production/module/UseKt.class
End of files
Compiling files:
src/getRandomEnumEntry.kt
src/use.kt
End of files
COMPILATION FAILED
'when' expression must be exhaustive or contain an 'else' branch
Cleaning output files:
out/production/module/Enum.class
End of files
Compiling files:
src/Enum.kt
src/getRandomEnumEntry.kt
src/use.kt
End of files
@@ -0,0 +1,6 @@
import java.util.Random
fun getRandomEnumEntry() =
with (Enum.values()) {
get(Random().nextInt(size))
}
@@ -0,0 +1,7 @@
import Enum.*
fun use(e: Enum): String =
when (e) {
A -> "A"
B -> "B"
}
@@ -0,0 +1,8 @@
import Enum.*
fun use(e: Enum): String =
when (e) {
A -> "A"
B -> "B"
C -> "C"
}
@@ -0,0 +1,3 @@
fun useImplicit() {
println(use(getRandomEnumEntry()))
}