Tests: use helper function to assert compile-time and run-time type check
To cleanup warnings about useless cast or type check that is always true.
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
package test
|
||||
|
||||
import kotlin.internal.NoInfer
|
||||
import kotlin.test.fail
|
||||
|
||||
// just a static type check
|
||||
fun <T> assertStaticTypeIs(@Suppress("UNUSED_PARAMETER") value: T) {}
|
||||
fun <T> assertStaticTypeIs(@Suppress("UNUSED_PARAMETER") value: @NoInfer T) {}
|
||||
|
||||
inline fun <reified T> assertStaticAndRuntimeTypeIs(value: @NoInfer T) {
|
||||
@Suppress("USELESS_CAST")
|
||||
if ((value as Any?) !is T) {
|
||||
fail("Expected value $value to have ${T::class} type")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user