Fix "rewrite at slice LEXICAL_SCOPE" during callable reference resolution

Following the TODO in CallableReferencesResolutionUtils.kt, delete the
suspicious scope and use the new resolution process with the qualifier which
was obtained after the resolution of LHS. However, by default the tower
resolution algorithm also considers each qualifier as a class value as well,
which would be wrong here because resolution of LHS as a "value" happens
earlier in DoubleColonExpressionResolver and with slightly different rules. To
avoid that, do not mix in the "explicit receiver" scope tower processor when
creating processors for callable reference resolution.

Also delete unused functions and classes related to deleted scope, refactor
Scopes.kt

 #KT-8596 Fixed
This commit is contained in:
Alexander Udalov
2016-07-01 16:37:46 +03:00
parent 7b59864ed9
commit 00f1415ed7
9 changed files with 109 additions and 135 deletions
@@ -0,0 +1,25 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// KT-8596 Rewrite at slice LEXICAL_SCOPE for nested class constructor reference in an argument position
class K {
class Nested
}
fun foo(f: Any) {}
fun test1() {
foo(K::Nested)
}
// KT-10567 Error: Rewrite at slice LEXICAL_SCOPE key: REFERENCE_EXPRESSION
class Foo(val a: String, val b: String)
fun test2() {
val prop : Foo.() -> String = if (true) {
Foo::a
} else {
Foo::b
}
}
@@ -0,0 +1,28 @@
package
public fun foo(/*0*/ f: kotlin.Any): kotlin.Unit
public fun test1(): kotlin.Unit
public fun test2(): kotlin.Unit
public final class Foo {
public constructor Foo(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String)
public final val a: kotlin.String
public final val b: kotlin.String
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
}
public final class K {
public constructor K()
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
public final class Nested {
public constructor Nested()
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
}
}