Support generating computable properties inside inline classes
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class Foo(val x: Int) {
|
||||
fun empty() = ""
|
||||
fun withParam(a: String) = a
|
||||
fun withInlineClassParam(f: Foo) = f.toString()
|
||||
|
||||
fun test(): String {
|
||||
val a = empty()
|
||||
val b = withParam("hello")
|
||||
val c = withInlineClassParam(this)
|
||||
return a + b + c
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return x.toString()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val f = Foo(12)
|
||||
return if (f.test() != "hello12") "fail" else "OK"
|
||||
return "OK"
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class UIntArray(private val intArray: IntArray) {
|
||||
val size get() = intArray.size
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val array = UIntArray(intArrayOf(1, 2, 3))
|
||||
return if (array.size != 3) "fail" else "OK"
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class Foo(val x: Int) {
|
||||
val prop: Int get() = 1
|
||||
val asThis: Foo get() = this
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
@kotlin.Metadata
|
||||
public final static class Foo$Erased {
|
||||
public final static @org.jetbrains.annotations.NotNull method box(p0: int): Foo
|
||||
public final static method getAsThis(p0: int): int
|
||||
public final static method getProp(p0: int): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class Foo {
|
||||
private final field x: int
|
||||
public method <init>(p0: int): void
|
||||
public final method getAsThis(): int
|
||||
public final method getProp(): int
|
||||
public final method getX(): int
|
||||
public final method unbox(): int
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class UInt private constructor(val value: Int)
|
||||
compiler/testData/codegen/bytecodeListing/inlineClasses/shapeOfInlineClassWithPrivateConstructor.txt
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
@kotlin.Metadata
|
||||
public final static class UInt$Erased {
|
||||
public final static @org.jetbrains.annotations.NotNull method box(p0: int): UInt
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class UInt {
|
||||
private final field value: int
|
||||
private method <init>(p0: int): void
|
||||
public final method getValue(): int
|
||||
public final method unbox(): int
|
||||
}
|
||||
Reference in New Issue
Block a user