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:
Ilya Gorbunov
2017-12-25 21:07:20 +03:00
parent ecd42f14b3
commit 053f3b6ac0
7 changed files with 79 additions and 55 deletions
+11 -1
View File
@@ -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")
}
}