Synthetic extensions wins against top-level extension.

This commit is contained in:
Stanislav Erokhin
2015-12-18 15:23:11 +03:00
parent e8a697cb6d
commit 1574dc78df
16 changed files with 189 additions and 45 deletions
@@ -0,0 +1,31 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
// FILE: A.java
public class A {
public A getFoo() { return 3; }
}
// FILE: 1.kt
private val A.foo: Int get() = 4
fun test(a: A) {
a.foo checkType { _<A>() }
with(a) {
foo checkType { _<A>() }
}
}
class B {
private val A.foo: B get() = this@B
fun test(a: A) {
a.foo checkType { _<B>() } // todo
with(a) {
foo checkType { _<B>() } // todo
}
}
}
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()