Minor, move tests on KT-39054 into a subdirectory

This commit is contained in:
Alexander Udalov
2021-11-26 02:19:31 +01:00
parent 85e6c90052
commit 29c1fe1be1
13 changed files with 308 additions and 234 deletions
@@ -0,0 +1,14 @@
// WITH_STDLIB
var x: String
get() = throw Exception("x's getter shouldn't be called")
set(_) { throw Exception("x's setter shouldn't be called") }
var y: String by ::x
var storage = "Fail"
operator fun Any.getValue(thiz: Any?, property: Any?): String = storage
operator fun Any.setValue(thiz: Any?, property: Any?, value: String) { storage = value }
fun box(): String {
y = "OK"
return y
}
@@ -0,0 +1,39 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// FIR status: REPEATED_ANNOTATION at val y9; fir2ir produces an IrFunctionReference of type KProperty0 instead of an IrPropertyReference
// WITH_REFLECT
// WITH_STDLIB
// FILE: J.java
public interface J<T> {
public T getValue();
}
// FILE: box.kt
class Impl(val x: String) : J<String> {
override fun getValue() = x
}
val j1: J<String> = Impl("O")
// Note that taking a reference to `J<T>::value` is not permitted by the frontend
// in any context except as a direct argument to `by`; e.g. `val x by run { j1::value }`
// would produce an error.
val x by j1::value
@Target(AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.EXPRESSION, AnnotationTarget.FILE)
@Retention(AnnotationRetention.SOURCE)
annotation class Anno
fun box(): String {
val j2: J<String> = Impl("K")
val y by j2::value
val y1 by @Anno j2::value
val y2 by (j2::value)
val y3 by (j2)::value
val y4 by ((j2)::value)
val y5 by (((j2)::value))
val y6 by @Anno() (((j2)::value))
val y7 by (@Anno() ((j2)::value))
val y8 by ((@Anno() (j2)::value))
val y9 by @Anno() ((@Anno() (j2)::value))
return x + y
}
@@ -0,0 +1,13 @@
// WITH_STDLIB
// IGNORE_BACKEND: JS
class C(var x: String)
var x = "fail"
var y by ::x
var z by C("fail")::x
fun box(): String {
y = "O"
z = "K"
return y + z
}
@@ -0,0 +1,23 @@
// WITH_STDLIB
val String.foo: String
get() = this
abstract class A {
abstract val x: String
val y by x::foo
}
var storage = "OK"
class B : A() {
override var x: String
get() = storage
set(value) { storage = value }
}
fun box(): String {
val b = B()
b.x = "fail"
return b.y
}
@@ -0,0 +1,8 @@
// WITH_STDLIB
class C(val x: String)
val x = "O"
val y by ::x
val z by C("K")::x
fun box(): String = y + z
@@ -0,0 +1,16 @@
// WITH_STDLIB
var result = "Fail"
object O {
val z = 42
init { result = "OK" }
}
class A {
val x by O::z
}
fun box(): String {
A()
return result
}