[IR] Add MFVC generation tests
#KT-1179
This commit is contained in:
committed by
teamcity
parent
73b0fac657
commit
a788433aac
@@ -0,0 +1,26 @@
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
@JvmInline
|
||||
value class DPoint(val x: Double, val y: Double)
|
||||
|
||||
class A(var x: DPoint) {
|
||||
init { x = DPoint(2.0, 3.0) }
|
||||
}
|
||||
|
||||
class B() {
|
||||
var a = DPoint(4.0, 5.0)
|
||||
val b = a
|
||||
init { a = DPoint(6.0, 7.0) }
|
||||
val c = a
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
require(A(DPoint(0.0, 1.0)).x == DPoint(2.0, 3.0)) { "No init used" }
|
||||
require(B().a == DPoint(6.0, 7.0)) { "No init used" }
|
||||
require(B().b == DPoint(4.0, 5.0)) { "Wrong init order used" }
|
||||
require(B().c == DPoint(6.0, 7.0)) { "Wrong init order used" }
|
||||
return "OK"
|
||||
}
|
||||
+2
-2
@@ -66,7 +66,7 @@ fun <T : List<Int>> h(r: R<T>) {
|
||||
g(r.z)
|
||||
f(r)
|
||||
r
|
||||
C(2, B(3U), "") // todo fix box
|
||||
C(2, B(3U), "")
|
||||
D(C(2, B(3U), ""))
|
||||
val x = D(C(2, B(3U), ""))
|
||||
var y = D(C(4, B(5U), "1"))
|
||||
@@ -172,4 +172,4 @@ fun equalsChecks(left: R<List<Int>>, right: R<List<Int>>) {
|
||||
|
||||
// todo add default parameters
|
||||
|
||||
fun box() = "OK"//.also { h(R(1, 2U, E(D(C(3, B(4U), "5"))), A(listOf(listOf(6))))) }
|
||||
fun box() = "OK"
|
||||
+34
-32
@@ -1,7 +1,7 @@
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class A {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field x: java.util.List
|
||||
private synthetic method <init>(p0: java.util.List): void
|
||||
public synthetic final static method box-impl(p0: java.util.List): A
|
||||
@@ -20,7 +20,7 @@ public final class A {
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class B {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
private final field x: int
|
||||
private synthetic method <init>(p0: int): void
|
||||
public synthetic final static method box-impl(p0: int): B
|
||||
@@ -38,7 +38,7 @@ public final class B {
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class Base1$DefaultImpls {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
public static @org.jetbrains.annotations.NotNull method getFakeOverrideMFVC(@org.jetbrains.annotations.NotNull p0: Base1): R
|
||||
public static method getFakeOverrideRegular(@org.jetbrains.annotations.NotNull p0: Base1): int
|
||||
public final inner class Base1$DefaultImpls
|
||||
@@ -46,7 +46,7 @@ public final class Base1$DefaultImpls {
|
||||
|
||||
@kotlin.Metadata
|
||||
public interface Base1 {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
public abstract @org.jetbrains.annotations.NotNull method getFakeOverrideMFVC(): R
|
||||
public abstract method getFakeOverrideRegular(): int
|
||||
public final inner class Base1$DefaultImpls
|
||||
@@ -54,20 +54,20 @@ public interface Base1 {
|
||||
|
||||
@kotlin.Metadata
|
||||
public interface Base2 {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
public abstract @org.jetbrains.annotations.NotNull method getL(): R
|
||||
public abstract method setL-Y_3tvh0(p0: int, p1: int, p2: int, p3: int, @org.jetbrains.annotations.NotNull p4: java.lang.String, @org.jetbrains.annotations.NotNull p5: java.util.List): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public interface Base3 {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
public abstract @org.jetbrains.annotations.NotNull method getZ(): E
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public interface Base4 {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
public abstract method getL(): java.lang.Object
|
||||
public abstract method setL(p0: java.lang.Object): void
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public interface Base4 {
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class C {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
private field x: int
|
||||
private field y: int
|
||||
private @org.jetbrains.annotations.NotNull field z: java.lang.String
|
||||
@@ -97,10 +97,26 @@ public final class C {
|
||||
public synthetic final method unbox-impl2(): java.lang.String
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class ComplexKt {
|
||||
// source: 'complex.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static method equalsChecks-GPBa7dw-yJnZWq8(p0: int, p1: int, p2: int, p3: int, @org.jetbrains.annotations.NotNull p4: java.lang.String, @org.jetbrains.annotations.NotNull p5: java.util.List, p6: int, p7: int, p8: int, p9: int, @org.jetbrains.annotations.NotNull p10: java.lang.String, @org.jetbrains.annotations.NotNull p11: java.util.List): void
|
||||
public final static method f-sUp7gFk-Y_3tvh0(p0: int, p1: int, p2: int, p3: int, @org.jetbrains.annotations.NotNull p4: java.lang.String, @org.jetbrains.annotations.NotNull p5: java.util.List): void
|
||||
public final static method g-sUp7gFk-ZTiL54U(p0: int, p1: int, @org.jetbrains.annotations.NotNull p2: java.lang.String): void
|
||||
public final static method h-sUp7gFk-Y_3tvh0(p0: int, p1: int, p2: int, p3: int, @org.jetbrains.annotations.NotNull p4: java.lang.String, @org.jetbrains.annotations.NotNull p5: java.util.List): void
|
||||
public final static method h1(): void
|
||||
public final static @org.jetbrains.annotations.NotNull method inlined-OsBMiQA(p0: int, p1: int, p2: int): D
|
||||
public final static @org.jetbrains.annotations.NotNull method notInlined-OsBMiQA(p0: int, p1: int, p2: int): D
|
||||
public final static method reuseBoxed(@org.jetbrains.annotations.NotNull p0: java.util.List): void
|
||||
public final static method supply(p0: boolean): void
|
||||
public final static method testVars(@org.jetbrains.annotations.NotNull p0: NotInlined): void
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class D {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
private field x$x: int
|
||||
private field x$y: int
|
||||
private @org.jetbrains.annotations.NotNull field x$z: java.lang.String
|
||||
@@ -127,7 +143,7 @@ public final class D {
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class E {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
private field x$x$x: int
|
||||
private field x$x$y: int
|
||||
private @org.jetbrains.annotations.NotNull field x$x$z: java.lang.String
|
||||
@@ -155,22 +171,22 @@ public final class E {
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class NotInlined {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
private @org.jetbrains.annotations.NotNull field l$t: java.util.List
|
||||
private field l$x: int
|
||||
private field l$y: int
|
||||
private field l$z$x$x$x$1: int
|
||||
private field l$z$x$x$x: int
|
||||
private field l$z$x$x$y: int
|
||||
private @org.jetbrains.annotations.NotNull field l$z$x$x$z: java.lang.String
|
||||
private @org.jetbrains.annotations.NotNull field withNonTrivialGettersWithBF$t: java.util.List
|
||||
private field withNonTrivialGettersWithBF$x: int
|
||||
private field withNonTrivialGettersWithBF$y: int
|
||||
private field withNonTrivialGettersWithBF$z$x$x$x$1: int
|
||||
private field withNonTrivialGettersWithBF$z$x$x$x: int
|
||||
private field withNonTrivialGettersWithBF$z$x$x$y: int
|
||||
private @org.jetbrains.annotations.NotNull field withNonTrivialGettersWithBF$z$x$x$z: java.lang.String
|
||||
private @org.jetbrains.annotations.NotNull field withNonTrivialSettersWithBF$t: java.util.List
|
||||
private field withNonTrivialSettersWithBF$x: int
|
||||
private field withNonTrivialSettersWithBF$y: int
|
||||
private field withNonTrivialSettersWithBF$z$x$x$x$1: int
|
||||
private field withNonTrivialSettersWithBF$z$x$x$x: int
|
||||
private field withNonTrivialSettersWithBF$z$x$x$y: int
|
||||
private @org.jetbrains.annotations.NotNull field withNonTrivialSettersWithBF$z$x$x$z: java.lang.String
|
||||
@@ -180,6 +196,7 @@ public final class NotInlined {
|
||||
public @org.jetbrains.annotations.NotNull method getFakeOverrideMFVC(): R
|
||||
public method getFakeOverrideRegular(): int
|
||||
public final @org.jetbrains.annotations.NotNull method getL$t(): java.util.List
|
||||
public final method getL$x(): int
|
||||
public final method getL$y(): int
|
||||
public final method getL$z$x$x$x(): int
|
||||
public final method getL$z$x$x$y(): int
|
||||
@@ -205,10 +222,10 @@ public final class NotInlined {
|
||||
@kotlin.jvm.JvmInline
|
||||
@kotlin.Metadata
|
||||
public final class R {
|
||||
// source: 'simple.kt'
|
||||
// source: 'complex.kt'
|
||||
private @org.jetbrains.annotations.NotNull field t: java.util.List
|
||||
private field x: int
|
||||
private field y: int
|
||||
private field z$x$x$x$1: int
|
||||
private field z$x$x$x: int
|
||||
private field z$x$x$y: int
|
||||
private @org.jetbrains.annotations.NotNull field z$x$x$z: java.lang.String
|
||||
@@ -223,6 +240,7 @@ public final class R {
|
||||
public method getFakeOverrideRegular(): int
|
||||
public static method getFakeOverrideRegular-impl(p0: int, p1: int, p2: int, p3: int, @org.jetbrains.annotations.NotNull p4: java.lang.String, @org.jetbrains.annotations.NotNull p5: java.util.List): int
|
||||
public final @org.jetbrains.annotations.NotNull method getT(): java.util.List
|
||||
public final method getX(): int
|
||||
public final method getY(): int
|
||||
public final method getZ$x$x$x(): int
|
||||
public final method getZ$x$x$y(): int
|
||||
@@ -241,19 +259,3 @@ public final class R {
|
||||
public synthetic final method unbox-impl4(): java.lang.String
|
||||
public synthetic final method unbox-impl5(): java.util.List
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class SimpleKt {
|
||||
// source: 'simple.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static method equalsChecks-GPBa7dw-yJnZWq8(p0: int, p1: int, p2: int, p3: int, @org.jetbrains.annotations.NotNull p4: java.lang.String, @org.jetbrains.annotations.NotNull p5: java.util.List, p6: int, p7: int, p8: int, p9: int, @org.jetbrains.annotations.NotNull p10: java.lang.String, @org.jetbrains.annotations.NotNull p11: java.util.List): void
|
||||
public final static method f-sUp7gFk-Y_3tvh0(p0: int, p1: int, p2: int, p3: int, @org.jetbrains.annotations.NotNull p4: java.lang.String, @org.jetbrains.annotations.NotNull p5: java.util.List): void
|
||||
public final static method g-sUp7gFk-ZTiL54U(p0: int, p1: int, @org.jetbrains.annotations.NotNull p2: java.lang.String): void
|
||||
public final static method h-sUp7gFk-Y_3tvh0(p0: int, p1: int, p2: int, p3: int, @org.jetbrains.annotations.NotNull p4: java.lang.String, @org.jetbrains.annotations.NotNull p5: java.util.List): void
|
||||
public final static method h1(): void
|
||||
public final static @org.jetbrains.annotations.NotNull method inlined-OsBMiQA(p0: int, p1: int, p2: int): D
|
||||
public final static @org.jetbrains.annotations.NotNull method notInlined-OsBMiQA(p0: int, p1: int, p2: int): D
|
||||
public final static method reuseBoxed(@org.jetbrains.annotations.NotNull p0: java.util.List): void
|
||||
public final static method supply(p0: boolean): void
|
||||
public final static method testVars(@org.jetbrains.annotations.NotNull p0: NotInlined): void
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
interface AbstractPoint<T> {
|
||||
val x: T
|
||||
val y: T
|
||||
}
|
||||
|
||||
@JvmInline
|
||||
value class DPoint(override val x: Double, override val y: Double): AbstractPoint<Double>
|
||||
|
||||
interface GenericMFVCHolder<T> {
|
||||
var p: T
|
||||
var p1: T
|
||||
}
|
||||
|
||||
interface GenericMFVCHolderWithMFVCUpperBound<T : DPoint> {
|
||||
var p: T
|
||||
var p1: T
|
||||
}
|
||||
|
||||
interface ReifiedMFVCHolder {
|
||||
var p: DPoint
|
||||
var p1: DPoint
|
||||
}
|
||||
|
||||
data class DataClassException(val value: Any?): Exception()
|
||||
|
||||
interface GenericMFVCHolderWithImpls<T> {
|
||||
var p: T
|
||||
get() = throw DataClassException(1)
|
||||
set(value) = throw DataClassException(2 to value)
|
||||
|
||||
var p1: T
|
||||
get() = throw DataClassException(3)
|
||||
set(value) = throw DataClassException(4 to value)
|
||||
}
|
||||
|
||||
interface GenericMFVCHolderWithMFVCUpperBoundWithImpls<T : DPoint> {
|
||||
var p: T
|
||||
get() = throw DataClassException(5)
|
||||
set(value) = throw DataClassException(6 to value)
|
||||
|
||||
var p1: T
|
||||
get() = throw DataClassException(7)
|
||||
set(value) = throw DataClassException(8 to value)
|
||||
}
|
||||
|
||||
interface ReifiedMFVCHolderWithImpls {
|
||||
var p: DPoint
|
||||
get() = throw DataClassException(9)
|
||||
set(value) = throw DataClassException(10 to value)
|
||||
|
||||
var p1: DPoint
|
||||
get() = throw DataClassException(11)
|
||||
set(value) = throw DataClassException(12 to value)
|
||||
}
|
||||
|
||||
class RealOverride(override var p: DPoint) : GenericMFVCHolder<DPoint>, ReifiedMFVCHolder, GenericMFVCHolderWithMFVCUpperBound<DPoint> {
|
||||
override var p1: DPoint
|
||||
get() = throw DataClassException(13)
|
||||
set(value) = throw DataClassException(14 to value)
|
||||
}
|
||||
|
||||
class GenericFakeOverride : GenericMFVCHolderWithImpls<DPoint>
|
||||
class ReifiedFakeOverride : ReifiedMFVCHolderWithImpls
|
||||
class GenericFakeOverrideWithMFVCUpperBound : GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>
|
||||
|
||||
|
||||
@JvmInline
|
||||
value class GenericFakeOverrideMFVC(val field1: Double, val field2: Double) : GenericMFVCHolderWithImpls<DPoint>
|
||||
@JvmInline
|
||||
value class ReifiedFakeOverrideMFVC(val field1: Double, val field2: Double) : ReifiedMFVCHolderWithImpls
|
||||
@JvmInline
|
||||
value class GenericFakeOverrideMFVCWithMFVCUpperBound(val field1: Double, val field2: Double) : GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>
|
||||
|
||||
|
||||
interface SomePointInterface<T> {
|
||||
var somethingRegular: Int
|
||||
|
||||
var somethingGeneric: T
|
||||
|
||||
var somethingMFVC: DPoint
|
||||
}
|
||||
|
||||
interface SomePointInterfaceWithMFVCBound<T : DPoint> {
|
||||
var somethingRegular: Int
|
||||
|
||||
var somethingGeneric: T
|
||||
|
||||
var somethingMFVC: DPoint
|
||||
}
|
||||
|
||||
@JvmInline
|
||||
value class DPointWithInterface(val x: Double, val y: Double) : SomePointInterface<DPoint>, SomePointInterfaceWithMFVCBound<DPoint> {
|
||||
override var somethingGeneric: DPoint
|
||||
get() = throw DataClassException(15)
|
||||
set(value) = throw DataClassException(16 to value)
|
||||
|
||||
override var somethingMFVC: DPoint
|
||||
get() = throw DataClassException(17)
|
||||
set(value) = throw DataClassException(18 to value)
|
||||
|
||||
override var somethingRegular: Int
|
||||
get() = throw DataClassException(19)
|
||||
set(value) = throw DataClassException(20 to value)
|
||||
}
|
||||
|
||||
|
||||
interface AbstractSegment<T> {
|
||||
val p1: T
|
||||
val p2: T
|
||||
}
|
||||
|
||||
@JvmInline
|
||||
value class DSegment(override val p1: DPoint, override val p2: DPoint): AbstractSegment<DPoint>
|
||||
|
||||
fun <T> equal(expected: () -> T, actual: () -> T) {
|
||||
val expectedResult = runCatching { expected() }
|
||||
val actualResult = runCatching { actual() }
|
||||
require(expectedResult == actualResult) { "Expected: $expectedResult\nActual: $actualResult" }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val dPoint = DPoint(1.0, 2.0)
|
||||
equal({ dPoint.toString() }, { (dPoint as Any).toString() })
|
||||
|
||||
equal({ dPoint.equals(dPoint) }, { dPoint.equals(dPoint as Any) })
|
||||
equal({ dPoint.equals(dPoint) }, { (dPoint as Any).equals(dPoint) })
|
||||
equal({ dPoint.equals(dPoint) }, { dPoint.equals(dPoint as Any) })
|
||||
equal({ dPoint.equals(dPoint) }, { (dPoint as Any).equals(dPoint as Any) })
|
||||
|
||||
val otherDPoint = DPoint(3.0, 4.0)
|
||||
equal({ dPoint.equals(otherDPoint) }, { dPoint.equals(otherDPoint as Any) })
|
||||
equal({ dPoint.equals(otherDPoint) }, { (dPoint as Any).equals(otherDPoint) })
|
||||
equal({ dPoint.equals(otherDPoint) }, { dPoint.equals(otherDPoint as Any) })
|
||||
equal({ dPoint.equals(otherDPoint) }, { (dPoint as Any).equals(otherDPoint as Any) })
|
||||
|
||||
equal({ dPoint.hashCode() }, { (dPoint as Any).hashCode() })
|
||||
|
||||
equal({ dPoint.x }, { (dPoint as AbstractPoint<Double>).x })
|
||||
equal({ dPoint.y }, { (dPoint as AbstractPoint<Double>).y })
|
||||
|
||||
|
||||
val realOverride = RealOverride(dPoint)
|
||||
|
||||
equal({ realOverride.p }, { (realOverride as GenericMFVCHolder<DPoint>).p })
|
||||
equal({ realOverride.p1 }, { (realOverride as GenericMFVCHolder<DPoint>).p1 })
|
||||
equal({ realOverride.p }, { (realOverride as ReifiedMFVCHolder).p })
|
||||
equal({ realOverride.p1 }, { (realOverride as ReifiedMFVCHolder).p1 })
|
||||
equal({ realOverride.p }, { (realOverride as GenericMFVCHolderWithMFVCUpperBound<DPoint>).p })
|
||||
equal({ realOverride.p1 }, { (realOverride as GenericMFVCHolderWithMFVCUpperBound<DPoint>).p1 })
|
||||
|
||||
equal({ realOverride.p = dPoint }, { (realOverride as GenericMFVCHolder<DPoint>).p = dPoint })
|
||||
equal({ realOverride.p1 = dPoint }, { (realOverride as GenericMFVCHolder<DPoint>).p1 = dPoint })
|
||||
equal({ realOverride.p = dPoint }, { (realOverride as ReifiedMFVCHolder).p = dPoint })
|
||||
equal({ realOverride.p1 = dPoint }, { (realOverride as ReifiedMFVCHolder).p1 = dPoint })
|
||||
equal({ realOverride.p = dPoint }, { (realOverride as GenericMFVCHolderWithMFVCUpperBound<DPoint>).p = dPoint })
|
||||
equal({ realOverride.p1 = dPoint }, { (realOverride as GenericMFVCHolderWithMFVCUpperBound<DPoint>).p1 = dPoint })
|
||||
|
||||
|
||||
val genericFakeOverride = GenericFakeOverride()
|
||||
|
||||
equal({ genericFakeOverride.p }, { (genericFakeOverride as GenericMFVCHolderWithImpls<DPoint>).p })
|
||||
equal({ genericFakeOverride.p1 }, { (genericFakeOverride as GenericMFVCHolderWithImpls<DPoint>).p1 })
|
||||
val reifiedFakeOverride = ReifiedFakeOverride()
|
||||
equal({ reifiedFakeOverride.p }, { (reifiedFakeOverride as ReifiedMFVCHolderWithImpls).p })
|
||||
equal({ reifiedFakeOverride.p1 }, { (reifiedFakeOverride as ReifiedMFVCHolderWithImpls).p1 })
|
||||
val genericFakeOverrideWithMFVCUpperBound = GenericFakeOverrideWithMFVCUpperBound()
|
||||
equal(
|
||||
{ genericFakeOverrideWithMFVCUpperBound.p },
|
||||
{ (genericFakeOverrideWithMFVCUpperBound as GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>).p }
|
||||
)
|
||||
equal(
|
||||
{ genericFakeOverrideWithMFVCUpperBound.p1 },
|
||||
{ (genericFakeOverrideWithMFVCUpperBound as GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>).p1 }
|
||||
)
|
||||
|
||||
equal({ genericFakeOverride.p = dPoint }, { (genericFakeOverride as GenericMFVCHolderWithImpls<DPoint>).p = dPoint })
|
||||
equal({ genericFakeOverride.p1 = dPoint }, { (genericFakeOverride as GenericMFVCHolderWithImpls<DPoint>).p1 = dPoint })
|
||||
equal({ reifiedFakeOverride.p = dPoint }, { (reifiedFakeOverride as ReifiedMFVCHolderWithImpls).p = dPoint })
|
||||
equal({ reifiedFakeOverride.p1 = dPoint }, { (reifiedFakeOverride as ReifiedMFVCHolderWithImpls).p1 = dPoint })
|
||||
equal(
|
||||
{ genericFakeOverrideWithMFVCUpperBound.p = dPoint },
|
||||
{ (genericFakeOverrideWithMFVCUpperBound as GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>).p = dPoint }
|
||||
)
|
||||
equal(
|
||||
{ genericFakeOverrideWithMFVCUpperBound.p1 = dPoint },
|
||||
{ (genericFakeOverrideWithMFVCUpperBound as GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>).p1 = dPoint }
|
||||
)
|
||||
|
||||
|
||||
val genericFakeOverrideMFVC = GenericFakeOverrideMFVC(1.0, 2.0)
|
||||
|
||||
equal({ genericFakeOverrideMFVC.p }, { (genericFakeOverrideMFVC as GenericMFVCHolderWithImpls<DPoint>).p })
|
||||
equal({ genericFakeOverrideMFVC.p1 }, { (genericFakeOverrideMFVC as GenericMFVCHolderWithImpls<DPoint>).p1 })
|
||||
|
||||
val reifiedFakeOverrideMFVC = ReifiedFakeOverrideMFVC(1.0, 2.0)
|
||||
equal({ reifiedFakeOverrideMFVC.p }, { (reifiedFakeOverrideMFVC as ReifiedMFVCHolderWithImpls).p })
|
||||
equal({ reifiedFakeOverrideMFVC.p1 }, { (reifiedFakeOverrideMFVC as ReifiedMFVCHolderWithImpls).p1 })
|
||||
|
||||
val genericFakeOverrideMFVCWithMFVCUpperBound = GenericFakeOverrideMFVCWithMFVCUpperBound(1.0, 2.0)
|
||||
equal(
|
||||
{ genericFakeOverrideMFVCWithMFVCUpperBound.p },
|
||||
{ (genericFakeOverrideMFVCWithMFVCUpperBound as GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>).p },
|
||||
)
|
||||
equal(
|
||||
{ genericFakeOverrideMFVCWithMFVCUpperBound.p1 },
|
||||
{ (genericFakeOverrideMFVCWithMFVCUpperBound as GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>).p1 },
|
||||
)
|
||||
|
||||
equal({ genericFakeOverrideMFVC.p = dPoint }, { (genericFakeOverrideMFVC as GenericMFVCHolderWithImpls<DPoint>).p = dPoint })
|
||||
equal({ genericFakeOverrideMFVC.p1 = dPoint }, { (genericFakeOverrideMFVC as GenericMFVCHolderWithImpls<DPoint>).p1 = dPoint })
|
||||
|
||||
equal({ reifiedFakeOverrideMFVC.p = dPoint }, { (reifiedFakeOverrideMFVC as ReifiedMFVCHolderWithImpls).p = dPoint })
|
||||
equal({ reifiedFakeOverrideMFVC.p1 = dPoint }, { (reifiedFakeOverrideMFVC as ReifiedMFVCHolderWithImpls).p1 = dPoint })
|
||||
|
||||
equal(
|
||||
{ genericFakeOverrideMFVCWithMFVCUpperBound.p = dPoint },
|
||||
{ (genericFakeOverrideMFVCWithMFVCUpperBound as GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>).p = dPoint },
|
||||
)
|
||||
equal(
|
||||
{ genericFakeOverrideMFVCWithMFVCUpperBound.p1 = dPoint },
|
||||
{ (genericFakeOverrideMFVCWithMFVCUpperBound as GenericMFVCHolderWithMFVCUpperBoundWithImpls<DPoint>).p1 = dPoint },
|
||||
)
|
||||
|
||||
|
||||
val dPointWithInterface = DPointWithInterface(1.0, 2.0)
|
||||
|
||||
equal({ dPointWithInterface.somethingGeneric }, { (dPointWithInterface as SomePointInterface<DPoint>).somethingGeneric })
|
||||
equal({ dPointWithInterface.somethingRegular }, { (dPointWithInterface as SomePointInterface<DPoint>).somethingRegular })
|
||||
equal({ dPointWithInterface.somethingMFVC }, { (dPointWithInterface as SomePointInterface<DPoint>).somethingMFVC })
|
||||
|
||||
equal({ dPointWithInterface.somethingGeneric }, { (dPointWithInterface as SomePointInterfaceWithMFVCBound<DPoint>).somethingGeneric })
|
||||
equal({ dPointWithInterface.somethingRegular }, { (dPointWithInterface as SomePointInterfaceWithMFVCBound<DPoint>).somethingRegular })
|
||||
equal({ dPointWithInterface.somethingMFVC }, { (dPointWithInterface as SomePointInterfaceWithMFVCBound<DPoint>).somethingMFVC })
|
||||
|
||||
equal(
|
||||
{ dPointWithInterface.somethingGeneric = dPoint },
|
||||
{ (dPointWithInterface as SomePointInterface<DPoint>).somethingGeneric = dPoint }
|
||||
)
|
||||
equal({ dPointWithInterface.somethingRegular = 1 }, { (dPointWithInterface as SomePointInterface<DPoint>).somethingRegular = 1 })
|
||||
equal({ dPointWithInterface.somethingMFVC = dPoint }, { (dPointWithInterface as SomePointInterface<DPoint>).somethingMFVC = dPoint })
|
||||
|
||||
equal(
|
||||
{ dPointWithInterface.somethingGeneric = dPoint },
|
||||
{ (dPointWithInterface as SomePointInterfaceWithMFVCBound<DPoint>).somethingGeneric = dPoint }
|
||||
)
|
||||
equal(
|
||||
{ dPointWithInterface.somethingRegular = 2 },
|
||||
{ (dPointWithInterface as SomePointInterfaceWithMFVCBound<DPoint>).somethingRegular = 2 }
|
||||
)
|
||||
equal(
|
||||
{ dPointWithInterface.somethingMFVC = dPoint},
|
||||
{ (dPointWithInterface as SomePointInterfaceWithMFVCBound<DPoint>).somethingMFVC = dPoint }
|
||||
)
|
||||
|
||||
|
||||
val dSegment = DSegment(dPoint, otherDPoint)
|
||||
|
||||
equal({ dPoint }, { dSegment.p1 })
|
||||
equal({ otherDPoint }, { dSegment.p2 })
|
||||
equal({ dPoint.x }, { dSegment.p1.x })
|
||||
equal({ otherDPoint.x }, { dSegment.p2.x })
|
||||
equal({ dPoint.y }, { dSegment.p1.y })
|
||||
equal({ otherDPoint.y }, { dSegment.p2.y })
|
||||
equal({ dSegment.p1 }, { (dSegment as AbstractSegment<DPoint>).p1 })
|
||||
equal({ dSegment.p2 }, { (dSegment as AbstractSegment<DPoint>).p2 })
|
||||
equal({ dSegment.p1.x }, { (dSegment as AbstractSegment<DPoint>).p1.x })
|
||||
equal({ dSegment.p2.x }, { (dSegment as AbstractSegment<DPoint>).p2.x })
|
||||
equal({ dSegment.p1.y }, { (dSegment as AbstractSegment<DPoint>).p1.y })
|
||||
equal({ dSegment.p2.y }, { (dSegment as AbstractSegment<DPoint>).p2.y })
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
@JvmInline
|
||||
value class DPoint(val x: Double, val y: Double)
|
||||
|
||||
class PointBox(var value: DPoint)
|
||||
|
||||
fun box(): String {
|
||||
var p = DPoint(1.0, 2.0)
|
||||
try {
|
||||
p = DPoint(3.0, error("Failure"))
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
if (p != DPoint(1.0, 2.0)) {
|
||||
return "Partially reassigned variable"
|
||||
}
|
||||
|
||||
val box = PointBox(p)
|
||||
|
||||
try {
|
||||
box.value = DPoint(3.0, error("Failure"))
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
|
||||
if (box.value != DPoint(1.0, 2.0)) {
|
||||
return "Partially reassigned field"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// CHECK_BYTECODE_LISTING
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
@JvmInline
|
||||
value class A<T : Any>(val x: List<T>)
|
||||
|
||||
@JvmInline
|
||||
value class B(val x: UInt)
|
||||
|
||||
@JvmInline
|
||||
value class C(val x: Int, val y: B, val z: String = "3")
|
||||
|
||||
@JvmInline
|
||||
value class D(val x: C) {
|
||||
constructor(x: Int, y: UInt, z: Int) : this(C(x, B(y), z.toString()))
|
||||
|
||||
init {
|
||||
println(x.x)
|
||||
}
|
||||
}
|
||||
|
||||
fun functionWithoutBoxes(x: D, y: D) {
|
||||
var z: D = x
|
||||
val t: D = D(C(1, B(3U), "4"))
|
||||
z = t
|
||||
require(z == y)
|
||||
}
|
||||
|
||||
// 2 public static toString-impl\(IILjava/lang/String;\)Ljava/lang/String;
|
||||
// 2 INVOKESTATIC C.toString-impl \(IILjava/lang/String;\)Ljava/lang/String;
|
||||
// 1 INVOKESTATIC D.toString-impl \(IILjava/lang/String;\)Ljava/lang/String;
|
||||
// 2 public static hashCode-impl\(IILjava/lang/String;\)I
|
||||
// 2 INVOKESTATIC C.hashCode-impl \(IILjava/lang/String;\)I
|
||||
// 1 INVOKESTATIC D.hashCode-impl \(IILjava/lang/String;\)I
|
||||
// 2 public static equals-impl\(IILjava/lang/String;Ljava/lang/Object;\)Z
|
||||
// 2 public final static equals-impl0\(IILjava/lang/String;IILjava/lang/String;\)Z
|
||||
// 1 public final static constructor-impl\(III\)LD;
|
||||
// 2 public final static constructor-impl\(IILjava/lang/String;\)V
|
||||
// 2 INVOKESTATIC D.constructor-impl \(IILjava/lang/String;\)V
|
||||
// 2 INVOKESTATIC C.constructor-impl \(IILjava/lang/String;\)V
|
||||
// 1 public final getX\(\)LC;
|
||||
// 1 public final getX\$x\(\)I
|
||||
// 1 public final getX\$y\(\)I
|
||||
// 1 public final getX\$z\(\)Ljava/lang/String;
|
||||
// 2 private synthetic <init>\(IILjava/lang/String;\)V
|
||||
// 1 public final static synthetic box-impl\(IILjava/lang/String;\)LD;
|
||||
// 1 public final static synthetic box-impl\(IILjava/lang/String;\)LC;
|
||||
// 2 public final synthetic unbox-impl0\(\)I
|
||||
// 2 public final synthetic unbox-impl1\(\)I
|
||||
// 2 public final synthetic unbox-impl2\(\)Ljava/lang/String;
|
||||
// 1 private I x\$x
|
||||
// 1 private I x\$y
|
||||
// 1 private Ljava/lang/String; x\$z
|
||||
// 0 private LC; x
|
||||
// 3 private I x
|
||||
// 1 private I y
|
||||
// 1 private Ljava/lang/String; z
|
||||
// 1 INVOKESPECIAL C.<init> \(IILjava/lang/String;\)V
|
||||
// 1 INVOKESPECIAL D.<init> \(IILjava/lang/String;\)V
|
||||
// 1 INVOKESTATIC D.box-impl \(IILjava/lang/String;\)LD;
|
||||
// 1 INVOKESTATIC D.box-impl \(IILjava/lang/String;\)LD;\n ARETURN
|
||||
// 1 INVOKESTATIC C.box-impl \(IILjava/lang/String;\)LC;
|
||||
// 1 INVOKESTATIC C.box-impl \(IILjava/lang/String;\)LC;\n ARETURN
|
||||
// 1 public final static functionWithoutBoxes-GPBa7dw-AYZo7_8\(IILjava/lang/String;IILjava/lang/String;\)V
|
||||
// 0 functionWithoutBoxes.*(\n {3}.*)*(\n {4}(NEW [ABCD]|.*(box|[ABCD]\.<init>|LA;|LB;|LC;|LD;)))
|
||||
@@ -0,0 +1,73 @@
|
||||
// CHECK_BYTECODE_LISTING
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
@JvmInline
|
||||
value class DPoint(val x: Double, val y: Double)
|
||||
|
||||
class Box(var value: DPoint)
|
||||
|
||||
fun supplier(index: Int) {} // to make usage of the argument
|
||||
fun supplier(index: Int, x: DPoint) {} // to make usage of the argument
|
||||
|
||||
fun reassignVariable(x: DPoint, box: Box) {
|
||||
supplier(100)
|
||||
var p = DPoint(1.0, 2.0) // should not use temporary variables
|
||||
supplier(101, p)
|
||||
p = p // should not use temporary variables
|
||||
supplier(102, p)
|
||||
p = DPoint(3.0, 4.0) // should use tempVars
|
||||
supplier(103, p)
|
||||
p = x // should not use temporary variables
|
||||
supplier(104, p)
|
||||
p = box.value // should use temporary variables
|
||||
supplier(105, p)
|
||||
p = listOf(p)[0] // should use temporary variables
|
||||
supplier(106, p)
|
||||
}
|
||||
|
||||
fun reassignField(x: DPoint, box: Box) {
|
||||
supplier(107)
|
||||
val p = DPoint(5.0, 6.0)
|
||||
supplier(108, p)
|
||||
var b = Box(p) // should not use temporary variables
|
||||
supplier(109)
|
||||
b.value = b.value // should not use temporary variables
|
||||
supplier(110)
|
||||
b.value = DPoint(7.0, 8.0) // should use tempVars
|
||||
supplier(111)
|
||||
b.value = x // should not use temporary variables
|
||||
supplier(112)
|
||||
b.value = box.value // should not use temporary variables
|
||||
supplier(113)
|
||||
b.value = listOf(p)[0] // should use temporary variables
|
||||
supplier(114)
|
||||
}
|
||||
|
||||
// 1 100(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){2}101
|
||||
// 0 100(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){3}101
|
||||
// 1 101(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){2}102
|
||||
// 0 101(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){3}102
|
||||
// 1 102(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){4}103
|
||||
// 0 102(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){5}103
|
||||
// 1 103(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){2}104
|
||||
// 0 103(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){3}104
|
||||
// 1 104(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){4}105
|
||||
// 0 104(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){5}105
|
||||
// 1 105(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){4}106
|
||||
// 0 105(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){5}106
|
||||
|
||||
// 1 107(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){2}108
|
||||
// 0 107(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){3}108
|
||||
// 0 108(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){1}109
|
||||
// 1 109(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){2}110
|
||||
// 0 109(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){3}110
|
||||
// 1 110(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){2}111
|
||||
// 0 110(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){3}111
|
||||
// 0 111(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){1}112
|
||||
// 1 112(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){2}113
|
||||
// 0 112(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){3}113
|
||||
// 1 113(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){2}114
|
||||
// 0 113(\D|\d\D|\d\d\D)*(DSTORE(\D|\d\D|\d\d\D)*){3}114
|
||||
@@ -0,0 +1,42 @@
|
||||
// CHECK_BYTECODE_LISTING
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
@JvmInline
|
||||
value class DPoint(val x: Double, val y: Double)
|
||||
|
||||
fun require(index: Int, condition: Boolean) = require(condition) { "$index" }
|
||||
|
||||
fun DPoint.toObject() = this as Any
|
||||
fun DPoint.toDPointOrNull() = this as DPoint?
|
||||
fun Nothing?.toDPointOrNull() = this as DPoint?
|
||||
|
||||
fun equalsChecks(left: DPoint, right: DPoint) {
|
||||
require(100, left == right)
|
||||
require(101, left.toObject() == right)
|
||||
require(102, left == right.toObject())
|
||||
require(103, left.toObject() == right.toObject())
|
||||
require(104, null == right)
|
||||
require(105, left == null)
|
||||
require(106, null as Any? == right)
|
||||
require(107, left == null as Any?)
|
||||
require(108, null.toDPointOrNull() == right)
|
||||
require(109, left == null.toDPointOrNull())
|
||||
require(110, left.toDPointOrNull() == right)
|
||||
require(111, left == right.toDPointOrNull())
|
||||
}
|
||||
|
||||
// 1 BIPUSH 100\n {4}DLOAD 0\n {4}DLOAD 2\n {4}DLOAD 4\n {4}DLOAD 6\n {4}INVOKESTATIC .*equals-impl0.*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 101\n {4}DLOAD 0\n {4}DLOAD 2\n {4}.*toObject.*\n {4}DLOAD 4\n {4}DLOAD 6\n {4}.*box-impl.*\n {4}INVOKESTATIC .*Intrinsics.areEqual.*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 102\n {4}DLOAD 0\n {4}DLOAD 2\n {4}DLOAD 4\n {4}DLOAD 6\n {4}.*toObject.*\n {4}INVOKESTATIC .*equals-impl .*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 103\n {4}DLOAD 0\n {4}DLOAD 2\n {4}.*toObject.*\n {4}DLOAD 4\n {4}DLOAD 6\n {4}.*toObject.*\n {4}INVOKESTATIC .*Intrinsics.areEqual.*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 104\n {4}ICONST_0\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 105\n {4}DLOAD 0\n {4}DLOAD 2\n {4}ACONST_NULL\n {4}INVOKESTATIC .*equals-impl .*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 106\n {4}ACONST_NULL\n {4}DLOAD 4\n {4}DLOAD 6\n {4}.*box.*\n {4}INVOKESTATIC .*Intrinsics.areEqual.*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 107\n {4}DLOAD 0\n {4}DLOAD 2\n {4}ACONST_NULL\n {4}INVOKESTATIC .*equals-impl .*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 108\n {4}ACONST_NULL\n {4}.*toDPointOrNull.*\n {4}DUP\n {4}IFNONNULL.*(\n {3}([^b\n]|b[^o\n]|bo[^x\n]|box-impl\d)*)*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 109\n {4}DLOAD 0\n {4}DLOAD 2\n {4}ACONST_NULL\n {4}.*toDPointOrNull.*\n {4}INVOKESTATIC .*equals-impl .*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 110\n {4}DLOAD 0\n {4}DLOAD 2\n {4}.*toDPointOrNull.*\n {4}DUP\n {4}IFNONNULL.*(\n {3}([^b\n]|b[^o\n]|bo[^x\n]|box-impl\d)*)*\n {4}INVOKESTATIC .*require
|
||||
// 1 BIPUSH 111\n {4}DLOAD 0\n {4}DLOAD 2\n {4}DLOAD 4\n {4}DLOAD 6\n {4}.*toDPointOrNull.*\n {4}INVOKESTATIC .*equals-impl .*\n {4}INVOKESTATIC .*require
|
||||
@@ -0,0 +1,49 @@
|
||||
// CHECK_BYTECODE_LISTING
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
@JvmInline
|
||||
value class DPoint(val x: Double, val y: Double)
|
||||
|
||||
fun acceptBoxed(x: Any?) {}
|
||||
fun acceptFlattened(x: DPoint) {}
|
||||
fun returnBoxed() = DPoint(3.0, 4.0)
|
||||
|
||||
fun testFlattened2Boxed() {
|
||||
acceptBoxed(DPoint(1.0, 2.0))
|
||||
}
|
||||
|
||||
fun testBoxed2Boxed() {
|
||||
acceptBoxed(returnBoxed())
|
||||
}
|
||||
|
||||
fun testFlattened2Flattened() {
|
||||
acceptFlattened(DPoint(1.0, 2.0))
|
||||
}
|
||||
|
||||
fun testBoxed2Flattened() {
|
||||
acceptFlattened(returnBoxed())
|
||||
}
|
||||
|
||||
fun testIgnoredFlattened() {
|
||||
DPoint(1.0, 2.0)
|
||||
DPoint(1.0, 2.0)
|
||||
}
|
||||
|
||||
fun testIgnoredBoxed() {
|
||||
returnBoxed()
|
||||
}
|
||||
|
||||
// 1 testFlattened2Boxed\(\)V(\n {3}.*)*((\n {3}.*box-impl .*)(\n {3}.*)*){1}
|
||||
// 0 testFlattened2Boxed\(\)V(\n {3}.*)*((\n {3}.*box-impl.*)(\n {3}.*)*){2}
|
||||
// 0 testBoxed2Boxed\(\)V(\n {3}.*)*((\n {3}.*(box-impl|DSTORE|DLOAD).*)(\n {3}.*)*){1}
|
||||
// 0 testFlattened2Flattened\(\)V(\n {3}.*)*((\n {3}.*box-impl.*)(\n {3}.*)*){1}
|
||||
// 1 testFlattened2Flattened\(\)V(\n {3}.*)*((\n {3}.*DSTORE.*)(\n {3}.*)*){2}
|
||||
// 0 testFlattened2Flattened\(\)V(\n {3}.*)*((\n {3}.*DSTORE.*)(\n {3}.*)*){3}
|
||||
// 0 testBoxed2Flattened\(\)V(\n {3}.*)*((\n {3}.*box-impl .*)(\n {3}.*)*){1}
|
||||
// 1 testBoxed2Flattened\(\)V(\n {3}.*)*((\n {3}.*unbox-impl.*)(\n {3}.*)*){2}
|
||||
// 0 testBoxed2Flattened\(\)V(\n {3}.*)*((\n {3}.*unbox-impl.*)(\n {3}.*)*){3}
|
||||
// 0 testIgnoredFlattened\(\)V(\n {3}.*)*((\n {3}.*box-impl.*)(\n {3}.*)*){1}
|
||||
// 0 testIgnoredBoxed\(\)V(\n {3}.*)*((\n {3}.*box-impl.*)(\n {3}.*)*){1}
|
||||
@@ -0,0 +1,149 @@
|
||||
// CHECK_BYTECODE_LISTING
|
||||
// WITH_STDLIB
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
|
||||
@JvmInline
|
||||
value class DPoint(val x: Double, val y: Double) {
|
||||
val opposite: DPoint
|
||||
get() = DPoint(-x, -y)
|
||||
}
|
||||
|
||||
class DSegment(var p1: DPoint, var p2: DPoint) {
|
||||
|
||||
val center: DPoint
|
||||
get() = DPoint(p1.x / 2 + p2.x / 2, p1.y / 2 + p2.y / 2)
|
||||
|
||||
var notImplemented: DPoint
|
||||
get() = TODO()
|
||||
set(_) = TODO()
|
||||
|
||||
var point1WithBackingFieldAndDefaultGetter: DPoint = p1
|
||||
var point2WithBackingFieldAndDefaultGetter: DPoint = p1
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
require("${2 + 2}" == "4")
|
||||
}
|
||||
|
||||
var pointWithBackingFieldAndCustomGetter: DPoint = p1
|
||||
get() = field.also { require("${2 + 2}" == "4") }
|
||||
set(value) {
|
||||
field = value
|
||||
require("${2 + 2}" == "4")
|
||||
}
|
||||
|
||||
init {
|
||||
p1 = p1
|
||||
}
|
||||
}
|
||||
|
||||
fun tryGetSegment(segment: DSegment) {
|
||||
segment.p1
|
||||
segment.p1.x
|
||||
segment.p1.y
|
||||
segment.p2
|
||||
segment.p2.x
|
||||
segment.p2.y
|
||||
segment.center
|
||||
segment.center.x
|
||||
segment.center.y
|
||||
segment.notImplemented
|
||||
segment.notImplemented.x
|
||||
segment.notImplemented.y
|
||||
segment.point1WithBackingFieldAndDefaultGetter
|
||||
segment.point1WithBackingFieldAndDefaultGetter.x
|
||||
segment.point1WithBackingFieldAndDefaultGetter.y
|
||||
segment.point2WithBackingFieldAndDefaultGetter
|
||||
segment.point2WithBackingFieldAndDefaultGetter.x
|
||||
segment.point2WithBackingFieldAndDefaultGetter.y
|
||||
segment.pointWithBackingFieldAndCustomGetter
|
||||
segment.pointWithBackingFieldAndCustomGetter.x
|
||||
segment.pointWithBackingFieldAndCustomGetter.y
|
||||
}
|
||||
|
||||
fun trySetSegment(segment: DSegment) {
|
||||
segment.notImplemented = segment.p1
|
||||
segment.point1WithBackingFieldAndDefaultGetter = segment.p1
|
||||
segment.point2WithBackingFieldAndDefaultGetter = segment.p1
|
||||
segment.pointWithBackingFieldAndCustomGetter = segment.p1
|
||||
segment.p1 = segment.p1
|
||||
segment.p2 = segment.p2
|
||||
}
|
||||
|
||||
// 0 public final getOpposite\(\)LDPoint;
|
||||
// 1 public final static getOpposite-impl\(DD\)LDPoint;
|
||||
// 1 private D p1\$x
|
||||
// 1 private D p1\$y
|
||||
// 0 private DPoint; p1
|
||||
// 1 private D p2\$x
|
||||
// 1 private D p2\$y
|
||||
// 0 private DPoint; p2
|
||||
// 1 private D point1WithBackingFieldAndDefaultGetter\$x
|
||||
// 1 private D point1WithBackingFieldAndDefaultGetter\$y
|
||||
// 0 private DPoint; point1WithBackingFieldAndDefaultGetter
|
||||
// 1 private D point2WithBackingFieldAndDefaultGetter\$x
|
||||
// 1 private D point2WithBackingFieldAndDefaultGetter\$y
|
||||
// 0 private DPoint; point2WithBackingFieldAndDefaultGetter
|
||||
// 1 private D pointWithBackingFieldAndCustomGetter\$x
|
||||
// 1 private D pointWithBackingFieldAndCustomGetter\$y
|
||||
// 0 private DPoint; pointWithBackingFieldAndCustomGetter
|
||||
// 0 private DPoint; notImplemented
|
||||
// 0 private D notImplemented
|
||||
// 0 private DPoint; center
|
||||
// 0 private D center
|
||||
// 1 public <init>\(DDDD\)V
|
||||
// 0 public <init>\(DDDD\)V.*(\n {3}.*)*(\n {4}.*box)
|
||||
// 1 public final getP1\(\)LDPoint;
|
||||
// 1 public final setP1-sUp7gFk\(DD\)V
|
||||
// 1 public final getP2\(\)LDPoint;
|
||||
// 1 public final setP2-sUp7gFk\(DD\)V
|
||||
// 1 public final getCenter\(\)LDPoint;
|
||||
// 1 public final getNotImplemented\(\)LDPoint;
|
||||
// 1 public final setNotImplemented-sUp7gFk\(DD\)V
|
||||
// 1 public final getPoint1WithBackingFieldAndDefaultGetter\(\)LDPoint;
|
||||
// 1 public final setPoint1WithBackingFieldAndDefaultGetter-sUp7gFk\(DD\)V
|
||||
// 1 public final getPoint2WithBackingFieldAndDefaultGetter\(\)LDPoint;
|
||||
// 1 public final setPoint2WithBackingFieldAndDefaultGetter-sUp7gFk\(DD\)V
|
||||
// 1 public final getPointWithBackingFieldAndCustomGetter\(\)LDPoint;
|
||||
// 1 public final setPointWithBackingFieldAndCustomGetter-sUp7gFk\(DD\)V
|
||||
// 1 public final getP1\$x\(\)D
|
||||
// 1 public final getP1\$y\(\)D
|
||||
// 1 public final getP2\$x\(\)D
|
||||
// 1 public final getP2\$y\(\)D
|
||||
// 1 public final getPoint1WithBackingFieldAndDefaultGetter\$x\(\)D
|
||||
// 1 public final getPoint1WithBackingFieldAndDefaultGetter\$y\(\)D
|
||||
// 1 public final getPoint2WithBackingFieldAndDefaultGetter\$x\(\)D
|
||||
// 1 public final getPoint2WithBackingFieldAndDefaultGetter\$y\(\)D
|
||||
// 0 public final getCenter\$
|
||||
// 0 public final getNotImplemented\$
|
||||
// 0 public final getPointWithBackingFieldAndCustomGetter\$
|
||||
// 0 ^ {2}\b.*get.*\$.*(\n {3}.*)*(\n {4}.*\.box)
|
||||
// 1 tryGetSegment\(LDSegment;\)V
|
||||
// 0 try[GS]etSegment\(LDSegment;\)V.*(\n {3}.*)*(\n {4}.*\.box)
|
||||
// 1 tryGetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}.*LDPoint;)){13}
|
||||
// 0 tryGetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}.*LDPoint;)){14}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*(\n {3}.*)*(\n {4}.*LDPoint;)
|
||||
// 1 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setNotImplemented-sUp7gFk \(DD\)V)){1}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setNotImplemented-sUp7gFk \(DD\)V)){2}
|
||||
// 1 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setPoint1WithBackingFieldAndDefaultGetter-sUp7gFk \(DD\)V)){1}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setPoint1WithBackingFieldAndDefaultGetter-sUp7gFk \(DD\)V)){2}
|
||||
// 1 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setPoint2WithBackingFieldAndDefaultGetter-sUp7gFk \(DD\)V)){1}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setPoint2WithBackingFieldAndDefaultGetter-sUp7gFk \(DD\)V)){2}
|
||||
// 1 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setPointWithBackingFieldAndCustomGetter-sUp7gFk \(DD\)V)){1}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setPointWithBackingFieldAndCustomGetter-sUp7gFk \(DD\)V)){2}
|
||||
// 1 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setP1-sUp7gFk \(DD\)V)){1}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setP1-sUp7gFk \(DD\)V)){2}
|
||||
// 1 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setP2-sUp7gFk \(DD\)V)){1}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DSegment\.setP2-sUp7gFk \(DD\)V)){2}
|
||||
// 1 tryGetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DPoint\.getX \(\)D)){3}
|
||||
// 0 tryGetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DPoint\.getX \(\)D)){4}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*(\n {3}.*)*(\n {4}INVOKEVIRTUAL DPoint\.getX \(\)D)
|
||||
// 1 tryGetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DPoint\.getY \(\)D)){3}
|
||||
// 0 tryGetSegment\(LDSegment;\)V.*((\n {3}.*)*(\n {4}INVOKEVIRTUAL DPoint\.getY \(\)D)){4}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*(\n {3}.*)*(\n {4}INVOKEVIRTUAL DPoint\.getY \(\)D)
|
||||
// 1 tryGetSegment\(LDSegment;\)V.*((\n {3}.*)*?(\n {4}INVOKEVIRTUAL DSegment\.get.*\$[xy] \(\)D)){8}
|
||||
// 0 tryGetSegment\(LDSegment;\)V.*((\n {3}.*)*?(\n {4}INVOKEVIRTUAL DSegment\.get.*\$[xy] \(\)D)){9}
|
||||
// 1 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*?(\n {4}INVOKEVIRTUAL DSegment\.get.*\$[xy] \(\)D)){12}
|
||||
// 0 trySetSegment\(LDSegment;\)V.*((\n {3}.*)*?(\n {4}INVOKEVIRTUAL DSegment\.get.*\$[xy] \(\)D)){13}
|
||||
Reference in New Issue
Block a user