uli
05/31/2017, 4:55 PMtypealias NumberType = Double
inline fun Number.toNumberType() = when (NumberType::class) {
Double::class -> this.toDouble() as NumberType
Float::class -> this.toFloat() as NumberType
Long::class -> this.toLong() as NumberType
Int::class -> this.toInt() as NumberType
Short::class -> this.toShort() as NumberType
Byte::class -> this.toByte() as NumberType
else -> throw IllegalArgumentException("NumberType must be in [Double, Float, Long, Int, Short, Byte]")
}
Looking at the decompiled java code, it generates all when branches, not noticing, that only one will ever be selected.
Is this expected or should i report?