Simplify function hierarchy in reflection
Get rid of all classes except kotlin.reflect.KFunction, which will be used to represent all kinds of simple functions. Lots of changes to test data are related to the fact that KFunction is not an extension function (as opposed to KMemberFunction and KExtensionFunction who were) and so a member or an extension function reference now requires all arguments be passed to it in the parentheses, including receivers. This is probably temporary until we support calling any function both as a free function and as an extension. In JS, functions and extension functions are not interchangeable, so tests on this behavior are removed until this is supported
This commit is contained in:
+1
-1
@@ -6,4 +6,4 @@ class B : A() {
|
||||
override fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = B().(A::foo)()
|
||||
fun box(): String = (A::foo)(B())
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
fun box(): String {
|
||||
if (true.(Boolean::not)() != false) return "Fail 1"
|
||||
if (false.(Boolean::not)() != true) return "Fail 2"
|
||||
if ((Boolean::not)(true) != false) return "Fail 1"
|
||||
if ((Boolean::not)(false) != true) return "Fail 2"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
fun foo(k: Int) = k
|
||||
|
||||
fun result() = this.(::foo)(111)
|
||||
fun result() = (::foo)(this, 111)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@ class A {
|
||||
fun k(k: Int) = k
|
||||
}
|
||||
|
||||
fun A.foo() = this.(::o)() + this.(A::k)(222)
|
||||
fun A.foo() = (::o)(this) + (A::k)(this, 222)
|
||||
|
||||
fun box(): String {
|
||||
val result = A().foo()
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ class A {
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return A().x()
|
||||
return x(A())
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ class A {
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return A().x("OK")
|
||||
return x(A(), "OK")
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ class A {
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val x = A::foo
|
||||
a.x()
|
||||
x(a)
|
||||
return a.result
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ class A {
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val x = A::foo
|
||||
a.x("OK")
|
||||
x(a, "OK")
|
||||
return a.result
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ enum class E {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val i = E.I.(E::name)()
|
||||
val i = (E::name)(E.I)
|
||||
if (i != "I") return "Fail $i"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
class A
|
||||
|
||||
fun box() = if (A().(A::equals)(A())) "Fail" else "OK"
|
||||
fun box() = if ((A::equals)(A(), A())) "Fail" else "OK"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class A {
|
||||
fun result() = this.(::foo)("OK")
|
||||
fun result() = (::foo)(this, "OK")
|
||||
}
|
||||
|
||||
fun A.foo(x: String) = x
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
class A
|
||||
|
||||
fun A.foo() = this.(A::bar)("OK")
|
||||
fun A.foo() = (A::bar)(this, "OK")
|
||||
|
||||
fun A.bar(x: String) = x
|
||||
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ fun A.foo() = "OK"
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return A().x()
|
||||
return x(A())
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ fun A.foo(result: String) = result
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
return A().x("OK")
|
||||
return x(A(), "OK")
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ fun A.foo() {
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val x = A::foo
|
||||
a.x()
|
||||
x(a)
|
||||
return a.result
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ fun A.foo(newResult: String) {
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val x = A::foo
|
||||
a.x("OK")
|
||||
x(a, "OK")
|
||||
return a.result
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ class A<T>(val t: T) {
|
||||
fun foo(): T = t
|
||||
}
|
||||
|
||||
fun box() = A("OK").(A<String>::foo)()
|
||||
fun box() = (A<String>::foo)(A("OK"))
|
||||
|
||||
Vendored
+1
-1
@@ -4,7 +4,7 @@ class A {
|
||||
val k = 222
|
||||
}
|
||||
|
||||
fun result() = this.(A::Inner)().o + this.(::Inner)().k
|
||||
fun result() = (A::Inner)(this).o + (::Inner)(this).k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@ class A {
|
||||
}
|
||||
}
|
||||
|
||||
fun A.foo() = this.(A::Inner)().o + this.(::Inner)().k
|
||||
fun A.foo() = (A::Inner)(this).o + (::Inner)(this).k
|
||||
|
||||
fun box(): String {
|
||||
val result = A().foo()
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ class A {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = (::A)().(A::Inner)().o + A().(A::Inner)().k
|
||||
val result = (A::Inner)((::A)()).o + (A::Inner)(A()).k
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ class A {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = (::A)().(A::Inner)(111).result + A().(A::Inner)(222).result
|
||||
val result = (A::Inner)((::A)(), 111).result + (A::Inner)(A(), 222).result
|
||||
if (result != 333) return "Fail $result"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,5 +8,5 @@ class Outer {
|
||||
|
||||
fun box(): String {
|
||||
val f = Outer.Inner::foo
|
||||
return Outer().Inner().f()
|
||||
return f(Outer().Inner())
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ fun box(): String {
|
||||
}
|
||||
|
||||
val ref = Local::foo
|
||||
return Local().ref()
|
||||
return ref(Local())
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -7,5 +7,5 @@ enum class E : Named {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return E.OK.(Named::name)()
|
||||
return (Named::name)(E.OK)
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ class A
|
||||
|
||||
fun box(): String {
|
||||
fun A.foo() = "OK"
|
||||
return A().(A::foo)()
|
||||
return (A::foo)(A())
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
fun box(): String {
|
||||
class A
|
||||
fun A.foo() = "OK"
|
||||
return (::A)().(A::foo)()
|
||||
return (A::foo)((::A)())
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun box(): String {
|
||||
fun Int.is42With(that: Int) = this + 2 * that == 42
|
||||
return if (16.(Int::is42With)(13)) "OK" else "Fail"
|
||||
return if ((Int::is42With)(16, 13)) "OK" else "Fail"
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -6,6 +6,6 @@ fun box(): String {
|
||||
fun A.ext() { result = "OK" }
|
||||
|
||||
val f = A::ext
|
||||
A().f()
|
||||
f(A())
|
||||
return result
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ fun box(): String {
|
||||
}
|
||||
|
||||
val ref = Id<String>::invoke
|
||||
return Id<String>().ref("OK")
|
||||
return ref(Id<String>(), "OK")
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -7,5 +7,5 @@ fun box(): String {
|
||||
|
||||
val member = Local::foo
|
||||
val instance = Local()
|
||||
return instance.member()
|
||||
return member(instance)
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -8,6 +8,6 @@ object A {
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
A.x()
|
||||
x(A)
|
||||
return A.result
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -8,6 +8,6 @@ object A {
|
||||
|
||||
fun box(): String {
|
||||
val x = A::foo
|
||||
A.x("OK")
|
||||
x(A, "OK")
|
||||
return A.result
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
private fun foo() = "OK"
|
||||
|
||||
fun bar() = this.(::foo)()
|
||||
fun bar() = (::foo)(this)
|
||||
}
|
||||
|
||||
fun box() = A().bar()
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ interface T {
|
||||
|
||||
class B : T {
|
||||
inner class C {
|
||||
fun bar() = this@B.(::foo)()
|
||||
fun bar() = (::foo)(this@B)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ class B : A {
|
||||
override fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box() = B().(A::foo)()
|
||||
fun box() = (A::foo)(B())
|
||||
|
||||
Reference in New Issue
Block a user