Fix type mapping of nullable inline class types in reflection

Based on #4761.

 #KT-31141 Fixed

Co-authored-by: wrongwrong <boranti1995@gmail.com>
This commit is contained in:
Alexander Udalov
2022-03-16 23:35:09 +01:00
parent 07ebf4ed29
commit 8b56babb1d
24 changed files with 283 additions and 622 deletions
@@ -2,7 +2,6 @@
// WITH_REFLECT
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val x: Int)
@@ -32,28 +31,20 @@ fun box(): String {
val z3 = Z(3)
val z4 = Z(4)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
val outer = ::Outer.call(z1, z2)
assertEquals(z1, outer.z1)
assertEquals(z2, outer.z2)
val outer = ::Outer.call(z1, z2)
assertEquals(z1, outer.z1)
assertEquals(z2, outer.z2)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("Z(x=1) Z(x=2) Z(x=3) Z(x=4)", Outer::Inner.call(outer, z3, z4).test)
assertEquals("Z(x=1) Z(x=2) Z(x=2) Z(x=4)", outer::Inner.call(z2, z4).test)
}
}
assertEquals("Z(x=1) Z(x=2) Z(x=3) Z(x=4)", Outer::Inner.call(outer, z3, z4).test)
assertEquals("Z(x=1) Z(x=2) Z(x=2) Z(x=4)", outer::Inner.call(z2, z4).test)
val inlineNonNullOuter = InlineNonNullOuter(z1)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("Z(x=1) Z(x=2) Z(x=3)", InlineNonNullOuter::Inner.call(inlineNonNullOuter, z2, z3).test)
assertEquals("Z(x=1) Z(x=2) Z(x=2)", inlineNonNullOuter::Inner.call(z2, z2).test)
}
assertEquals("Z(x=1) Z(x=2) Z(x=3)", InlineNonNullOuter::Inner.call(inlineNonNullOuter, z2, z3).test)
assertEquals("Z(x=1) Z(x=2) Z(x=2)", inlineNonNullOuter::Inner.call(z2, z2).test)
val inlineNullableOuter = InlineNullableOuter(z1)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("Z(x=1) Z(x=2) Z(x=3)", InlineNullableOuter::Inner.call(inlineNullableOuter, z2, z3).test)
assertEquals("Z(x=1) Z(x=2) Z(x=2)", inlineNullableOuter::Inner.call(z2, z2).test)
}
assertEquals("Z(x=1) Z(x=2) Z(x=3)", InlineNullableOuter::Inner.call(inlineNullableOuter, z2, z3).test)
assertEquals("Z(x=1) Z(x=2) Z(x=2)", inlineNullableOuter::Inner.call(z2, z2).test)
return "OK"
}
@@ -3,7 +3,6 @@
import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class S(val value: Int) {
operator fun plus(other: S): S = S(this.value + other.value)
@@ -36,17 +35,13 @@ fun box(): String {
assertEquals(one, c.nonNullBoundRef().call())
assertEquals(one, c.nonNullBoundRef().getter.call())
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, c.nullableUnboundRef().setter.call(c, zero))
assertEquals(zero, c.nullableUnboundRef().call(c))
assertEquals(zero, c.nullableUnboundRef().getter.call(c))
}
assertEquals(Unit, c.nullableUnboundRef().setter.call(c, zero))
assertEquals(zero, c.nullableUnboundRef().call(c))
assertEquals(zero, c.nullableUnboundRef().getter.call(c))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, c.nullableBoundRef().setter.call(one))
assertEquals(one, c.nullableBoundRef().call())
assertEquals(one, c.nullableBoundRef().getter.call())
}
assertEquals(Unit, c.nullableBoundRef().setter.call(one))
assertEquals(one, c.nullableBoundRef().call())
assertEquals(one, c.nullableBoundRef().getter.call())
val nonNullTopLevel = ::nonNullTopLevel.apply { isAccessible = true }
assertEquals(Unit, nonNullTopLevel.setter.call(two))
@@ -54,11 +49,9 @@ fun box(): String {
assertEquals(two, nonNullTopLevel.getter.call())
val nullableTopLevel = ::nullableTopLevel.apply { isAccessible = true }
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, nullableTopLevel.setter.call(two))
assertEquals(two, nullableTopLevel.call())
assertEquals(two, nullableTopLevel.getter.call())
}
assertEquals(Unit, nullableTopLevel.setter.call(two))
assertEquals(two, nullableTopLevel.call())
assertEquals(two, nullableTopLevel.getter.call())
return "OK"
}
@@ -29,32 +29,16 @@ fun box(): String {
val four = S(4)
val seven = S(7)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, C::member.call(C(), one, 2, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, ::topLevel.call(1, two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, S::extension1.call(one, two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, S::extension2.call(one, two, four))
}
assertEquals(seven, C::member.call(C(), one, 2, four))
assertEquals(seven, ::topLevel.call(1, two, four))
assertEquals(seven, S::extension1.call(one, two, four))
assertEquals(seven, S::extension2.call(one, two, four))
assertEquals(0, S::extension3.call(zero))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(0, S?::extension4.call(zero))
}
assertEquals(0, S?::extension4.call(zero))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, C()::member.call(one, 2, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, one::extension1.call(two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, one::extension2.call(two, four))
}
assertEquals(seven, C()::member.call(one, 2, four))
assertEquals(seven, one::extension1.call(two, four))
assertEquals(seven, one::extension2.call(two, four))
assertEquals(0, zero::extension3.call())
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(0, zero::extension4.call(zero))
@@ -5,7 +5,6 @@
import kotlin.reflect.KMutableProperty1
import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val value: Int) {
operator fun plus(other: Z): Z = Z(this.value + other.value)
@@ -34,11 +33,9 @@ fun box(): String {
val nullableUnboundRef = C::class.members.single { it.name == "p2" } as KMutableProperty1<C, Z?>
nullableUnboundRef.isAccessible = true
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, nullableUnboundRef.setter.call(C, one))
assertEquals(one, nullableUnboundRef.call(C))
assertEquals(one, nullableUnboundRef.getter.call(C))
}
assertEquals(Unit, nullableUnboundRef.setter.call(C, one))
assertEquals(one, nullableUnboundRef.call(C))
assertEquals(one, nullableUnboundRef.getter.call(C))
val nonNullBoundRef = C.nonNullBoundRef()
assertEquals(Unit, nonNullBoundRef.setter.call(two))
@@ -46,11 +43,9 @@ fun box(): String {
assertEquals(two, nonNullBoundRef.getter.call())
val nullableBoundRef = C.nullableBoundRef()
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, nullableBoundRef.setter.call(two))
assertEquals(two, nullableBoundRef.call())
assertEquals(two, nullableBoundRef.getter.call())
}
assertEquals(Unit, nullableBoundRef.setter.call(two))
assertEquals(two, nullableBoundRef.call())
assertEquals(two, nullableBoundRef.getter.call())
return "OK"
}
@@ -4,7 +4,6 @@
import kotlin.reflect.KFunction
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val value: Int) {
operator fun plus(other: Z): Z = Z(this.value + other.value)
@@ -28,22 +27,14 @@ fun box(): String {
val four = Z(4)
val seven = Z(7)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, C::foo.call(one, 2, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, (I)::bar.call(1, two, four))
}
assertEquals(seven, C::foo.call(one, 2, four))
assertEquals(seven, (I)::bar.call(1, two, four))
val unboundFoo = C::class.members.single { it.name == "foo" } as KFunction<*>
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, unboundFoo.call(C, one, 2, four))
}
assertEquals(seven, unboundFoo.call(C, one, 2, four))
val unboundBar = I.Companion::class.members.single { it.name == "bar" } as KFunction<*>
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, unboundBar.call(I, 1, two, four))
}
assertEquals(seven, unboundBar.call(I, 1, two, four))
return "OK"
}
@@ -2,7 +2,6 @@
// WITH_REFLECT
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val x: Int) {
fun test(a: Int, b: Z, c: Z?) = "$x$a${b.x}${c!!.x}"
@@ -20,26 +19,14 @@ fun box(): String {
val two = Z(2)
val four = Z(4)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", Z::test.call(Z(0), 1, two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", Z(0)::test.call(1, two, four))
}
assertEquals("0124", Z::test.call(Z(0), 1, two, four))
assertEquals("0124", Z(0)::test.call(1, two, four))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", S::test.call(S("0"), 1, two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", S("0")::test.call(1, two, four))
}
assertEquals("0124", S::test.call(S("0"), 1, two, four))
assertEquals("0124", S("0")::test.call(1, two, four))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", A::test.call(A(0), 1, two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", A(0)::test.call(1, two, four))
}
assertEquals("0124", A::test.call(A(0), 1, two, four))
assertEquals("0124", A(0)::test.call(1, two, four))
return "OK"
}
@@ -2,7 +2,6 @@
// WITH_REFLECT
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
var global = Z(0)
@@ -71,26 +70,14 @@ fun box(): String {
assertEquals(zFour, global)
global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, Z::nullableTest.call(zOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, zOne::nullableTest.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, Z::nullableTest.getter.call(zOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, zOne::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
Z::nullableTest.setter.call(zOne, zTwo)
assertEquals(zThree, global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
zOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
}
assertEquals(zOne, Z::nullableTest.call(zOne))
assertEquals(zOne, zOne::nullableTest.call())
assertEquals(zOne, Z::nullableTest.getter.call(zOne))
assertEquals(zOne, zOne::nullableTest.getter.call())
Z::nullableTest.setter.call(zOne, zTwo)
assertEquals(zThree, global)
zOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
global = zZero
assertEquals(zOne, S::nonNullTest.call(sOne))
@@ -103,26 +90,14 @@ fun box(): String {
assertEquals(zFour, global)
global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, S::nullableTest.call(sOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, sOne::nullableTest.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, S::nullableTest.getter.call(sOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, sOne::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
S::nullableTest.setter.call(sOne, zTwo)
assertEquals(zThree, global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
sOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
}
assertEquals(zOne, S::nullableTest.call(sOne))
assertEquals(zOne, sOne::nullableTest.call())
assertEquals(zOne, S::nullableTest.getter.call(sOne))
assertEquals(zOne, sOne::nullableTest.getter.call())
S::nullableTest.setter.call(sOne, zTwo)
assertEquals(zThree, global)
sOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
global = zZero
assertEquals(zOne, A::nonNullTest.call(aOne))
@@ -135,26 +110,14 @@ fun box(): String {
assertEquals(zFour, global)
global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, A::nullableTest.call(aOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, aOne::nullableTest.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, A::nullableTest.getter.call(aOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, aOne::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
A::nullableTest.setter.call(aOne, zTwo)
assertEquals(zThree, global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
aOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
}
assertEquals(zOne, A::nullableTest.call(aOne))
assertEquals(zOne, aOne::nullableTest.call())
assertEquals(zOne, A::nullableTest.getter.call(aOne))
assertEquals(zOne, aOne::nullableTest.getter.call())
A::nullableTest.setter.call(aOne, zTwo)
assertEquals(zThree, global)
aOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
return "OK"
}
@@ -2,7 +2,6 @@
// WITH_REFLECT
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
interface ITest {
fun test(a: Int, b: Z, c: Z?): String
@@ -24,26 +23,14 @@ fun box(): String {
val two = Z(2)
val four = Z(4)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", Z::test.call(Z(0), 1, two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", Z(0)::test.call(1, two, four))
}
assertEquals("0124", Z::test.call(Z(0), 1, two, four))
assertEquals("0124", Z(0)::test.call(1, two, four))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", S::test.call(S("0"), 1, two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", S("0")::test.call(1, two, four))
}
assertEquals("0124", S::test.call(S("0"), 1, two, four))
assertEquals("0124", S("0")::test.call(1, two, four))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", A::test.call(A(0), 1, two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("0124", A(0)::test.call(1, two, four))
}
assertEquals("0124", A::test.call(A(0), 1, two, four))
assertEquals("0124", A(0)::test.call(1, two, four))
return "OK"
}
@@ -2,7 +2,6 @@
// WITH_REFLECT
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
var global = Z(0)
@@ -76,26 +75,14 @@ fun box(): String {
assertEquals(zFour, global)
global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, Z::nullableTest.call(zOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, zOne::nullableTest.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, Z::nullableTest.getter.call(zOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, zOne::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
Z::nullableTest.setter.call(zOne, zTwo)
assertEquals(zThree, global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
zOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
}
assertEquals(zOne, Z::nullableTest.call(zOne))
assertEquals(zOne, zOne::nullableTest.call())
assertEquals(zOne, Z::nullableTest.getter.call(zOne))
assertEquals(zOne, zOne::nullableTest.getter.call())
Z::nullableTest.setter.call(zOne, zTwo)
assertEquals(zThree, global)
zOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
global = zZero
assertEquals(zOne, S::nonNullTest.call(sOne))
@@ -108,26 +95,14 @@ fun box(): String {
assertEquals(zFour, global)
global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, S::nullableTest.call(sOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, sOne::nullableTest.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, S::nullableTest.getter.call(sOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, sOne::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
S::nullableTest.setter.call(sOne, zTwo)
assertEquals(zThree, global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
sOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
}
assertEquals(zOne, S::nullableTest.call(sOne))
assertEquals(zOne, sOne::nullableTest.call())
assertEquals(zOne, S::nullableTest.getter.call(sOne))
assertEquals(zOne, sOne::nullableTest.getter.call())
S::nullableTest.setter.call(sOne, zTwo)
assertEquals(zThree, global)
sOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
global = zZero
assertEquals(zOne, A::nonNullTest.call(aOne))
@@ -140,26 +115,14 @@ fun box(): String {
assertEquals(zFour, global)
global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, A::nullableTest.call(aOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, aOne::nullableTest.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, A::nullableTest.getter.call(aOne))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(zOne, aOne::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
A::nullableTest.setter.call(aOne, zTwo)
assertEquals(zThree, global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
aOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
}
assertEquals(zOne, A::nullableTest.call(aOne))
assertEquals(zOne, aOne::nullableTest.call())
assertEquals(zOne, A::nullableTest.getter.call(aOne))
assertEquals(zOne, aOne::nullableTest.getter.call())
A::nullableTest.setter.call(aOne, zTwo)
assertEquals(zThree, global)
aOne::nullableTest.setter.call(zThree)
assertEquals(zFour, global)
return "OK"
}
@@ -3,7 +3,6 @@
import kotlin.reflect.KMutableProperty2
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val value: Int) {
operator fun plus(other: Z): Z = Z(this.value + other.value)
@@ -65,17 +64,13 @@ fun box(): String {
assertEquals(two, c::nonNullMember.call())
assertEquals(two, c::nonNullMember.getter.call())
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, C::nullableMember.setter.call(c, one))
assertEquals(one, C::nullableMember.call(c))
assertEquals(one, C::nullableMember.getter.call(c))
}
assertEquals(Unit, C::nullableMember.setter.call(c, one))
assertEquals(one, C::nullableMember.call(c))
assertEquals(one, C::nullableMember.getter.call(c))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, c::nullableMember.setter.call(two))
assertEquals(two, c::nullableMember.call())
assertEquals(two, c::nullableMember.getter.call())
}
assertEquals(Unit, c::nullableMember.setter.call(two))
assertEquals(two, c::nullableMember.call())
assertEquals(two, c::nullableMember.getter.call())
val nonNull_nonNullMemExt = C::class.members.single { it.name == "nonNull_nonNullMemExt" } as KMutableProperty2<C, Z, Z>
assertEquals(Unit, nonNull_nonNullMemExt.setter.call(c, Z(0), two))
@@ -83,57 +78,43 @@ fun box(): String {
assertEquals(three, nonNull_nonNullMemExt.getter.call(c, one))
val nonNull_nullableMemExt = C::class.members.single { it.name == "nonNull_nullableMemExt" } as KMutableProperty2<C, Z, Z?>
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, nonNull_nullableMemExt.setter.call(c, Z(0), two))
assertEquals(three, nonNull_nullableMemExt.call(c, one))
assertEquals(three, nonNull_nullableMemExt.getter.call(c, one))
}
assertEquals(Unit, nonNull_nullableMemExt.setter.call(c, Z(0), two))
assertEquals(three, nonNull_nullableMemExt.call(c, one))
assertEquals(three, nonNull_nullableMemExt.getter.call(c, one))
val nullable_nonNullMemExt = C::class.members.single { it.name == "nullable_nonNullMemExt" } as KMutableProperty2<C, Z?, Z>
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, nullable_nonNullMemExt.setter.call(c, Z(0), two))
assertEquals(three, nullable_nonNullMemExt.call(c, one))
assertEquals(three, nullable_nonNullMemExt.getter.call(c, one))
}
assertEquals(Unit, nullable_nonNullMemExt.setter.call(c, Z(0), two))
assertEquals(three, nullable_nonNullMemExt.call(c, one))
assertEquals(three, nullable_nonNullMemExt.getter.call(c, one))
val nullable_nullableMemExt = C::class.members.single { it.name == "nullable_nullableMemExt" } as KMutableProperty2<C, Z?, Z?>
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, nullable_nullableMemExt.setter.call(c, Z(0), two))
assertEquals(three, nullable_nullableMemExt.call(c, one))
assertEquals(three, nullable_nullableMemExt.getter.call(c, one))
}
assertEquals(Unit, nullable_nullableMemExt.setter.call(c, Z(0), two))
assertEquals(three, nullable_nullableMemExt.call(c, one))
assertEquals(three, nullable_nullableMemExt.getter.call(c, one))
assertEquals(Unit, ::nonNullTopLevel.setter.call(one))
assertEquals(one, ::nonNullTopLevel.call())
assertEquals(one, ::nonNullTopLevel.getter.call())
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, ::nullableTopLevel.setter.call(one))
assertEquals(one, ::nullableTopLevel.call())
assertEquals(one, ::nullableTopLevel.getter.call())
}
assertEquals(Unit, ::nullableTopLevel.setter.call(one))
assertEquals(one, ::nullableTopLevel.call())
assertEquals(one, ::nullableTopLevel.getter.call())
assertEquals(Unit, Z::nonNull_nonNullExt.setter.call(Z(0), two))
assertEquals(three, Z::nonNull_nonNullExt.call(one))
assertEquals(three, Z::nonNull_nonNullExt.getter.call(one))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, Z::nonNull_nullableExt.setter.call(Z(0), two))
assertEquals(three, Z::nonNull_nullableExt.call(one))
assertEquals(three, Z::nonNull_nullableExt.getter.call(one))
}
assertEquals(Unit, Z::nonNull_nullableExt.setter.call(Z(0), two))
assertEquals(three, Z::nonNull_nullableExt.call(one))
assertEquals(three, Z::nonNull_nullableExt.getter.call(one))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, Z?::nullable_nonNullExt.setter.call(Z(0), two))
assertEquals(three, Z?::nullable_nonNullExt.call(one))
assertEquals(three, Z?::nullable_nonNullExt.getter.call(one))
}
assertEquals(Unit, Z?::nullable_nonNullExt.setter.call(Z(0), two))
assertEquals(three, Z?::nullable_nonNullExt.call(one))
assertEquals(three, Z?::nullable_nonNullExt.getter.call(one))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(Unit, Z?::nullable_nullableExt.setter.call(Z(0), two))
assertEquals(three, Z?::nullable_nullableExt.call(one))
assertEquals(three, Z?::nullable_nullableExt.getter.call(one))
}
assertEquals(Unit, Z?::nullable_nullableExt.setter.call(Z(0), two))
assertEquals(three, Z?::nullable_nullableExt.call(one))
assertEquals(three, Z?::nullable_nullableExt.getter.call(one))
return "OK"
}
@@ -39,12 +39,10 @@ fun box(): String {
}.let { assertEquals(1, it) }
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
run0 {
C::nullableConsume.callSuspend(c, Z(2))
C::nullableProduce.callSuspend(c)!!.value
}.let { assertEquals(2, it) }
}
run0 {
C::nullableConsume.callSuspend(c, Z(2))
C::nullableProduce.callSuspend(c)!!.value
}.let { assertEquals(2, it) }
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
run0 {
@@ -52,11 +50,9 @@ fun box(): String {
}.let { assertEquals(3, it) }
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
run0 {
C::nonNull_nullableConsumeAndProduce.callSuspend(c, Z(4))!!.value
}.let { assertEquals(4, it) }
}
run0 {
C::nonNull_nullableConsumeAndProduce.callSuspend(c, Z(4))!!.value
}.let { assertEquals(4, it) }
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
run0 {
@@ -64,11 +60,9 @@ fun box(): String {
}.let { assertEquals(5, it) }
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
run0 {
C::nullable_nullableConsumeAndProduce.callSuspend(c, Z(6))!!.value
}.let { assertEquals(6, it) }
}
run0 {
C::nullable_nullableConsumeAndProduce.callSuspend(c, Z(6))!!.value
}.let { assertEquals(6, it) }
return "OK"
}