1 package kotlinx.coroutines 2 3 import kotlinx.coroutines.testing.* 4 import kotlinx.coroutines.* 5 import org.junit.Test 6 import kotlin.test.* 7 8 9 class NoParamAssertionsTest : TestBase() { 10 // These tests verify that we haven't omitted "-Xno-param-assertions" and "-Xno-receiver-assertions" 11 12 @Test testNoReceiverAssertionnull13 fun testNoReceiverAssertion() { 14 val function: (ThreadLocal<Int>, Int) -> ThreadContextElement<Int> = ThreadLocal<Int>::asContextElement 15 @Suppress("UNCHECKED_CAST") 16 val unsafeCasted = function as ((ThreadLocal<Int>?, Int) -> ThreadContextElement<Int>) 17 unsafeCasted(null, 42) 18 } 19 20 @Test testNoParamAssertionnull21 fun testNoParamAssertion() { 22 val function: (ThreadLocal<Any>, Any) -> ThreadContextElement<Any> = ThreadLocal<Any>::asContextElement 23 @Suppress("UNCHECKED_CAST") 24 val unsafeCasted = function as ((ThreadLocal<Any?>?, Any?) -> ThreadContextElement<Any>) 25 unsafeCasted(ThreadLocal.withInitial { Any() }, null) 26 } 27 } 28