Forbidden old invokeExtension convention.

This commit is contained in:
Stanislav Erokhin
2015-10-16 21:25:25 +03:00
parent fc4b0a8121
commit 7d7d37719b
26 changed files with 157 additions and 126 deletions
@@ -0,0 +1,35 @@
class B
class A {
operator fun B.invoke() = 4
}
class X {
operator fun invoke() = 3
}
fun test(a: A, b: B) {
with (a) {
b()
(b)()
}
X()()
val x = X()
x()
(x)()
}
fun test(c: () -> String, e: Int.() -> String) {
c()
(c)()
3.e()
3.(e)()
with(3) {
e()
(e)()
}
}
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()