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:
+1
-4
@@ -4,7 +4,6 @@
|
||||
|
||||
import kotlin.reflect.KCallable
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
inline class Z(val x: Int) {
|
||||
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(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"
|
||||
}
|
||||
|
||||
+9
-22
@@ -2,7 +2,6 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
inline class S(val x: String?)
|
||||
|
||||
@@ -32,32 +31,20 @@ fun box(): String {
|
||||
val z3 = S("3")
|
||||
val z4 = S("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("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=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)
|
||||
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
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)
|
||||
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
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)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Vendored
+9
-16
@@ -3,7 +3,6 @@
|
||||
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
inline class S(val value: String?) {
|
||||
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().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(S("ab"), c.nullableUnboundRef().call(c))
|
||||
assertEquals(S("ab"), c.nullableUnboundRef().getter.call(c))
|
||||
}
|
||||
assertEquals(Unit, c.nullableUnboundRef().setter.call(c, S("ab")))
|
||||
assertEquals(S("ab"), c.nullableUnboundRef().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(S("cd"), c.nullableBoundRef().call())
|
||||
assertEquals(S("cd"), c.nullableBoundRef().getter.call())
|
||||
}
|
||||
assertEquals(Unit, c.nullableBoundRef().setter.call(S("cd")))
|
||||
assertEquals(S("cd"), c.nullableBoundRef().call())
|
||||
assertEquals(S("cd"), c.nullableBoundRef().getter.call())
|
||||
|
||||
val nonNullTopLevel = ::nonNullTopLevel.apply { isAccessible = true }
|
||||
assertEquals(Unit, nonNullTopLevel.setter.call(S("ef")))
|
||||
@@ -50,11 +45,9 @@ fun box(): String {
|
||||
assertEquals(S("ef"), 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(S("ef")))
|
||||
assertEquals(S("ef"), nullableTopLevel.call())
|
||||
assertEquals(S("ef"), nullableTopLevel.getter.call())
|
||||
}
|
||||
assertEquals(Unit, nullableTopLevel.setter.call(S("ef")))
|
||||
assertEquals(S("ef"), nullableTopLevel.call())
|
||||
assertEquals(S("ef"), nullableTopLevel.getter.call())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+6
-18
@@ -23,26 +23,14 @@ fun S.extension3(): String = value!!
|
||||
fun S?.extension4(): String = this!!.value!!
|
||||
|
||||
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")))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
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("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")))
|
||||
assertEquals(S("jkl"), S::extension2.call(S("j"), S("k"), S("l")))
|
||||
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.") {
|
||||
assertEquals(S("pqr"), S("p")::extension1.call(S("q"), "r"))
|
||||
}
|
||||
|
||||
compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFieldInObject.kt
Vendored
+6
-11
@@ -5,7 +5,6 @@
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
inline class S(val value: String?) {
|
||||
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?>
|
||||
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(S("ab"), nullableUnboundRef.call(C))
|
||||
assertEquals(S("ab"), nullableUnboundRef.getter.call(C))
|
||||
}
|
||||
assertEquals(Unit, nullableUnboundRef.setter.call(C, S("ab")))
|
||||
assertEquals(S("ab"), nullableUnboundRef.call(C))
|
||||
assertEquals(S("ab"), nullableUnboundRef.getter.call(C))
|
||||
|
||||
val nonNullBoundRef = C.nonNullBoundRef()
|
||||
assertEquals(Unit, nonNullBoundRef.setter.call(S("cd")))
|
||||
@@ -43,11 +40,9 @@ fun box(): String {
|
||||
assertEquals(S("cd"), 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(S("cd")))
|
||||
assertEquals(S("cd"), nullableBoundRef.call())
|
||||
assertEquals(S("cd"), nullableBoundRef.getter.call())
|
||||
}
|
||||
assertEquals(Unit, nullableBoundRef.setter.call(S("cd")))
|
||||
assertEquals(S("cd"), nullableBoundRef.call())
|
||||
assertEquals(S("cd"), nullableBoundRef.getter.call())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Vendored
+4
-13
@@ -4,7 +4,6 @@
|
||||
|
||||
import kotlin.reflect.KFunction
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
inline class S(val value: String?) {
|
||||
operator fun plus(other: S): S = S(this.value!! + other.value!!)
|
||||
@@ -23,22 +22,14 @@ interface I {
|
||||
}
|
||||
|
||||
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")))
|
||||
}
|
||||
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")))
|
||||
}
|
||||
assertEquals(S("abc"), C::foo.call(S("a"), "b", S("c")))
|
||||
assertEquals(S("def"), (I)::bar.call("d", S("e"), S("f")))
|
||||
|
||||
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<*>
|
||||
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"
|
||||
}
|
||||
|
||||
+6
-19
@@ -2,7 +2,6 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
inline class S(val x: String?) {
|
||||
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 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))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals("42-+*", S("42")::test.call("-", 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-+*", Z::test.call(Z(42), "-", plus, aster))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals("42-+*", Z(42)::test.call("-", 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-+*", A::test.call(A("42"), "-", plus, aster))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals("42-+*", A("42")::test.call("-", plus, aster))
|
||||
}
|
||||
assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster))
|
||||
assertEquals("42-+*", A("42")::test.call("-", plus, aster))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+24
-61
@@ -2,7 +2,6 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
var global = S("")
|
||||
|
||||
@@ -60,26 +59,14 @@ fun box(): String {
|
||||
assertEquals(S("S+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), S::nullableTest.call(S("42")))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), S("42")::nullableTest.call())
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
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())
|
||||
}
|
||||
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)
|
||||
}
|
||||
assertEquals(S("42"), S::nullableTest.call(S("42")))
|
||||
assertEquals(S("42"), S("42")::nullableTest.call())
|
||||
assertEquals(S("42"), S::nullableTest.getter.call(S("42")))
|
||||
assertEquals(S("42"), S("42")::nullableTest.getter.call())
|
||||
S::nullableTest.setter.call(S("42"), S("S-"))
|
||||
assertEquals(S("S-42"), global)
|
||||
S("42")::nullableTest.setter.call(S("S+"))
|
||||
assertEquals(S("S+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertEquals(S("42"), Z::nonNullTest.call(Z(42)))
|
||||
@@ -92,26 +79,14 @@ fun box(): String {
|
||||
assertEquals(S("Z+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), Z::nullableTest.call(Z(42)))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), Z(42)::nullableTest.call())
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
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())
|
||||
}
|
||||
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)
|
||||
}
|
||||
assertEquals(S("42"), Z::nullableTest.call(Z(42)))
|
||||
assertEquals(S("42"), Z(42)::nullableTest.call())
|
||||
assertEquals(S("42"), Z::nullableTest.getter.call(Z(42)))
|
||||
assertEquals(S("42"), Z(42)::nullableTest.getter.call())
|
||||
Z::nullableTest.setter.call(Z(42), S("Z-"))
|
||||
assertEquals(S("Z-42"), global)
|
||||
Z(42)::nullableTest.setter.call(S("Z+"))
|
||||
assertEquals(S("Z+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertEquals(S("42"), A::nonNullTest.call(A(42)))
|
||||
@@ -124,26 +99,14 @@ fun box(): String {
|
||||
assertEquals(S("A+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), A::nullableTest.call(A(42)))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), A(42)::nullableTest.call())
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
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())
|
||||
}
|
||||
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)
|
||||
}
|
||||
assertEquals(S("42"), A::nullableTest.call(A(42)))
|
||||
assertEquals(S("42"), A(42)::nullableTest.call())
|
||||
assertEquals(S("42"), A::nullableTest.getter.call(A(42)))
|
||||
assertEquals(S("42"), A(42)::nullableTest.getter.call())
|
||||
A::nullableTest.setter.call(A(42), S("A-"))
|
||||
assertEquals(S("A-42"), global)
|
||||
A(42)::nullableTest.setter.call(S("A+"))
|
||||
assertEquals(S("A+42"), global)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+6
-19
@@ -2,7 +2,6 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
interface ITest {
|
||||
fun test(a: String, b: S, c: S?): String
|
||||
@@ -24,26 +23,14 @@ fun box(): String {
|
||||
val plus = 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))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals("42-+*", S("42")::test.call("-", 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-+*", Z::test.call(Z(42), "-", plus, aster))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals("42-+*", Z(42)::test.call("-", 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-+*", A::test.call(A("42"), "-", plus, aster))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals("42-+*", A("42")::test.call("-", plus, aster))
|
||||
}
|
||||
assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster))
|
||||
assertEquals("42-+*", A("42")::test.call("-", plus, aster))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+24
-61
@@ -2,7 +2,6 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
var global = S("")
|
||||
|
||||
@@ -65,26 +64,14 @@ fun box(): String {
|
||||
assertEquals(S("S+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), S::nullableTest.call(S("42")))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), S("42")::nullableTest.call())
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
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())
|
||||
}
|
||||
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)
|
||||
}
|
||||
assertEquals(S("42"), S::nullableTest.call(S("42")))
|
||||
assertEquals(S("42"), S("42")::nullableTest.call())
|
||||
assertEquals(S("42"), S::nullableTest.getter.call(S("42")))
|
||||
assertEquals(S("42"), S("42")::nullableTest.getter.call())
|
||||
S::nullableTest.setter.call(S("42"), S("S-"))
|
||||
assertEquals(S("S-42"), global)
|
||||
S("42")::nullableTest.setter.call(S("S+"))
|
||||
assertEquals(S("S+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertEquals(S("42"), Z::nonNullTest.call(Z(42)))
|
||||
@@ -97,26 +84,14 @@ fun box(): String {
|
||||
assertEquals(S("Z+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), Z::nullableTest.call(Z(42)))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), Z(42)::nullableTest.call())
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
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())
|
||||
}
|
||||
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)
|
||||
}
|
||||
assertEquals(S("42"), Z::nullableTest.call(Z(42)))
|
||||
assertEquals(S("42"), Z(42)::nullableTest.call())
|
||||
assertEquals(S("42"), Z::nullableTest.getter.call(Z(42)))
|
||||
assertEquals(S("42"), Z(42)::nullableTest.getter.call())
|
||||
Z::nullableTest.setter.call(Z(42), S("Z-"))
|
||||
assertEquals(S("Z-42"), global)
|
||||
Z(42)::nullableTest.setter.call(S("Z+"))
|
||||
assertEquals(S("Z+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertEquals(S("42"), A::nonNullTest.call(A(42)))
|
||||
@@ -129,26 +104,14 @@ fun box(): String {
|
||||
assertEquals(S("A+42"), global)
|
||||
|
||||
global = S("")
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), A::nullableTest.call(A(42)))
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
assertEquals(S("42"), A(42)::nullableTest.call())
|
||||
}
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
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())
|
||||
}
|
||||
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)
|
||||
}
|
||||
assertEquals(S("42"), A::nullableTest.call(A(42)))
|
||||
assertEquals(S("42"), A(42)::nullableTest.call())
|
||||
assertEquals(S("42"), A::nullableTest.getter.call(A(42)))
|
||||
assertEquals(S("42"), A(42)::nullableTest.getter.call())
|
||||
A::nullableTest.setter.call(A(42), S("A-"))
|
||||
assertEquals(S("A-42"), global)
|
||||
A(42)::nullableTest.setter.call(S("A+"))
|
||||
assertEquals(S("A+42"), global)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+27
-46
@@ -3,7 +3,6 @@
|
||||
|
||||
import kotlin.reflect.KMutableProperty2
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
inline class S(val value: String?) {
|
||||
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.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(S("ab"), C::nullableMember.call(c))
|
||||
assertEquals(S("ab"), C::nullableMember.getter.call(c))
|
||||
}
|
||||
assertEquals(Unit, C::nullableMember.setter.call(c, S("ab")))
|
||||
assertEquals(S("ab"), C::nullableMember.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(S("cd"), c::nullableMember.call())
|
||||
assertEquals(S("cd"), c::nullableMember.getter.call())
|
||||
}
|
||||
assertEquals(Unit, c::nullableMember.setter.call(S("cd")))
|
||||
assertEquals(S("cd"), c::nullableMember.call())
|
||||
assertEquals(S("cd"), c::nullableMember.getter.call())
|
||||
|
||||
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")))
|
||||
@@ -79,57 +74,43 @@ fun box(): String {
|
||||
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?>
|
||||
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(S("ef"), nonNull_nullableMemExt.call(c, S("e")))
|
||||
assertEquals(S("ef"), nonNull_nullableMemExt.getter.call(c, S("e")))
|
||||
}
|
||||
assertEquals(Unit, nonNull_nullableMemExt.setter.call(c, S(""), S("f")))
|
||||
assertEquals(S("ef"), nonNull_nullableMemExt.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>
|
||||
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(S("ef"), nullable_nonNullMemExt.call(c, S("e")))
|
||||
assertEquals(S("ef"), nullable_nonNullMemExt.getter.call(c, S("e")))
|
||||
}
|
||||
assertEquals(Unit, nullable_nonNullMemExt.setter.call(c, S(""), S("f")))
|
||||
assertEquals(S("ef"), nullable_nonNullMemExt.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?>
|
||||
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(S("ef"), nullable_nullableMemExt.call(c, S("e")))
|
||||
assertEquals(S("ef"), nullable_nullableMemExt.getter.call(c, S("e")))
|
||||
}
|
||||
assertEquals(Unit, nullable_nullableMemExt.setter.call(c, S(""), S("f")))
|
||||
assertEquals(S("ef"), nullable_nullableMemExt.call(c, S("e")))
|
||||
assertEquals(S("ef"), nullable_nullableMemExt.getter.call(c, S("e")))
|
||||
|
||||
assertEquals(Unit, ::nonNullTopLevel.setter.call(S("gh")))
|
||||
assertEquals(S("gh"), ::nonNullTopLevel.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(S("gh"), ::nullableTopLevel.call())
|
||||
assertEquals(S("gh"), ::nullableTopLevel.getter.call())
|
||||
}
|
||||
assertEquals(Unit, ::nullableTopLevel.setter.call(S("gh")))
|
||||
assertEquals(S("gh"), ::nullableTopLevel.call())
|
||||
assertEquals(S("gh"), ::nullableTopLevel.getter.call())
|
||||
|
||||
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.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(S("ij"), S::nonNull_nullableExt.call(S("i")))
|
||||
assertEquals(S("ij"), S::nonNull_nullableExt.getter.call(S("i")))
|
||||
}
|
||||
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.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(S("ij"), S?::nullable_nonNullExt.call(S("i")))
|
||||
assertEquals(S("ij"), S?::nullable_nonNullExt.getter.call(S("i")))
|
||||
}
|
||||
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.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(S("ij"), S?::nullable_nullableExt.call(S("i")))
|
||||
assertEquals(S("ij"), S?::nullable_nullableExt.getter.call(S("i")))
|
||||
}
|
||||
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.getter.call(S("i")))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Vendored
+13
-22
@@ -5,7 +5,6 @@
|
||||
import kotlin.coroutines.startCoroutine
|
||||
import kotlin.reflect.full.callSuspend
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFailsWith
|
||||
import helpers.*
|
||||
|
||||
inline class S(val value: String?)
|
||||
@@ -37,34 +36,26 @@ fun box(): String {
|
||||
C::nonNullProduce.callSuspend(c).value!!
|
||||
}.let { assertEquals("nonNull", it) }
|
||||
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
run0 {
|
||||
C::nullableConsume.callSuspend(c, S("nullable"))
|
||||
C::nullableProduce.callSuspend(c)!!.value!!
|
||||
}.let { assertEquals("nullable", it) }
|
||||
}
|
||||
run0 {
|
||||
C::nullableConsume.callSuspend(c, S("nullable"))
|
||||
C::nullableProduce.callSuspend(c)!!.value!!
|
||||
}.let { assertEquals("nullable", it) }
|
||||
|
||||
run0 {
|
||||
C::nonNull_nonNullConsumeAndProduce.callSuspend(c, S("nonNull_nonNull")).value!!
|
||||
}.let { assertEquals("nonNull_nonNull", it) }
|
||||
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
run0 {
|
||||
C::nonNull_nullableConsumeAndProduce.callSuspend(c, S("nonNull_nullable"))!!.value!!
|
||||
}.let { assertEquals("nonNull_nullable", it) }
|
||||
}
|
||||
run0 {
|
||||
C::nonNull_nullableConsumeAndProduce.callSuspend(c, S("nonNull_nullable"))!!.value!!
|
||||
}.let { assertEquals("nonNull_nullable", it) }
|
||||
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
run0 {
|
||||
C::nullable_nonNullConsumeAndProduce.callSuspend(c, S("nullable_nonNull")).value!!
|
||||
}.let { assertEquals("nullable_nonNull", it) }
|
||||
}
|
||||
run0 {
|
||||
C::nullable_nonNullConsumeAndProduce.callSuspend(c, S("nullable_nonNull")).value!!
|
||||
}.let { assertEquals("nullable_nonNull", it) }
|
||||
|
||||
assertFailsWith<IllegalArgumentException>("Remove assertFailsWith and try again, as this problem may have been fixed.") {
|
||||
run0 {
|
||||
C::nullable_nullableConsumeAndProduce.callSuspend(c, S("nullable_nullable"))!!.value!!
|
||||
}.let { assertEquals("nullable_nullable", it) }
|
||||
}
|
||||
run0 {
|
||||
C::nullable_nullableConsumeAndProduce.callSuspend(c, S("nullable_nullable"))!!.value!!
|
||||
}.let { assertEquals("nullable_nullable", it) }
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+9
-18
@@ -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"
|
||||
}
|
||||
|
||||
+9
-16
@@ -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"
|
||||
}
|
||||
|
||||
+8
-24
@@ -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))
|
||||
|
||||
Vendored
+6
-11
@@ -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
-13
@@ -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"
|
||||
}
|
||||
|
||||
+6
-19
@@ -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"
|
||||
}
|
||||
|
||||
+24
-61
@@ -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"
|
||||
}
|
||||
|
||||
Vendored
+6
-19
@@ -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"
|
||||
}
|
||||
|
||||
Vendored
+24
-61
@@ -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"
|
||||
}
|
||||
|
||||
+27
-46
@@ -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"
|
||||
}
|
||||
|
||||
+10
-16
@@ -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"
|
||||
}
|
||||
|
||||
+15
-6
@@ -5,14 +5,13 @@
|
||||
|
||||
package kotlin.reflect.jvm.internal.calls
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
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.TypeUtils
|
||||
import java.lang.reflect.Member
|
||||
import java.lang.reflect.Method
|
||||
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)")
|
||||
}
|
||||
|
||||
internal fun KotlinType.toInlineClass(): Class<*>? =
|
||||
constructor.declarationDescriptor.toInlineClass()
|
||||
internal fun KotlinType.toInlineClass(): Class<*>? {
|
||||
// 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<*>? =
|
||||
if (this is ClassDescriptor && isInlineClass())
|
||||
|
||||
Reference in New Issue
Block a user