Remove unneeded CallerImpl implementations

Also fix a bug where nullability of the assigned value was not checked
in ClassCompanionFieldSetter because it wasn't a subclass of FieldSetter
where this check occurred
This commit is contained in:
Alexander Udalov
2018-08-27 19:43:56 +02:00
parent 356b02cb91
commit 8c8f0639f8
3 changed files with 47 additions and 80 deletions
@@ -23,6 +23,14 @@ class CounterTest<T>(t: T) {
private var generic: T = t
}
class C {
companion object {
private var z: String = ""
fun getBoundZ() = this::z
}
}
fun box(): String {
val p = A::class.memberProperties.single() as KMutableProperty1<A, String?>
p.isAccessible = true
@@ -47,5 +55,19 @@ fun box(): String {
d.isAccessible = true
d.setter.call(CounterTest(""), null) // Also should not fail, because we can't be sure about nullability of 'generic'
val z = C.Companion::class.memberProperties.single { it.name == "z" } as KMutableProperty1<C.Companion, String?>
z.isAccessible = true
try {
z.setter.call(C, null)
return "Fail: exception should have been thrown"
} catch (e: IllegalArgumentException) {}
val zz = C.getBoundZ() as KMutableProperty0<String?>
zz.isAccessible = true
try {
zz.setter.call(null)
return "Fail: exception should have been thrown"
} catch (e: IllegalArgumentException) {}
return "OK"
}