Hello, I have this following test that passes in a...
# multiplatform
s
Hello, I have this following test that passes in all other platforms but
iosSimulatorArm64
and
macosArm64
but passes on
jvm
,
iosX64
and
macosX64
. Is this a known issue? I didn't see any related tickets
c
What is the issue? There’s no error / output / stack trace provided.
s
oh sorry... looks like the error didn't post. trying again
Instead of throwing the
ClassCastException
those two platforms are actually returning the instance as if it can be casted. So actually the assertion fails because it is not null.
Copy code
kotlin.AssertionError: Expected an exception of kotlin.ClassCastException to be thrown, but was kotlin.AssertionError: Expected value to be null, but was: <CastTest.Motorcycle@54e4070>.
	at kotlin.Error#<init>(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:14)
	at kotlin.AssertionError#<init>(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:134)
	at kotlin.test.DefaultAsserter#fail(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/DefaultAsserter.kt:21)
	at kotlin.test.Asserter#fail(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Assertions.kt:643)
	at kotlin.test#checkResultIsFailure(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/test/Assertions.kt:36)
	at <global>.CastTest#should(/Users/saud.khan/playground/castTest/src/commonTest/kotlin/CastTest.kt:42)
	at $CastTest$test$0.$should(/Users/saud.khan/playground/castTest/src/commonTest/kotlin/CastTest.kt:34)
	at $CastTest$test$0.$should(/Users/saud.khan/playground/castTest/src/commonTest/kotlin/CastTest.kt:34)
	at kotlin.Function1#invoke(/Users/teamcity/.gradle/daemon/8.4/[K][Suspend]Functions:1)
	at kotlin.native.internal.test.BaseClassSuite.TestCase#doRun(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestSuite.kt:177)
	at kotlin.native.internal.test.TestCase#doRun(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestSuite.kt:44)
	at kotlin.native.internal.test.TestCase#run(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestSuite.kt:52)
	at kotlin.native.internal.test.TestCase#run(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestSuite.kt:49)
	at kotlin.native.internal.test.TestRunner.run#internal(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestRunner.kt:263)
	at kotlin.native.internal.test.TestRunner.runIteration#internal(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestRunner.kt:289)
	at kotlin.native.internal.test.TestRunner#run(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/TestRunner.kt:304)
	at kotlin.native.internal.test#testLauncherEntryPoint(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt:33)
	at kotlin.native.internal.test#main(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt:38)
	at <global>.Konan_start(/Users/saud.khan/.gradle/daemon/8.8/entryPointOwner:1)
	at <global>.Init_and_run_start(Unknown Source)
	at <global>.0x0(Unknown Source)
	at <global>.0x0(Unknown Source)
	at <global>.0x0(Unknown Source)
	at kotlin.Error#<init>(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:14)
	at kotlin.AssertionError#<init>(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:132)
	at kotlin.test.DefaultAsserter#fail(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/DefaultAsserter.kt:16)
	at kotlin.test.Asserter#fail(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Assertions.kt:634)
	at kotlin.test.Asserter#assertTrue(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Assertions.kt:652)
	at kotlin.test.Asserter#assertTrue(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Assertions.kt:650)
	at kotlin.test.Asserter#assertNull(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Assertions.kt:707)
	at kotlin.test.Asserter#assertNull(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Assertions.kt:706)
	at kotlin.test#assertNull(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Assertions.kt:159)
	at kotlin.test#assertNull$default(/opt/buildAgent/work/b2e1db4d8d903ca4/kotlin/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Assertions.kt:158)
	at <global>.CastTest#should(/Users/saud.khan/playground/castTest/src/commonTest/kotlin/CastTest.kt:41)
	at $CastTest$test$0.$should(/Users/saud.khan/playground/castTest/src/commonTest/kotlin/CastTest.kt:34)
Even making the
cast
function
inline
fails the same way. but it doesn't do that if we replace the
cast
function to directly cast instead:
Copy code
val hasDoors: HasDoors = motorcycle as HasDoors
Also forgot to add that it happens on both Kotlin 2.0 and 1.9.23
Looks like it is impacting all natives and only if we use a generic cast function. Added a ticket: https://youtrack.jetbrains.com/issue/KT-69675/Native-builds-does-not-throw-ClassCastException