Add test for KT-19246
The issue was fixed by https://github.com/jetbrains/kotlin/commit/904c7f9c640ccb38c0becb40bd3b5dad3ac921bd
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
enum class ResultType constructor(val reason: String) {
|
||||
SOMETHING("123"),
|
||||
OK("OK"),
|
||||
UNKNOWN("FAIL");
|
||||
|
||||
companion object {
|
||||
fun getByVal(reason: String): ResultType {
|
||||
return ResultType.values().firstOrDefault({ it.reason == reason }, UNKNOWN)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T> Array<out T>.firstOrDefault(predicate: (T) -> Boolean, default: T): T {
|
||||
return firstOrNull(predicate) ?: default
|
||||
}
|
||||
|
||||
fun box(): String = ResultType.getByVal("OK").reason
|
||||
Reference in New Issue
Block a user