Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/equalsEvaluationOrderInlineClass.kt
T
Mark Punzalan 802beb49a6 Use TypeSubstitutor to get the substituted underlying type for inline
classes, instead of MemberScope.

The primary motivation was to fix issues around type-mapping for inline
classes in FIR, which uses wrapped descriptors that have empty
MemberScopes.
2020-06-04 17:03:55 +03:00

34 lines
617 B
Kotlin
Vendored

// !LANGUAGE: +InlineClasses
inline class Inner(val x: Int)
inline class A(val x: Inner)
var i = 0
fun set1(): A {
i = 1
return A(Inner(0))
}
fun test1(n: Int): A {
if (i != 1)
throw IllegalStateException("Fail $n")
i = 0
return A(Inner(0))
}
fun set1Boxed(): Any? = set1()
fun test1Boxed(n: Int): Any? = test1(n)
fun box(): String {
try {
set1() == test1(1)
set1Boxed() == test1(2)
set1() == test1Boxed(3)
set1Boxed() == test1Boxed(4)
} catch (e: IllegalStateException) {
return e.message ?: "Fail no message"
}
return "OK"
}