Fix enum delegate bug (KT-37503)

This commit is contained in:
Alexander Nozik 2020-03-25 19:06:08 +03:00
parent e0aab57953
commit 5c3d51de58
2 changed files with 5 additions and 2 deletions

View File

@ -6,7 +6,7 @@ plugins {
id("scientifik.publish") version toolsVersion apply false id("scientifik.publish") version toolsVersion apply false
} }
val dataforgeVersion by extra("0.1.6-dev") val dataforgeVersion by extra("0.1.6-dev-1")
val bintrayRepo by extra("dataforge") val bintrayRepo by extra("dataforge")
val githubProject by extra("dataforge-core") val githubProject by extra("dataforge-core")

View File

@ -171,7 +171,10 @@ fun Configurable.float(default: Float, key: Name? = null): ReadWriteProperty<Any
inline fun <reified E : Enum<E>> Configurable.enum( inline fun <reified E : Enum<E>> Configurable.enum(
default: E, key: Name? = null default: E, key: Name? = null
): ReadWriteProperty<Any?, E> = ): ReadWriteProperty<Any?, E> =
item(default, key).transform { item -> item?.string?.let { enumValueOf<E>(it) } ?: default } item(default, key).transform { item -> item?.string?.let {str->
@Suppress("USELESS_CAST")
enumValueOf<E>(str) as E
} ?: default }
/* /*
* Extra delegates for special cases * Extra delegates for special cases