[IR] Add MFVC generation tests
#KT-1179
This commit is contained in:
committed by
teamcity
parent
894cdc2307
commit
765c212327
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user