Synthetic extensions wins against top-level extension.
This commit is contained in:
@@ -63,6 +63,7 @@ internal class ScopeTowerImpl(
|
||||
filter { it.kind.withLocalDescriptors }.
|
||||
mapTo(result) { ScopeBasedTowerLevel(this, it) }
|
||||
|
||||
var isFirstImportingScope = true
|
||||
lexicalScope.parentsWithSelf.forEach { scope ->
|
||||
if (scope is LexicalScope) {
|
||||
if (!scope.kind.withLocalDescriptors) result.add(ScopeBasedTowerLevel(this, scope))
|
||||
@@ -70,10 +71,13 @@ internal class ScopeTowerImpl(
|
||||
scope.implicitReceiver?.let { result.add(ReceiverScopeTowerLevel(this, it.value)) }
|
||||
}
|
||||
else {
|
||||
if (isFirstImportingScope) {
|
||||
isFirstImportingScope = false
|
||||
result.add(SyntheticScopeBasedTowerLevel(this, syntheticScopes))
|
||||
}
|
||||
result.add(ImportingScopeBasedTowerLevel(this, scope as ImportingScope))
|
||||
}
|
||||
}
|
||||
result.add(SyntheticScopeBasedTowerLevel(this, syntheticScopes))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
+31
@@ -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()
|
||||
+22
@@ -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
|
||||
}
|
||||
+38
@@ -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()
|
||||
+28
@@ -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
|
||||
}
|
||||
@@ -13735,6 +13735,18 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/priority/synthesizedMembersVsExtension.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticPropertiesVsExtensions.kt")
|
||||
public void testSyntheticPropertiesVsExtensions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/priority/syntheticPropertiesVsExtensions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticPropertiesVsMembers.kt")
|
||||
public void testSyntheticPropertiesVsMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/priority/syntheticPropertiesVsMembers.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/resolve/overloadConflicts")
|
||||
|
||||
Reference in New Issue
Block a user