Fix tests: "infix modifier required" and "operator modifier required" errors
This commit is contained in:
+2
-2
@@ -9,11 +9,11 @@ class MyClass() {
|
||||
}
|
||||
|
||||
class Delegate {
|
||||
fun getValue(t: Any?, p: KProperty<*>): String {
|
||||
operator fun getValue(t: Any?, p: KProperty<*>): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun setValue(t: Any?, p: KProperty<*>, i: String) {}
|
||||
operator fun setValue(t: Any?, p: KProperty<*>, i: String) {}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
operator fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
operator fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
this[index1 + index2] = elem
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
operator fun Array<String>.get(index1: Int, index2: Int) = this[index1 + index2]
|
||||
operator fun Array<String>.set(index1: Int, index2: Int, elem: String) {
|
||||
this[index1 + index2] = elem
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ fun box(): String {
|
||||
val s = arrayOf("live", "long")
|
||||
val t: Array<String> = s.clone()
|
||||
if (!equals(s, t)) return "Fail string"
|
||||
if (s identityEquals t) return "Fail string identity"
|
||||
if (s.identityEquals(t)) return "Fail string identity"
|
||||
|
||||
val ss = arrayOf(s, s)
|
||||
val tt: Array<Array<String>> = ss.clone()
|
||||
if (!equals(ss, tt)) return "Fail string[]"
|
||||
if (ss identityEquals tt) return "Fail string[] identity"
|
||||
if (ss.identityEquals(tt)) return "Fail string[] identity"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,35 +3,35 @@ import java.util.Arrays.equals
|
||||
fun box(): String {
|
||||
val i = intArrayOf(1, 2)
|
||||
if (!equals(i, i.clone())) return "Fail int"
|
||||
if (i.clone() identityEquals i) return "Fail int identity"
|
||||
if (i.clone().identityEquals(i)) return "Fail int identity"
|
||||
|
||||
val j = longArrayOf(1L, 2L)
|
||||
if (!equals(j, j.clone())) return "Fail long"
|
||||
if (j.clone() identityEquals j) return "Fail long identity"
|
||||
if (j.clone().identityEquals(j)) return "Fail long identity"
|
||||
|
||||
val s = shortArrayOf(1.toShort(), 2.toShort())
|
||||
if (!equals(s, s.clone())) return "Fail short"
|
||||
if (s.clone() identityEquals s) return "Fail short identity"
|
||||
if (s.clone().identityEquals(s)) return "Fail short identity"
|
||||
|
||||
val b = byteArrayOf(1.toByte(), 2.toByte())
|
||||
if (!equals(b, b.clone())) return "Fail byte"
|
||||
if (b.clone() identityEquals b) return "Fail byte identity"
|
||||
if (b.clone().identityEquals(b)) return "Fail byte identity"
|
||||
|
||||
val c = charArrayOf('a', 'b')
|
||||
if (!equals(c, c.clone())) return "Fail char"
|
||||
if (c.clone() identityEquals c) return "Fail char identity"
|
||||
if (c.clone().identityEquals(c)) return "Fail char identity"
|
||||
|
||||
val d = doubleArrayOf(1.0, -1.0)
|
||||
if (!equals(d, d.clone())) return "Fail double"
|
||||
if (d.clone() identityEquals d) return "Fail double identity"
|
||||
if (d.clone().identityEquals(d)) return "Fail double identity"
|
||||
|
||||
val f = floatArrayOf(1f, -1f)
|
||||
if (!equals(f, f.clone())) return "Fail float"
|
||||
if (f.clone() identityEquals f) return "Fail float identity"
|
||||
if (f.clone().identityEquals(f)) return "Fail float identity"
|
||||
|
||||
val z = booleanArrayOf(true, false)
|
||||
if (!equals(z, z.clone())) return "Fail boolean"
|
||||
if (z.clone() identityEquals z) return "Fail boolean identity"
|
||||
if (z.clone().identityEquals(z)) return "Fail boolean identity"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fun box(): String {
|
||||
val array = intArrayOf(11, 12, 13)
|
||||
val p = array get 0
|
||||
val p = array.get(0)
|
||||
if (p != 11) return "fail 1: $p"
|
||||
|
||||
val stringArray = arrayOf("OK", "FAIL")
|
||||
return stringArray get 0
|
||||
return stringArray.get(0)
|
||||
}
|
||||
@@ -17,15 +17,15 @@ class MyIterator<T>(val array : ReadOnlyArray<T>) : javaUtilIterator<T> {
|
||||
}
|
||||
|
||||
interface ReadOnlyArray<out T> : ISized, Iterable<T> {
|
||||
fun get(index : Int) : T
|
||||
operator fun get(index : Int) : T
|
||||
|
||||
override fun iterator() : Iterator<T> = MyIterator<T>(this)
|
||||
}
|
||||
|
||||
interface WriteOnlyArray<in T> : ISized {
|
||||
fun set(index : Int, value : T) : Unit
|
||||
operator fun set(index : Int, value : T) : Unit
|
||||
|
||||
fun set(from: Int, count: Int, value: T) {
|
||||
operator fun set(from: Int, count: Int, value: T) {
|
||||
for(i in from..from+count-1) {
|
||||
set(i, value)
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ fun sort(list: MutableList<String>, comparator: (String, String) -> Int) {
|
||||
})
|
||||
}
|
||||
|
||||
fun compare(s1: String, s2: String) = s1 compareTo s2
|
||||
fun compare(s1: String, s2: String) = s1.compareTo(s2)
|
||||
|
||||
fun box(): String {
|
||||
val l = ArrayList(Arrays.asList("d", "b", "c", "e", "a"))
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ class A {
|
||||
}
|
||||
|
||||
object NumberDecrypter {
|
||||
fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) {
|
||||
operator fun getValue(instance: Any?, data: KProperty<*>) = when (data.name) {
|
||||
"four" -> 4
|
||||
"two" -> 2
|
||||
else -> throw AssertionError()
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@ var result: String by Delegate
|
||||
object Delegate {
|
||||
var value = "lol"
|
||||
|
||||
fun getValue(instance: Any?, data: KProperty<*>): String {
|
||||
operator fun getValue(instance: Any?, data: KProperty<*>): String {
|
||||
return value
|
||||
}
|
||||
|
||||
fun setValue(instance: Any?, data: KProperty<*>, newValue: String) {
|
||||
operator fun setValue(instance: Any?, data: KProperty<*>, newValue: String) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ val <T> Value<T>.additionalText by DVal(Value<T>::text) //works
|
||||
val <T> Value<T>.additionalValue by DVal(Value<T>::value) //not work
|
||||
|
||||
class DVal<T, R, P: KProperty1<T, R>>(val kmember: P) {
|
||||
fun getValue(t: T, p: KProperty<*>): R {
|
||||
operator fun getValue(t: T, p: KProperty<*>): R {
|
||||
return kmember.get(t)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ val String.id: String
|
||||
fun box(): String {
|
||||
val pr = String::id
|
||||
|
||||
if (pr["123"] != "123") return "Fail value: ${pr["123"]}"
|
||||
if (pr.get("123") != "123") return "Fail value: ${pr.get("123")}"
|
||||
|
||||
if (pr.name != "id") return "Fail name: ${pr.name}"
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -10,9 +10,9 @@ var Int.foo: Int
|
||||
|
||||
fun box(): String {
|
||||
val pr = Int::foo
|
||||
if (pr.get(42) != 42) return "Fail 1: ${pr[42]}"
|
||||
if (pr.get(42) != 42) return "Fail 1: ${pr.get(42)}"
|
||||
pr.set(200, 39)
|
||||
if (pr.get(-239) != 0) return "Fail 2: ${pr[-239]}"
|
||||
if (pr.get(-239) != 0) return "Fail 2: ${pr.get(-239)}"
|
||||
if (storage != 239) return "Fail 3: $storage"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ fun box(): String {
|
||||
val o = Box("lorem")
|
||||
val prop = Box::value
|
||||
|
||||
if (prop.get(o) != "lorem") return "Fail 1: ${prop[o]}"
|
||||
if (prop.get(o) != "lorem") return "Fail 1: ${prop.get(o)}"
|
||||
prop.set(o, "ipsum")
|
||||
if (prop.get(o) != "ipsum") return "Fail 2: ${prop[o]}"
|
||||
if (prop.get(o) != "ipsum") return "Fail 2: ${prop.get(o)}"
|
||||
if (o.value != "ipsum") return "Fail 3: ${o.value}"
|
||||
o.value = "dolor"
|
||||
if (prop.get(o) != "dolor") return "Fail 4: ${prop.get(o)}"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class MyNumber(val i: Int) {
|
||||
fun inc(): MyNumber = MyNumber(i+1)
|
||||
operator fun inc(): MyNumber = MyNumber(i+1)
|
||||
}
|
||||
|
||||
class MNR(var ref: MyNumber) {}
|
||||
@@ -53,12 +53,12 @@ fun test6() : Boolean {
|
||||
class MyArrayList<T>() {
|
||||
private var value17: T? = null
|
||||
private var value39: T? = null
|
||||
fun get(index: Int): T {
|
||||
operator fun get(index: Int): T {
|
||||
if (index == 17) return value17!!
|
||||
if (index == 39) return value39!!
|
||||
throw Exception()
|
||||
}
|
||||
fun set(index: Int, value: T): T? {
|
||||
operator fun set(index: Int, value: T): T? {
|
||||
if (index == 17) value17 = value
|
||||
else if (index == 39) value39 = value
|
||||
else throw Exception()
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class mInt(val i : Int) {
|
||||
override fun toString() : String = "mint: $i"
|
||||
fun plus(i : Int) = mInt(this.i + i)
|
||||
fun inc() = mInt(i + 1)
|
||||
operator fun plus(i : Int) = mInt(this.i + i)
|
||||
operator fun inc() = mInt(i + 1)
|
||||
}
|
||||
|
||||
class MyArray() {
|
||||
val a = Array<mInt>(10, {mInt(0)})
|
||||
fun get(i : mInt) : mInt = a[i.i]
|
||||
fun set(i : mInt, v : mInt) {
|
||||
operator fun get(i : mInt) : mInt = a[i.i]
|
||||
operator fun set(i : mInt, v : mInt) {
|
||||
a[i.i] = v
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ data class A(val x: Int) {
|
||||
|
||||
fun box(): String {
|
||||
val a = A(0)
|
||||
return if (a equals a) "fail" else "OK"
|
||||
return if (a.equals(a)) "fail" else "OK"
|
||||
}
|
||||
Vendored
+2
-2
@@ -4,14 +4,14 @@ import java.lang.reflect.InvocationTargetException
|
||||
import kotlin.reflect.*
|
||||
|
||||
object Delegate {
|
||||
fun getValue(t: Any?, p: KProperty<*>): String {
|
||||
operator fun getValue(t: Any?, p: KProperty<*>): String {
|
||||
(p as? KProperty0<String>)?.get()
|
||||
(p as? KProperty1<O, String>)?.get(O)
|
||||
(p as? KProperty2<O, O, String>)?.get(O, O)
|
||||
return "Fail"
|
||||
}
|
||||
|
||||
fun setValue(t: Any?, p: KProperty<*>, v: String) {
|
||||
operator fun setValue(t: Any?, p: KProperty<*>, v: String) {
|
||||
(p as? KMutableProperty0<String>)?.set(v)
|
||||
(p as? KMutableProperty1<O, String>)?.set(O, v)
|
||||
(p as? KMutableProperty2<O, O, String>)?.set(O, O, v)
|
||||
|
||||
+2
-2
@@ -4,12 +4,12 @@ import kotlin.reflect.*
|
||||
val properties = HashSet<KProperty<*>>()
|
||||
|
||||
object Delegate {
|
||||
fun getValue(t: Any?, p: KProperty<*>): String {
|
||||
operator fun getValue(t: Any?, p: KProperty<*>): String {
|
||||
properties.add(p)
|
||||
return ""
|
||||
}
|
||||
|
||||
fun setValue(t: Any?, p: KProperty<*>, v: String) {
|
||||
operator fun setValue(t: Any?, p: KProperty<*>, v: String) {
|
||||
properties.add(p)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Ann(
|
||||
val p1: Int,
|
||||
val p2: Int,
|
||||
val p3: Int,
|
||||
val p4: Int,
|
||||
val p5: Int
|
||||
)
|
||||
|
||||
@Ann(1 plus 1, 1 minus 1, 1 times 1, 1 div 1, 1 mod 1) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val annotation = javaClass<MyClass>().getAnnotation(javaClass<Ann>())!!
|
||||
if (annotation.p1 != 2) return "fail 1"
|
||||
if (annotation.p2 != 0) return "fail 2"
|
||||
if (annotation.p3 != 1) return "fail 3"
|
||||
if (annotation.p4 != 1) return "fail 4"
|
||||
if (annotation.p5 != 0) return "fail 5"
|
||||
return "OK"
|
||||
}
|
||||
@@ -45,14 +45,14 @@ class Error(text : String) : Token("[Error: $text]")
|
||||
fun tokenize(text : String) : Deque<Token> {
|
||||
val result = LinkedList<Token>()
|
||||
for (c in text) {
|
||||
result add when (c) {
|
||||
result.add(when (c) {
|
||||
'(' -> LPAR
|
||||
')' -> RPAR
|
||||
'+' -> PLUS
|
||||
'*' -> TIMES
|
||||
in '0'..'9' -> Number(c.toString())
|
||||
else -> Error(c.toString())
|
||||
}
|
||||
})
|
||||
}
|
||||
result.add(EOF)
|
||||
return result
|
||||
|
||||
@@ -53,7 +53,7 @@ inline fun test(): String {
|
||||
return "123"
|
||||
}
|
||||
|
||||
fun String.fail(p: String): String {
|
||||
infix fun String.fail(p: String): String {
|
||||
throw AssertionError("fail")
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ fun box(): String {
|
||||
}
|
||||
}
|
||||
catch (caught: Throwable) {
|
||||
if (!(caught identityEquals e)) return "Fail: $caught"
|
||||
if (!(caught.identityEquals(e))) return "Fail: $caught"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
|
||||
@@ -8,7 +8,7 @@ fun box(): String {
|
||||
}
|
||||
}
|
||||
catch (caught: Throwable) {
|
||||
if (!(caught identityEquals e)) return "Fail: $caught"
|
||||
if (!(caught.identityEquals(e))) return "Fail: $caught"
|
||||
// If monitorexit didn't happen (a finally block failed), this assertion would fail
|
||||
assertThatThreadDoesNotOwnMonitor(obj)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ object A {
|
||||
v += B(1000)
|
||||
}
|
||||
|
||||
@JvmStatic fun B.plusAssign(b: B) {
|
||||
@JvmStatic operator fun B.plusAssign(b: B) {
|
||||
this.s += b.s
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class A(val p: Int) {
|
||||
|
||||
var prop = this
|
||||
|
||||
fun inc(): A {
|
||||
operator fun inc(): A {
|
||||
return A(p+1)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -3,12 +3,12 @@ class B
|
||||
|
||||
var holder = 0
|
||||
|
||||
fun A.not(): A {
|
||||
operator fun A.not(): A {
|
||||
holder++
|
||||
return this;
|
||||
}
|
||||
|
||||
fun B.not(): Boolean {
|
||||
operator fun B.not(): Boolean {
|
||||
holder++
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class C(val i: Int) {
|
||||
fun component1() = i + 1
|
||||
fun component2() = i + 2
|
||||
operator fun component1() = i + 1
|
||||
operator fun component2() = i + 2
|
||||
}
|
||||
|
||||
fun doTest(l : Array<C>): String {
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
class C(val i: Int) {
|
||||
}
|
||||
|
||||
fun C.component1() = i + 1
|
||||
fun C.component2() = i + 2
|
||||
operator fun C.component1() = i + 1
|
||||
operator fun C.component2() = i + 2
|
||||
|
||||
fun doTest(l : Array<C>): String {
|
||||
var s = ""
|
||||
|
||||
Vendored
+2
-2
@@ -2,8 +2,8 @@ class C(val i: Int) {
|
||||
}
|
||||
|
||||
class M {
|
||||
fun C.component1() = i + 1
|
||||
fun C.component2() = i + 2
|
||||
operator fun C.component1() = i + 1
|
||||
operator fun C.component2() = i + 2
|
||||
|
||||
fun doTest(l : Array<C>): String {
|
||||
var s = ""
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@ class C(val i: Int) {
|
||||
}
|
||||
|
||||
class M {
|
||||
fun C.component1() = i + 1
|
||||
fun C.component2() = i + 2
|
||||
operator fun C.component1() = i + 1
|
||||
operator fun C.component2() = i + 2
|
||||
}
|
||||
|
||||
fun M.doTest(l : Array<C>): String {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
class C(val i: Int) {
|
||||
fun component1() = i + 1
|
||||
fun component2() = i + 2
|
||||
operator fun component1() = i + 1
|
||||
operator fun component2() = i + 2
|
||||
}
|
||||
|
||||
fun doTest(l : Array<C>): String {
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
fun Int.component1() = this + 1
|
||||
fun Int.component2() = this + 2
|
||||
operator fun Int.component1() = this + 1
|
||||
operator fun Int.component2() = this + 2
|
||||
|
||||
fun doTest(l : Array<Int>): String {
|
||||
var s = ""
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
fun Int.component1() = this + 1
|
||||
fun Int.component2() = this + 2
|
||||
operator fun Int.component1() = this + 1
|
||||
operator fun Int.component2() = this + 2
|
||||
|
||||
fun doTest(l : Array<Int>): String {
|
||||
var s = ""
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
class M {
|
||||
fun Int.component1() = this + 1
|
||||
fun Int.component2() = this + 2
|
||||
operator fun Int.component1() = this + 1
|
||||
operator fun Int.component2() = this + 2
|
||||
|
||||
fun doTest(l : Array<Int>): String {
|
||||
var s = ""
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
class M {
|
||||
fun Int.component1() = this + 1
|
||||
fun Int.component2() = this + 2
|
||||
operator fun Int.component1() = this + 1
|
||||
operator fun Int.component2() = this + 2
|
||||
}
|
||||
|
||||
fun M.doTest(l : Array<Int>): String {
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
fun Long.component1() = this + 1
|
||||
fun Long.component2() = this + 2
|
||||
operator fun Long.component1() = this + 1
|
||||
operator fun Long.component2() = this + 2
|
||||
|
||||
fun doTest(l : Array<Long>): String {
|
||||
var s = ""
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
fun Long.component1() = this + 1
|
||||
fun Long.component2() = this + 2
|
||||
operator fun Long.component1() = this + 1
|
||||
operator fun Long.component2() = this + 2
|
||||
|
||||
fun doTest(l : Array<Long>): String {
|
||||
var s = ""
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
class M {
|
||||
fun Long.component1() = this + 1
|
||||
fun Long.component2() = this + 2
|
||||
operator fun Long.component1() = this + 1
|
||||
operator fun Long.component2() = this + 2
|
||||
|
||||
fun doTest(l : Array<Long>): String {
|
||||
var s = ""
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
class M {
|
||||
fun Long.component1() = this + 1
|
||||
fun Long.component2() = this + 2
|
||||
operator fun Long.component1() = this + 1
|
||||
operator fun Long.component2() = this + 2
|
||||
}
|
||||
|
||||
fun M.doTest(l : Array<Long>): String {
|
||||
|
||||
@@ -3,7 +3,7 @@ import java.io.Closeable
|
||||
class MyException(message: String) : Exception(message)
|
||||
|
||||
class Holder(var value: String) {
|
||||
public fun plusAssign(s: String?) {
|
||||
operator fun plusAssign(s: String?) {
|
||||
value += s
|
||||
if (s != "closed") {
|
||||
value += "->"
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import kotlin.test.assertEquals
|
||||
class MyException(message: String) : Exception(message)
|
||||
|
||||
class Holder(var value: String) {
|
||||
public fun plusAssign(s: String?) {
|
||||
operator fun plusAssign(s: String?) {
|
||||
value += s
|
||||
if (s != "closed") {
|
||||
value += "->"
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
fun Int.component1(): String {
|
||||
operator fun Int.component1(): String {
|
||||
return arrayListOf("zero", "one", "two", "three")[this]
|
||||
}
|
||||
|
||||
fun Int.component2(): Int {
|
||||
operator fun Int.component2(): Int {
|
||||
return arrayListOf(0, 1, 4, 9)[this]
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ fun box(): String {
|
||||
|
||||
val a = A()
|
||||
mutable as KMutableProperty2<A, String, String>
|
||||
assert(mutable[a, ""] == "before") { "Fail 3: ${mutable.get(a, "")}" }
|
||||
mutable[a, ""] = "OK"
|
||||
assert(mutable.get(a, "") == "before") { "Fail 3: ${mutable.get(a, "")}" }
|
||||
mutable.set(a, "", "OK")
|
||||
return mutable.get(a, "")
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -13,7 +13,7 @@ fun box(): String {
|
||||
|
||||
val a = A("")
|
||||
mutable as KMutableProperty1<A, String>
|
||||
assert(mutable[a] == "before") { "Fail 3: ${mutable.get(a)}" }
|
||||
mutable[a] = "OK"
|
||||
assert(mutable.get(a) == "before") { "Fail 3: ${mutable.get(a)}" }
|
||||
mutable.set(a, "OK")
|
||||
return mutable.get(a)
|
||||
}
|
||||
|
||||
+2
-2
@@ -9,14 +9,14 @@ fun box(): String {
|
||||
run {
|
||||
val foo: KProperty1<A, *> = javaClass<A>().kotlin.memberProperties.single()
|
||||
assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" }
|
||||
assert(foo.get(A()) == "member") { "Fail value: ${foo[A()]}" }
|
||||
assert(foo.get(A()) == "member") { "Fail value: ${foo.get(A())}" }
|
||||
}
|
||||
|
||||
run {
|
||||
val foo: KProperty2<A, *, *> = javaClass<A>().kotlin.memberExtensionProperties.single()
|
||||
assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" }
|
||||
foo as KProperty2<A, Unit, *>
|
||||
assert(foo.get(A(), Unit) == "extension") { "Fail value: ${foo[A(), Unit]}" }
|
||||
assert(foo.get(A(), Unit) == "extension") { "Fail value: ${foo.get(A(), Unit)}" }
|
||||
}
|
||||
|
||||
return "OK"
|
||||
|
||||
Vendored
+4
-4
@@ -11,15 +11,15 @@ fun box(): String {
|
||||
p.isAccessible = true
|
||||
|
||||
try {
|
||||
p[null] = "OK"
|
||||
p.set(null, "OK")
|
||||
return "Fail: set should check that first argument is Obj"
|
||||
} catch (e: IllegalArgumentException) {}
|
||||
|
||||
try {
|
||||
p[null]
|
||||
p.get(null)
|
||||
return "Fail: get should check that first argument is Obj"
|
||||
} catch (e: IllegalArgumentException) {}
|
||||
|
||||
p[Obj] = "OK"
|
||||
return p[Obj]
|
||||
p.set(Obj, "OK")
|
||||
return p.get(Obj)
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,5 +25,5 @@ fun box(): String {
|
||||
|
||||
f.set(a, ":)")
|
||||
|
||||
return if (f[a] != ":)") "Fail: ${f[a]}" else "OK"
|
||||
return if (f.get(a) != ":)") "Fail: ${f.get(a)}" else "OK"
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class Project {
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> Project.getValue(t: Any?, p: KProperty<*>): T = getInstance(javaClass<T>())
|
||||
inline operator fun <reified T : Any> Project.getValue(t: Any?, p: KProperty<*>): T = getInstance(javaClass<T>())
|
||||
|
||||
val project = Project()
|
||||
val x1: Int by project
|
||||
|
||||
Reference in New Issue
Block a user