bloder
04/17/2019, 10:43 PMinline class what happens if I have an inline class as parameter of another inline class?
inline class Bar(val number: Int)
inline class Foo(val bar: Bar)
Foo(Bar(1)) == 1?bdawg.io
04/17/2019, 10:48 PMFoo(Bar(1)).bar.number == 1 and then the compiler should unwrap it to just be 1 == 1 if your use case is really that simplebloder
04/17/2019, 10:50 PMbdawg.io
04/17/2019, 11:07 PMinline class Bar(val number: Int)
inline class Foo(val bar: Bar)
fun test() {
if (Foo(Bar(1)).bar.number == 1) {
println("YES")
}
} and it results in the following code in Java public final class Bar {
public static int constructor-impl(int number) { return number; }
}
public final class Foo {
public static int constructor-impl(int bar) { return bar; }
}
public static final void test() {
if (Foo.constructor-impl(Bar.constructor-impl(1)) == 1) {
System.out.println("YES");
}
} The key takeway that constructor-impl is receiving and returning an integer primitive and not boxed objectsbloder
04/17/2019, 11:12 PM