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
@@ -4,7 +4,6 @@
import kotlin.reflect.KCallable import kotlin.reflect.KCallable
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val x: Int) { inline class Z(val x: Int) {
constructor(a: Int, b: Int) : this(a + b) constructor(a: Int, b: Int) : this(a + b)
@@ -53,9 +52,7 @@ fun box(): String {
assertEquals(A("abc"), (ctorA2 as KCallable<A>).call("a", "bc")) assertEquals(A("abc"), (ctorA2 as KCallable<A>).call("a", "bc"))
assertEquals(Z2(Z(42)), ::Z2.call(Z(42))) assertEquals(Z2(Z(42)), ::Z2.call(Z(42)))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Z3(Z(42)), ::Z3.call(Z(42)))
assertEquals(Z3(Z(42)), ::Z3.call(Z(42)))
}
return "OK" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class S(val x: String?) inline class S(val x: String?)
@@ -32,32 +31,20 @@ fun box(): String {
val z3 = S("3") val z3 = S("3")
val z4 = S("4") val z4 = S("4")
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { val outer = ::Outer.call(z1, z2)
val outer = ::Outer.call(z1, z2) assertEquals(z1, outer.z1)
assertEquals(z1, outer.z1) assertEquals(z2, outer.z2)
assertEquals(z2, outer.z2)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("S(x=1) S(x=2) S(x=3) S(x=4)", Outer::Inner.call(outer, z3, z4).test)
assertEquals("S(x=1) S(x=2) S(x=3) S(x=4)", Outer::Inner.call(outer, z3, z4).test) assertEquals("S(x=1) S(x=2) S(x=2) S(x=4)", outer::Inner.call(z2, z4).test)
assertEquals("S(x=1) S(x=2) S(x=2) S(x=4)", outer::Inner.call(z2, z4).test)
}
}
val inlineNonNullOuter = InlineNonNullOuter(z1) val inlineNonNullOuter = InlineNonNullOuter(z1)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("S(x=1) S(x=2) S(x=3)", InlineNonNullOuter::Inner.call(inlineNonNullOuter, z2, z3).test)
assertEquals("S(x=1) S(x=2) S(x=3)", InlineNonNullOuter::Inner.call(inlineNonNullOuter, z2, z3).test) assertEquals("S(x=1) S(x=2) S(x=2)", inlineNonNullOuter::Inner.call(z2, z2).test)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("S(x=1) S(x=2) S(x=2)", inlineNonNullOuter::Inner.call(z2, z2).test)
}
val inlineNullableOuter = InlineNullableOuter(z1) val inlineNullableOuter = InlineNullableOuter(z1)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("S(x=1) S(x=2) S(x=3)", InlineNullableOuter::Inner.call(inlineNullableOuter, z2, z3).test)
assertEquals("S(x=1) S(x=2) S(x=3)", InlineNullableOuter::Inner.call(inlineNullableOuter, z2, z3).test) assertEquals("S(x=1) S(x=2) S(x=2)", inlineNullableOuter::Inner.call(z2, z2).test)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("S(x=1) S(x=2) S(x=2)", inlineNullableOuter::Inner.call(z2, z2).test)
}
return "OK" return "OK"
} }
@@ -3,7 +3,6 @@
import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class S(val value: String?) { inline class S(val value: String?) {
operator fun plus(other: S): S = S(this.value!! + other.value!!) operator fun plus(other: S): S = S(this.value!! + other.value!!)
@@ -32,17 +31,13 @@ fun box(): String {
assertEquals(S("cd"), c.nonNullBoundRef().call()) assertEquals(S("cd"), c.nonNullBoundRef().call())
assertEquals(S("cd"), c.nonNullBoundRef().getter.call()) assertEquals(S("cd"), 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, S("ab")))
assertEquals(Unit, c.nullableUnboundRef().setter.call(c, S("ab"))) assertEquals(S("ab"), c.nullableUnboundRef().call(c))
assertEquals(S("ab"), c.nullableUnboundRef().call(c)) assertEquals(S("ab"), c.nullableUnboundRef().getter.call(c))
assertEquals(S("ab"), 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(S("cd")))
assertEquals(Unit, c.nullableBoundRef().setter.call(S("cd"))) assertEquals(S("cd"), c.nullableBoundRef().call())
assertEquals(S("cd"), c.nullableBoundRef().call()) assertEquals(S("cd"), c.nullableBoundRef().getter.call())
assertEquals(S("cd"), c.nullableBoundRef().getter.call())
}
val nonNullTopLevel = ::nonNullTopLevel.apply { isAccessible = true } val nonNullTopLevel = ::nonNullTopLevel.apply { isAccessible = true }
assertEquals(Unit, nonNullTopLevel.setter.call(S("ef"))) assertEquals(Unit, nonNullTopLevel.setter.call(S("ef")))
@@ -50,11 +45,9 @@ fun box(): String {
assertEquals(S("ef"), nonNullTopLevel.getter.call()) assertEquals(S("ef"), nonNullTopLevel.getter.call())
val nullableTopLevel = ::nullableTopLevel.apply { isAccessible = true } 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(S("ef")))
assertEquals(Unit, nullableTopLevel.setter.call(S("ef"))) assertEquals(S("ef"), nullableTopLevel.call())
assertEquals(S("ef"), nullableTopLevel.call()) assertEquals(S("ef"), nullableTopLevel.getter.call())
assertEquals(S("ef"), nullableTopLevel.getter.call())
}
return "OK" return "OK"
} }
@@ -23,26 +23,14 @@ fun S.extension3(): String = value!!
fun S?.extension4(): String = this!!.value!! fun S?.extension4(): String = this!!.value!!
fun box(): String { fun box(): String {
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("abc"), C::member.call(C(), S("a"), "b", S("c")))
assertEquals(S("abc"), C::member.call(C(), S("a"), "b", S("c"))) assertEquals(S("def"), ::topLevel.call("d", S("e"), S("f")))
} assertEquals(S("ghi"), S::extension1.call(S("g"), S("h"), S("i")))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("jkl"), S::extension2.call(S("j"), S("k"), S("l")))
assertEquals(S("def"), ::topLevel.call("d", S("e"), S("f")))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("ghi"), S::extension1.call(S("g"), S("h"), S("i")))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("jkl"), S::extension2.call(S("j"), S("k"), S("l")))
}
assertEquals("_", S::extension3.call(S("_"))) assertEquals("_", S::extension3.call(S("_")))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("_", S?::extension4.call(S("_")))
assertEquals("_", S?::extension4.call(S("_")))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("mno"), C()::member.call(S("m"), "n", S("o")))
assertEquals(S("mno"), C()::member.call(S("m"), "n", S("o")))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("pqr"), S("p")::extension1.call(S("q"), "r")) assertEquals(S("pqr"), S("p")::extension1.call(S("q"), "r"))
} }
@@ -5,7 +5,6 @@
import kotlin.reflect.KMutableProperty1 import kotlin.reflect.KMutableProperty1
import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class S(val value: String?) { inline class S(val value: String?) {
operator fun plus(other: S): S = S(this.value!! + other.value!!) operator fun plus(other: S): S = S(this.value!! + other.value!!)
@@ -31,11 +30,9 @@ fun box(): String {
val nullableUnboundRef = C::class.members.single { it.name == "p2" } as KMutableProperty1<C, S?> val nullableUnboundRef = C::class.members.single { it.name == "p2" } as KMutableProperty1<C, S?>
nullableUnboundRef.isAccessible = true nullableUnboundRef.isAccessible = true
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Unit, nullableUnboundRef.setter.call(C, S("ab")))
assertEquals(Unit, nullableUnboundRef.setter.call(C, S("ab"))) assertEquals(S("ab"), nullableUnboundRef.call(C))
assertEquals(S("ab"), nullableUnboundRef.call(C)) assertEquals(S("ab"), nullableUnboundRef.getter.call(C))
assertEquals(S("ab"), nullableUnboundRef.getter.call(C))
}
val nonNullBoundRef = C.nonNullBoundRef() val nonNullBoundRef = C.nonNullBoundRef()
assertEquals(Unit, nonNullBoundRef.setter.call(S("cd"))) assertEquals(Unit, nonNullBoundRef.setter.call(S("cd")))
@@ -43,11 +40,9 @@ fun box(): String {
assertEquals(S("cd"), nonNullBoundRef.getter.call()) assertEquals(S("cd"), nonNullBoundRef.getter.call())
val nullableBoundRef = C.nullableBoundRef() val nullableBoundRef = C.nullableBoundRef()
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Unit, nullableBoundRef.setter.call(S("cd")))
assertEquals(Unit, nullableBoundRef.setter.call(S("cd"))) assertEquals(S("cd"), nullableBoundRef.call())
assertEquals(S("cd"), nullableBoundRef.call()) assertEquals(S("cd"), nullableBoundRef.getter.call())
assertEquals(S("cd"), nullableBoundRef.getter.call())
}
return "OK" return "OK"
} }
@@ -4,7 +4,6 @@
import kotlin.reflect.KFunction import kotlin.reflect.KFunction
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class S(val value: String?) { inline class S(val value: String?) {
operator fun plus(other: S): S = S(this.value!! + other.value!!) operator fun plus(other: S): S = S(this.value!! + other.value!!)
@@ -23,22 +22,14 @@ interface I {
} }
fun box(): String { fun box(): String {
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("abc"), C::foo.call(S("a"), "b", S("c")))
assertEquals(S("abc"), C::foo.call(S("a"), "b", S("c"))) assertEquals(S("def"), (I)::bar.call("d", S("e"), S("f")))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("def"), (I)::bar.call("d", S("e"), S("f")))
}
val unboundFoo = C::class.members.single { it.name == "foo" } as KFunction<*> 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(S("ghi"), unboundFoo.call(C, S("g"), "h", S("i")))
assertEquals(S("ghi"), unboundFoo.call(C, S("g"), "h", S("i")))
}
val unboundBar = I.Companion::class.members.single { it.name == "bar" } as KFunction<*> 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(S("jkl"), unboundBar.call(I, "j", S("k"), S("l")))
assertEquals(S("jkl"), unboundBar.call(I, "j", S("k"), S("l")))
}
return "OK" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class S(val x: String?) { inline class S(val x: String?) {
fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}"
@@ -20,26 +19,14 @@ fun box(): String {
val plus = S("+") val plus = S("+")
val aster = S("*") val aster = S("*")
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("42-+*", S::test.call(S("42"), "-", plus, aster))
assertEquals("42-+*", S::test.call(S("42"), "-", plus, aster)) assertEquals("42-+*", S("42")::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("42-+*", S("42")::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("42-+*", Z::test.call(Z(42), "-", plus, aster))
assertEquals("42-+*", Z::test.call(Z(42), "-", plus, aster)) assertEquals("42-+*", Z(42)::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("42-+*", Z(42)::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster))
assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster)) assertEquals("42-+*", A("42")::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("42-+*", A("42")::test.call("-", plus, aster))
}
return "OK" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
var global = S("") var global = S("")
@@ -60,26 +59,14 @@ fun box(): String {
assertEquals(S("S+42"), global) assertEquals(S("S+42"), global)
global = S("") global = S("")
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), S::nullableTest.call(S("42")))
assertEquals(S("42"), S::nullableTest.call(S("42"))) assertEquals(S("42"), S("42")::nullableTest.call())
} assertEquals(S("42"), S::nullableTest.getter.call(S("42")))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), S("42")::nullableTest.getter.call())
assertEquals(S("42"), S("42")::nullableTest.call()) S::nullableTest.setter.call(S("42"), S("S-"))
} assertEquals(S("S-42"), global)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { S("42")::nullableTest.setter.call(S("S+"))
assertEquals(S("42"), S::nullableTest.getter.call(S("42"))) assertEquals(S("S+42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("42"), S("42")::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
S::nullableTest.setter.call(S("42"), S("S-"))
assertEquals(S("S-42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
S("42")::nullableTest.setter.call(S("S+"))
assertEquals(S("S+42"), global)
}
global = S("") global = S("")
assertEquals(S("42"), Z::nonNullTest.call(Z(42))) assertEquals(S("42"), Z::nonNullTest.call(Z(42)))
@@ -92,26 +79,14 @@ fun box(): String {
assertEquals(S("Z+42"), global) assertEquals(S("Z+42"), global)
global = S("") global = S("")
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), Z::nullableTest.call(Z(42)))
assertEquals(S("42"), Z::nullableTest.call(Z(42))) assertEquals(S("42"), Z(42)::nullableTest.call())
} assertEquals(S("42"), Z::nullableTest.getter.call(Z(42)))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), Z(42)::nullableTest.getter.call())
assertEquals(S("42"), Z(42)::nullableTest.call()) Z::nullableTest.setter.call(Z(42), S("Z-"))
} assertEquals(S("Z-42"), global)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { Z(42)::nullableTest.setter.call(S("Z+"))
assertEquals(S("42"), Z::nullableTest.getter.call(Z(42))) assertEquals(S("Z+42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("42"), Z(42)::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
Z::nullableTest.setter.call(Z(42), S("Z-"))
assertEquals(S("Z-42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
Z(42)::nullableTest.setter.call(S("Z+"))
assertEquals(S("Z+42"), global)
}
global = S("") global = S("")
assertEquals(S("42"), A::nonNullTest.call(A(42))) assertEquals(S("42"), A::nonNullTest.call(A(42)))
@@ -124,26 +99,14 @@ fun box(): String {
assertEquals(S("A+42"), global) assertEquals(S("A+42"), global)
global = S("") global = S("")
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), A::nullableTest.call(A(42)))
assertEquals(S("42"), A::nullableTest.call(A(42))) assertEquals(S("42"), A(42)::nullableTest.call())
} assertEquals(S("42"), A::nullableTest.getter.call(A(42)))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), A(42)::nullableTest.getter.call())
assertEquals(S("42"), A(42)::nullableTest.call()) A::nullableTest.setter.call(A(42), S("A-"))
} assertEquals(S("A-42"), global)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { A(42)::nullableTest.setter.call(S("A+"))
assertEquals(S("42"), A::nullableTest.getter.call(A(42))) assertEquals(S("A+42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("42"), A(42)::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
A::nullableTest.setter.call(A(42), S("A-"))
assertEquals(S("A-42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
A(42)::nullableTest.setter.call(S("A+"))
assertEquals(S("A+42"), global)
}
return "OK" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
interface ITest { interface ITest {
fun test(a: String, b: S, c: S?): String fun test(a: String, b: S, c: S?): String
@@ -24,26 +23,14 @@ fun box(): String {
val plus = S("+") val plus = S("+")
val aster = S("*") val aster = S("*")
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("42-+*", S::test.call(S("42"), "-", plus, aster))
assertEquals("42-+*", S::test.call(S("42"), "-", plus, aster)) assertEquals("42-+*", S("42")::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("42-+*", S("42")::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("42-+*", Z::test.call(Z(42), "-", plus, aster))
assertEquals("42-+*", Z::test.call(Z(42), "-", plus, aster)) assertEquals("42-+*", Z(42)::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("42-+*", Z(42)::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster))
assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster)) assertEquals("42-+*", A("42")::test.call("-", plus, aster))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals("42-+*", A("42")::test.call("-", plus, aster))
}
return "OK" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
var global = S("") var global = S("")
@@ -65,26 +64,14 @@ fun box(): String {
assertEquals(S("S+42"), global) assertEquals(S("S+42"), global)
global = S("") global = S("")
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), S::nullableTest.call(S("42")))
assertEquals(S("42"), S::nullableTest.call(S("42"))) assertEquals(S("42"), S("42")::nullableTest.call())
} assertEquals(S("42"), S::nullableTest.getter.call(S("42")))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), S("42")::nullableTest.getter.call())
assertEquals(S("42"), S("42")::nullableTest.call()) S::nullableTest.setter.call(S("42"), S("S-"))
} assertEquals(S("S-42"), global)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { S("42")::nullableTest.setter.call(S("S+"))
assertEquals(S("42"), S::nullableTest.getter.call(S("42"))) assertEquals(S("S+42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("42"), S("42")::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
S::nullableTest.setter.call(S("42"), S("S-"))
assertEquals(S("S-42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
S("42")::nullableTest.setter.call(S("S+"))
assertEquals(S("S+42"), global)
}
global = S("") global = S("")
assertEquals(S("42"), Z::nonNullTest.call(Z(42))) assertEquals(S("42"), Z::nonNullTest.call(Z(42)))
@@ -97,26 +84,14 @@ fun box(): String {
assertEquals(S("Z+42"), global) assertEquals(S("Z+42"), global)
global = S("") global = S("")
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), Z::nullableTest.call(Z(42)))
assertEquals(S("42"), Z::nullableTest.call(Z(42))) assertEquals(S("42"), Z(42)::nullableTest.call())
} assertEquals(S("42"), Z::nullableTest.getter.call(Z(42)))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), Z(42)::nullableTest.getter.call())
assertEquals(S("42"), Z(42)::nullableTest.call()) Z::nullableTest.setter.call(Z(42), S("Z-"))
} assertEquals(S("Z-42"), global)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { Z(42)::nullableTest.setter.call(S("Z+"))
assertEquals(S("42"), Z::nullableTest.getter.call(Z(42))) assertEquals(S("Z+42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("42"), Z(42)::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
Z::nullableTest.setter.call(Z(42), S("Z-"))
assertEquals(S("Z-42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
Z(42)::nullableTest.setter.call(S("Z+"))
assertEquals(S("Z+42"), global)
}
global = S("") global = S("")
assertEquals(S("42"), A::nonNullTest.call(A(42))) assertEquals(S("42"), A::nonNullTest.call(A(42)))
@@ -129,26 +104,14 @@ fun box(): String {
assertEquals(S("A+42"), global) assertEquals(S("A+42"), global)
global = S("") global = S("")
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), A::nullableTest.call(A(42)))
assertEquals(S("42"), A::nullableTest.call(A(42))) assertEquals(S("42"), A(42)::nullableTest.call())
} assertEquals(S("42"), A::nullableTest.getter.call(A(42)))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(S("42"), A(42)::nullableTest.getter.call())
assertEquals(S("42"), A(42)::nullableTest.call()) A::nullableTest.setter.call(A(42), S("A-"))
} assertEquals(S("A-42"), global)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { A(42)::nullableTest.setter.call(S("A+"))
assertEquals(S("42"), A::nullableTest.getter.call(A(42))) assertEquals(S("A+42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(S("42"), A(42)::nullableTest.getter.call())
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
A::nullableTest.setter.call(A(42), S("A-"))
assertEquals(S("A-42"), global)
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
A(42)::nullableTest.setter.call(S("A+"))
assertEquals(S("A+42"), global)
}
return "OK" return "OK"
} }
@@ -3,7 +3,6 @@
import kotlin.reflect.KMutableProperty2 import kotlin.reflect.KMutableProperty2
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class S(val value: String?) { inline class S(val value: String?) {
operator fun plus(other: S): S = S(this.value!! + other.value!!) operator fun plus(other: S): S = S(this.value!! + other.value!!)
@@ -61,17 +60,13 @@ fun box(): String {
assertEquals(S("cd"), c::nonNullMember.call()) assertEquals(S("cd"), c::nonNullMember.call())
assertEquals(S("cd"), c::nonNullMember.getter.call()) assertEquals(S("cd"), 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, S("ab")))
assertEquals(Unit, C::nullableMember.setter.call(c, S("ab"))) assertEquals(S("ab"), C::nullableMember.call(c))
assertEquals(S("ab"), C::nullableMember.call(c)) assertEquals(S("ab"), C::nullableMember.getter.call(c))
assertEquals(S("ab"), 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(S("cd")))
assertEquals(Unit, c::nullableMember.setter.call(S("cd"))) assertEquals(S("cd"), c::nullableMember.call())
assertEquals(S("cd"), c::nullableMember.call()) assertEquals(S("cd"), c::nullableMember.getter.call())
assertEquals(S("cd"), c::nullableMember.getter.call())
}
val nonNull_nonNullMemExt = C::class.members.single { it.name == "nonNull_nonNullMemExt" } as KMutableProperty2<C, S, S> val nonNull_nonNullMemExt = C::class.members.single { it.name == "nonNull_nonNullMemExt" } as KMutableProperty2<C, S, S>
assertEquals(Unit, nonNull_nonNullMemExt.setter.call(c, S(""), S("f"))) assertEquals(Unit, nonNull_nonNullMemExt.setter.call(c, S(""), S("f")))
@@ -79,57 +74,43 @@ fun box(): String {
assertEquals(S("ef"), nonNull_nonNullMemExt.getter.call(c, S("e"))) assertEquals(S("ef"), nonNull_nonNullMemExt.getter.call(c, S("e")))
val nonNull_nullableMemExt = C::class.members.single { it.name == "nonNull_nullableMemExt" } as KMutableProperty2<C, S, S?> val nonNull_nullableMemExt = C::class.members.single { it.name == "nonNull_nullableMemExt" } as KMutableProperty2<C, S, S?>
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Unit, nonNull_nullableMemExt.setter.call(c, S(""), S("f")))
assertEquals(Unit, nonNull_nullableMemExt.setter.call(c, S(""), S("f"))) assertEquals(S("ef"), nonNull_nullableMemExt.call(c, S("e")))
assertEquals(S("ef"), nonNull_nullableMemExt.call(c, S("e"))) assertEquals(S("ef"), nonNull_nullableMemExt.getter.call(c, S("e")))
assertEquals(S("ef"), nonNull_nullableMemExt.getter.call(c, S("e")))
}
val nullable_nonNullMemExt = C::class.members.single { it.name == "nullable_nonNullMemExt" } as KMutableProperty2<C, S?, S> val nullable_nonNullMemExt = C::class.members.single { it.name == "nullable_nonNullMemExt" } as KMutableProperty2<C, S?, S>
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Unit, nullable_nonNullMemExt.setter.call(c, S(""), S("f")))
assertEquals(Unit, nullable_nonNullMemExt.setter.call(c, S(""), S("f"))) assertEquals(S("ef"), nullable_nonNullMemExt.call(c, S("e")))
assertEquals(S("ef"), nullable_nonNullMemExt.call(c, S("e"))) assertEquals(S("ef"), nullable_nonNullMemExt.getter.call(c, S("e")))
assertEquals(S("ef"), nullable_nonNullMemExt.getter.call(c, S("e")))
}
val nullable_nullableMemExt = C::class.members.single { it.name == "nullable_nullableMemExt" } as KMutableProperty2<C, S?, S?> val nullable_nullableMemExt = C::class.members.single { it.name == "nullable_nullableMemExt" } as KMutableProperty2<C, S?, S?>
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Unit, nullable_nullableMemExt.setter.call(c, S(""), S("f")))
assertEquals(Unit, nullable_nullableMemExt.setter.call(c, S(""), S("f"))) assertEquals(S("ef"), nullable_nullableMemExt.call(c, S("e")))
assertEquals(S("ef"), nullable_nullableMemExt.call(c, S("e"))) assertEquals(S("ef"), nullable_nullableMemExt.getter.call(c, S("e")))
assertEquals(S("ef"), nullable_nullableMemExt.getter.call(c, S("e")))
}
assertEquals(Unit, ::nonNullTopLevel.setter.call(S("gh"))) assertEquals(Unit, ::nonNullTopLevel.setter.call(S("gh")))
assertEquals(S("gh"), ::nonNullTopLevel.call()) assertEquals(S("gh"), ::nonNullTopLevel.call())
assertEquals(S("gh"), ::nonNullTopLevel.getter.call()) assertEquals(S("gh"), ::nonNullTopLevel.getter.call())
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Unit, ::nullableTopLevel.setter.call(S("gh")))
assertEquals(Unit, ::nullableTopLevel.setter.call(S("gh"))) assertEquals(S("gh"), ::nullableTopLevel.call())
assertEquals(S("gh"), ::nullableTopLevel.call()) assertEquals(S("gh"), ::nullableTopLevel.getter.call())
assertEquals(S("gh"), ::nullableTopLevel.getter.call())
}
assertEquals(Unit, S::nonNull_nonNullExt.setter.call(S(""), S("j"))) assertEquals(Unit, S::nonNull_nonNullExt.setter.call(S(""), S("j")))
assertEquals(S("ij"), S::nonNull_nonNullExt.call(S("i"))) assertEquals(S("ij"), S::nonNull_nonNullExt.call(S("i")))
assertEquals(S("ij"), S::nonNull_nonNullExt.getter.call(S("i"))) assertEquals(S("ij"), S::nonNull_nonNullExt.getter.call(S("i")))
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Unit, S::nonNull_nullableExt.setter.call(S(""), S("j")))
assertEquals(Unit, S::nonNull_nullableExt.setter.call(S(""), S("j"))) assertEquals(S("ij"), S::nonNull_nullableExt.call(S("i")))
assertEquals(S("ij"), S::nonNull_nullableExt.call(S("i"))) assertEquals(S("ij"), S::nonNull_nullableExt.getter.call(S("i")))
assertEquals(S("ij"), S::nonNull_nullableExt.getter.call(S("i")))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Unit, S?::nullable_nonNullExt.setter.call(S(""), S("j")))
assertEquals(Unit, S?::nullable_nonNullExt.setter.call(S(""), S("j"))) assertEquals(S("ij"), S?::nullable_nonNullExt.call(S("i")))
assertEquals(S("ij"), S?::nullable_nonNullExt.call(S("i"))) assertEquals(S("ij"), S?::nullable_nonNullExt.getter.call(S("i")))
assertEquals(S("ij"), S?::nullable_nonNullExt.getter.call(S("i")))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(Unit, S?::nullable_nullableExt.setter.call(S(""), S("j")))
assertEquals(Unit, S?::nullable_nullableExt.setter.call(S(""), S("j"))) assertEquals(S("ij"), S?::nullable_nullableExt.call(S("i")))
assertEquals(S("ij"), S?::nullable_nullableExt.call(S("i"))) assertEquals(S("ij"), S?::nullable_nullableExt.getter.call(S("i")))
assertEquals(S("ij"), S?::nullable_nullableExt.getter.call(S("i")))
}
return "OK" return "OK"
} }
@@ -5,7 +5,6 @@
import kotlin.coroutines.startCoroutine import kotlin.coroutines.startCoroutine
import kotlin.reflect.full.callSuspend import kotlin.reflect.full.callSuspend
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import helpers.* import helpers.*
inline class S(val value: String?) inline class S(val value: String?)
@@ -37,34 +36,26 @@ fun box(): String {
C::nonNullProduce.callSuspend(c).value!! C::nonNullProduce.callSuspend(c).value!!
}.let { assertEquals("nonNull", it) } }.let { assertEquals("nonNull", it) }
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { run0 {
run0 { C::nullableConsume.callSuspend(c, S("nullable"))
C::nullableConsume.callSuspend(c, S("nullable")) C::nullableProduce.callSuspend(c)!!.value!!
C::nullableProduce.callSuspend(c)!!.value!! }.let { assertEquals("nullable", it) }
}.let { assertEquals("nullable", it) }
}
run0 { run0 {
C::nonNull_nonNullConsumeAndProduce.callSuspend(c, S("nonNull_nonNull")).value!! C::nonNull_nonNullConsumeAndProduce.callSuspend(c, S("nonNull_nonNull")).value!!
}.let { assertEquals("nonNull_nonNull", it) } }.let { assertEquals("nonNull_nonNull", it) }
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { run0 {
run0 { C::nonNull_nullableConsumeAndProduce.callSuspend(c, S("nonNull_nullable"))!!.value!!
C::nonNull_nullableConsumeAndProduce.callSuspend(c, S("nonNull_nullable"))!!.value!! }.let { assertEquals("nonNull_nullable", it) }
}.let { assertEquals("nonNull_nullable", it) }
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { run0 {
run0 { C::nullable_nonNullConsumeAndProduce.callSuspend(c, S("nullable_nonNull")).value!!
C::nullable_nonNullConsumeAndProduce.callSuspend(c, S("nullable_nonNull")).value!! }.let { assertEquals("nullable_nonNull", it) }
}.let { assertEquals("nullable_nonNull", it) }
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { run0 {
run0 { C::nullable_nullableConsumeAndProduce.callSuspend(c, S("nullable_nullable"))!!.value!!
C::nullable_nullableConsumeAndProduce.callSuspend(c, S("nullable_nullable"))!!.value!! }.let { assertEquals("nullable_nullable", it) }
}.let { assertEquals("nullable_nullable", it) }
}
return "OK" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val x: Int) inline class Z(val x: Int)
@@ -32,28 +31,20 @@ fun box(): String {
val z3 = Z(3) val z3 = Z(3)
val z4 = Z(4) val z4 = Z(4)
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { val outer = ::Outer.call(z1, z2)
val outer = ::Outer.call(z1, z2) assertEquals(z1, outer.z1)
assertEquals(z1, outer.z1) assertEquals(z2, outer.z2)
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=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=2) Z(x=4)", outer::Inner.call(z2, z4).test)
}
}
val inlineNonNullOuter = InlineNonNullOuter(z1) 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=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=2)", inlineNonNullOuter::Inner.call(z2, z2).test)
}
val inlineNullableOuter = InlineNullableOuter(z1) 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=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=2)", inlineNullableOuter::Inner.call(z2, z2).test)
}
return "OK" return "OK"
} }
@@ -3,7 +3,6 @@
import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class S(val value: Int) { inline class S(val value: Int) {
operator fun plus(other: S): S = S(this.value + other.value) 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().call())
assertEquals(one, c.nonNullBoundRef().getter.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(Unit, c.nullableUnboundRef().setter.call(c, zero)) assertEquals(zero, c.nullableUnboundRef().call(c))
assertEquals(zero, c.nullableUnboundRef().call(c)) assertEquals(zero, c.nullableUnboundRef().getter.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(Unit, c.nullableBoundRef().setter.call(one)) assertEquals(one, c.nullableBoundRef().call())
assertEquals(one, c.nullableBoundRef().call()) assertEquals(one, c.nullableBoundRef().getter.call())
assertEquals(one, c.nullableBoundRef().getter.call())
}
val nonNullTopLevel = ::nonNullTopLevel.apply { isAccessible = true } val nonNullTopLevel = ::nonNullTopLevel.apply { isAccessible = true }
assertEquals(Unit, nonNullTopLevel.setter.call(two)) assertEquals(Unit, nonNullTopLevel.setter.call(two))
@@ -54,11 +49,9 @@ fun box(): String {
assertEquals(two, nonNullTopLevel.getter.call()) assertEquals(two, nonNullTopLevel.getter.call())
val nullableTopLevel = ::nullableTopLevel.apply { isAccessible = true } 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(Unit, nullableTopLevel.setter.call(two)) assertEquals(two, nullableTopLevel.call())
assertEquals(two, nullableTopLevel.call()) assertEquals(two, nullableTopLevel.getter.call())
assertEquals(two, nullableTopLevel.getter.call())
}
return "OK" return "OK"
} }
@@ -29,32 +29,16 @@ fun box(): String {
val four = S(4) val four = S(4)
val seven = S(7) 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))
assertEquals(seven, C::member.call(C(), one, 2, four)) assertEquals(seven, ::topLevel.call(1, two, four))
} 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, ::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(0, S::extension3.call(zero)) 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))
assertEquals(seven, C()::member.call(one, 2, four)) assertEquals(seven, one::extension1.call(two, four))
} assertEquals(seven, one::extension2.call(two, 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(0, zero::extension3.call()) assertEquals(0, zero::extension3.call())
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(0, zero::extension4.call(zero)) assertEquals(0, zero::extension4.call(zero))
@@ -5,7 +5,6 @@
import kotlin.reflect.KMutableProperty1 import kotlin.reflect.KMutableProperty1
import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.isAccessible
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val value: Int) { inline class Z(val value: Int) {
operator fun plus(other: Z): Z = Z(this.value + other.value) 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?> val nullableUnboundRef = C::class.members.single { it.name == "p2" } as KMutableProperty1<C, Z?>
nullableUnboundRef.isAccessible = true 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(Unit, nullableUnboundRef.setter.call(C, one)) assertEquals(one, nullableUnboundRef.call(C))
assertEquals(one, nullableUnboundRef.call(C)) assertEquals(one, nullableUnboundRef.getter.call(C))
assertEquals(one, nullableUnboundRef.getter.call(C))
}
val nonNullBoundRef = C.nonNullBoundRef() val nonNullBoundRef = C.nonNullBoundRef()
assertEquals(Unit, nonNullBoundRef.setter.call(two)) assertEquals(Unit, nonNullBoundRef.setter.call(two))
@@ -46,11 +43,9 @@ fun box(): String {
assertEquals(two, nonNullBoundRef.getter.call()) assertEquals(two, nonNullBoundRef.getter.call())
val nullableBoundRef = C.nullableBoundRef() 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(Unit, nullableBoundRef.setter.call(two)) assertEquals(two, nullableBoundRef.call())
assertEquals(two, nullableBoundRef.call()) assertEquals(two, nullableBoundRef.getter.call())
assertEquals(two, nullableBoundRef.getter.call())
}
return "OK" return "OK"
} }
@@ -4,7 +4,6 @@
import kotlin.reflect.KFunction import kotlin.reflect.KFunction
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val value: Int) { inline class Z(val value: Int) {
operator fun plus(other: Z): Z = Z(this.value + other.value) operator fun plus(other: Z): Z = Z(this.value + other.value)
@@ -28,22 +27,14 @@ fun box(): String {
val four = Z(4) val four = Z(4)
val seven = Z(7) 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))
assertEquals(seven, C::foo.call(one, 2, four)) assertEquals(seven, (I)::bar.call(1, two, four))
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
assertEquals(seven, (I)::bar.call(1, two, four))
}
val unboundFoo = C::class.members.single { it.name == "foo" } as KFunction<*> 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<*> 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" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val x: Int) { inline class Z(val x: Int) {
fun test(a: Int, b: Z, c: Z?) = "$x$a${b.x}${c!!.x}" 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 two = Z(2)
val four = Z(4) 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))
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", 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))
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", 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))
assertEquals("0124", A::test.call(A(0), 1, two, four)) assertEquals("0124", A(0)::test.call(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))
}
return "OK" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
var global = Z(0) var global = Z(0)
@@ -71,26 +70,14 @@ fun box(): String {
assertEquals(zFour, global) assertEquals(zFour, global)
global = zZero global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(zOne, Z::nullableTest.call(zOne))
assertEquals(zOne, Z::nullableTest.call(zOne)) assertEquals(zOne, zOne::nullableTest.call())
} 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())
assertEquals(zOne, zOne::nullableTest.call()) 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(zOne, Z::nullableTest.getter.call(zOne)) assertEquals(zFour, global)
}
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)
}
global = zZero global = zZero
assertEquals(zOne, S::nonNullTest.call(sOne)) assertEquals(zOne, S::nonNullTest.call(sOne))
@@ -103,26 +90,14 @@ fun box(): String {
assertEquals(zFour, global) assertEquals(zFour, global)
global = zZero global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(zOne, S::nullableTest.call(sOne))
assertEquals(zOne, S::nullableTest.call(sOne)) assertEquals(zOne, sOne::nullableTest.call())
} 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())
assertEquals(zOne, sOne::nullableTest.call()) 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(zOne, S::nullableTest.getter.call(sOne)) assertEquals(zFour, global)
}
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)
}
global = zZero global = zZero
assertEquals(zOne, A::nonNullTest.call(aOne)) assertEquals(zOne, A::nonNullTest.call(aOne))
@@ -135,26 +110,14 @@ fun box(): String {
assertEquals(zFour, global) assertEquals(zFour, global)
global = zZero global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(zOne, A::nullableTest.call(aOne))
assertEquals(zOne, A::nullableTest.call(aOne)) assertEquals(zOne, aOne::nullableTest.call())
} 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())
assertEquals(zOne, aOne::nullableTest.call()) 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(zOne, A::nullableTest.getter.call(aOne)) assertEquals(zFour, global)
}
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)
}
return "OK" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
interface ITest { interface ITest {
fun test(a: Int, b: Z, c: Z?): String fun test(a: Int, b: Z, c: Z?): String
@@ -24,26 +23,14 @@ fun box(): String {
val two = Z(2) val two = Z(2)
val four = Z(4) 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))
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", 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))
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", 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))
assertEquals("0124", A::test.call(A(0), 1, two, four)) assertEquals("0124", A(0)::test.call(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))
}
return "OK" return "OK"
} }
@@ -2,7 +2,6 @@
// WITH_REFLECT // WITH_REFLECT
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
var global = Z(0) var global = Z(0)
@@ -76,26 +75,14 @@ fun box(): String {
assertEquals(zFour, global) assertEquals(zFour, global)
global = zZero global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(zOne, Z::nullableTest.call(zOne))
assertEquals(zOne, Z::nullableTest.call(zOne)) assertEquals(zOne, zOne::nullableTest.call())
} 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())
assertEquals(zOne, zOne::nullableTest.call()) 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(zOne, Z::nullableTest.getter.call(zOne)) assertEquals(zFour, global)
}
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)
}
global = zZero global = zZero
assertEquals(zOne, S::nonNullTest.call(sOne)) assertEquals(zOne, S::nonNullTest.call(sOne))
@@ -108,26 +95,14 @@ fun box(): String {
assertEquals(zFour, global) assertEquals(zFour, global)
global = zZero global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(zOne, S::nullableTest.call(sOne))
assertEquals(zOne, S::nullableTest.call(sOne)) assertEquals(zOne, sOne::nullableTest.call())
} 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())
assertEquals(zOne, sOne::nullableTest.call()) 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(zOne, S::nullableTest.getter.call(sOne)) assertEquals(zFour, global)
}
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)
}
global = zZero global = zZero
assertEquals(zOne, A::nonNullTest.call(aOne)) assertEquals(zOne, A::nonNullTest.call(aOne))
@@ -140,26 +115,14 @@ fun box(): String {
assertEquals(zFour, global) assertEquals(zFour, global)
global = zZero global = zZero
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertEquals(zOne, A::nullableTest.call(aOne))
assertEquals(zOne, A::nullableTest.call(aOne)) assertEquals(zOne, aOne::nullableTest.call())
} 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())
assertEquals(zOne, aOne::nullableTest.call()) 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(zOne, A::nullableTest.getter.call(aOne)) assertEquals(zFour, global)
}
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)
}
return "OK" return "OK"
} }
@@ -3,7 +3,6 @@
import kotlin.reflect.KMutableProperty2 import kotlin.reflect.KMutableProperty2
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
inline class Z(val value: Int) { inline class Z(val value: Int) {
operator fun plus(other: Z): Z = Z(this.value + other.value) 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.call())
assertEquals(two, c::nonNullMember.getter.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(Unit, C::nullableMember.setter.call(c, one)) assertEquals(one, C::nullableMember.call(c))
assertEquals(one, C::nullableMember.call(c)) assertEquals(one, C::nullableMember.getter.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(Unit, c::nullableMember.setter.call(two)) assertEquals(two, c::nullableMember.call())
assertEquals(two, c::nullableMember.call()) assertEquals(two, c::nullableMember.getter.call())
assertEquals(two, c::nullableMember.getter.call())
}
val nonNull_nonNullMemExt = C::class.members.single { it.name == "nonNull_nonNullMemExt" } as KMutableProperty2<C, Z, Z> 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)) 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)) assertEquals(three, nonNull_nonNullMemExt.getter.call(c, one))
val nonNull_nullableMemExt = C::class.members.single { it.name == "nonNull_nullableMemExt" } as KMutableProperty2<C, Z, Z?> 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(Unit, nonNull_nullableMemExt.setter.call(c, Z(0), two)) assertEquals(three, nonNull_nullableMemExt.call(c, one))
assertEquals(three, nonNull_nullableMemExt.call(c, one)) assertEquals(three, nonNull_nullableMemExt.getter.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> 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(Unit, nullable_nonNullMemExt.setter.call(c, Z(0), two)) assertEquals(three, nullable_nonNullMemExt.call(c, one))
assertEquals(three, nullable_nonNullMemExt.call(c, one)) assertEquals(three, nullable_nonNullMemExt.getter.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?> 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(Unit, nullable_nullableMemExt.setter.call(c, Z(0), two)) assertEquals(three, nullable_nullableMemExt.call(c, one))
assertEquals(three, nullable_nullableMemExt.call(c, one)) assertEquals(three, nullable_nullableMemExt.getter.call(c, one))
assertEquals(three, nullable_nullableMemExt.getter.call(c, one))
}
assertEquals(Unit, ::nonNullTopLevel.setter.call(one)) assertEquals(Unit, ::nonNullTopLevel.setter.call(one))
assertEquals(one, ::nonNullTopLevel.call()) assertEquals(one, ::nonNullTopLevel.call())
assertEquals(one, ::nonNullTopLevel.getter.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(Unit, ::nullableTopLevel.setter.call(one)) assertEquals(one, ::nullableTopLevel.call())
assertEquals(one, ::nullableTopLevel.call()) assertEquals(one, ::nullableTopLevel.getter.call())
assertEquals(one, ::nullableTopLevel.getter.call())
}
assertEquals(Unit, Z::nonNull_nonNullExt.setter.call(Z(0), two)) assertEquals(Unit, Z::nonNull_nonNullExt.setter.call(Z(0), two))
assertEquals(three, Z::nonNull_nonNullExt.call(one)) assertEquals(three, Z::nonNull_nonNullExt.call(one))
assertEquals(three, Z::nonNull_nonNullExt.getter.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(Unit, Z::nonNull_nullableExt.setter.call(Z(0), two)) assertEquals(three, Z::nonNull_nullableExt.call(one))
assertEquals(three, Z::nonNull_nullableExt.call(one)) assertEquals(three, Z::nonNull_nullableExt.getter.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(Unit, Z?::nullable_nonNullExt.setter.call(Z(0), two)) assertEquals(three, Z?::nullable_nonNullExt.call(one))
assertEquals(three, Z?::nullable_nonNullExt.call(one)) assertEquals(three, Z?::nullable_nonNullExt.getter.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(Unit, Z?::nullable_nullableExt.setter.call(Z(0), two)) assertEquals(three, Z?::nullable_nullableExt.call(one))
assertEquals(three, Z?::nullable_nullableExt.call(one)) assertEquals(three, Z?::nullable_nullableExt.getter.call(one))
assertEquals(three, Z?::nullable_nullableExt.getter.call(one))
}
return "OK" return "OK"
} }
@@ -39,12 +39,10 @@ fun box(): String {
}.let { assertEquals(1, it) } }.let { assertEquals(1, it) }
} }
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { run0 {
run0 { C::nullableConsume.callSuspend(c, Z(2))
C::nullableConsume.callSuspend(c, Z(2)) C::nullableProduce.callSuspend(c)!!.value
C::nullableProduce.callSuspend(c)!!.value }.let { assertEquals(2, it) }
}.let { assertEquals(2, it) }
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
run0 { run0 {
@@ -52,11 +50,9 @@ fun box(): String {
}.let { assertEquals(3, it) } }.let { assertEquals(3, it) }
} }
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { run0 {
run0 { C::nonNull_nullableConsumeAndProduce.callSuspend(c, Z(4))!!.value
C::nonNull_nullableConsumeAndProduce.callSuspend(c, Z(4))!!.value }.let { assertEquals(4, it) }
}.let { assertEquals(4, it) }
}
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
run0 { run0 {
@@ -64,11 +60,9 @@ fun box(): String {
}.let { assertEquals(5, it) } }.let { assertEquals(5, it) }
} }
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") { run0 {
run0 { C::nullable_nullableConsumeAndProduce.callSuspend(c, Z(6))!!.value
C::nullable_nullableConsumeAndProduce.callSuspend(c, Z(6))!!.value }.let { assertEquals(6, it) }
}.let { assertEquals(6, it) }
}
return "OK" return "OK"
} }
@@ -5,14 +5,13 @@
package kotlin.reflect.jvm.internal.calls package kotlin.reflect.jvm.internal.calls
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.resolve.descriptorUtil.classId
import org.jetbrains.kotlin.resolve.isGetterOfUnderlyingPropertyOfInlineClass
import org.jetbrains.kotlin.resolve.isInlineClass
import org.jetbrains.kotlin.resolve.isInlineClassType
import org.jetbrains.kotlin.resolve.isUnderlyingPropertyOfInlineClass
import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import java.lang.reflect.Member import java.lang.reflect.Member
import java.lang.reflect.Method import java.lang.reflect.Method
import java.lang.reflect.Type import java.lang.reflect.Type
@@ -176,8 +175,18 @@ internal fun Class<*>.getBoxMethod(descriptor: CallableMemberDescriptor): Method
throw KotlinReflectionInternalError("No box method found in inline class: $this (calling $descriptor)") throw KotlinReflectionInternalError("No box method found in inline class: $this (calling $descriptor)")
} }
internal fun KotlinType.toInlineClass(): Class<*>? = internal fun KotlinType.toInlineClass(): Class<*>? {
constructor.declarationDescriptor.toInlineClass() // See computeExpandedTypeForInlineClass.
// TODO: add tests on type parameters with inline class bounds.
// TODO: add tests on usages of inline classes in Java.
val klass = constructor.declarationDescriptor.toInlineClass() ?: return null
if (!TypeUtils.isNullableType(this)) return klass
val expandedUnderlyingType = unsubstitutedUnderlyingType() ?: return null
if (!TypeUtils.isNullableType(expandedUnderlyingType) && !KotlinBuiltIns.isPrimitiveType(expandedUnderlyingType)) return klass
return null
}
internal fun DeclarationDescriptor?.toInlineClass(): Class<*>? = internal fun DeclarationDescriptor?.toInlineClass(): Class<*>? =
if (this is ClassDescriptor && isInlineClass()) if (this is ClassDescriptor && isInlineClass())