mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 08:31:29 +00:00
When we have a nullable inline class value with non-null underlying type, corresponding value in unboxed representation is nullable. E.g.: inline class Str(val value: String) fun test(s: Str?) = listOf(s) Here 'test(s: Str?)' accepts nullable 'java.lang.String' as a parameter. When boxing/unboxing nullable values of such inline classes, take care of nulls. #KT-26052 Fixed Target versions 1.3-M2
20 lines
479 B
Kotlin
Vendored
20 lines
479 B
Kotlin
Vendored
// !LANGUAGE: +InlineClasses
|
|
// IGNORE_BACKEND: JVM_IR, JS
|
|
|
|
inline class Z(val value: Int)
|
|
|
|
fun eq(a: Z?, b: Z) = a == b
|
|
|
|
fun eqq(a: Z, b: Z?) = a == b
|
|
|
|
fun box(): String {
|
|
if (!eq(Z(1), Z(1))) throw AssertionError()
|
|
if (eq(Z(1), Z(2))) throw AssertionError()
|
|
if (eq(null, Z(0))) throw AssertionError()
|
|
|
|
if (!eqq(Z(1), Z(1))) throw AssertionError()
|
|
if (eqq(Z(1), Z(2))) throw AssertionError()
|
|
if (eqq(Z(0), null)) throw AssertionError()
|
|
|
|
return "OK"
|
|
} |