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()
@@ -0,0 +1,22 @@
package
private val A.foo: kotlin.Int
public fun test(/*0*/ a: A): kotlin.Unit
public fun </*0*/ T, /*1*/ R> with(/*0*/ receiver: T, /*1*/ f: T.() -> R): R
public open class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open fun getFoo(): A!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B {
public constructor B()
private final val A.foo: B
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(/*0*/ a: A): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,38 @@
// !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
// FILE: A.java
public class A {
public A getFoo() { return 3; }
}
// FILE: B.java
public class B {
public B getFoo() { return ""; }
}
// FILE: 1.kt
class C(val foo: C)
fun test(a: A, b: B, c: C) {
with(a) {
with(b) {
foo checkType { _<B>() }
}
foo checkType { _<A>() }
}
with(a) {
with(c) {
foo checkType { _<C>() }
}
}
with(c) {
with(a) {
foo checkType { _<C>() } // todo
}
}
}
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
@@ -0,0 +1,28 @@
package
public fun test(/*0*/ a: A, /*1*/ b: B, /*2*/ c: C): kotlin.Unit
public fun </*0*/ T, /*1*/ R> with(/*0*/ receiver: T, /*1*/ f: T.() -> R): R
public open class A {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open fun getFoo(): A!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class B {
public constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open fun getFoo(): B!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class C {
public constructor C(/*0*/ foo: C)
public final val foo: C
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}