FIR resolve: add extra test & comments to multiple receiver resolve
This commit is contained in:
@@ -146,8 +146,8 @@ abstract class SessionBasedTowerLevel(val session: FirSession) : TowerScopeLevel
|
||||
// This is more like "dispatch receiver-based tower level"
|
||||
// Here we always have an explicit or implicit dispatch receiver, and can access members of its scope
|
||||
// (which is separated from currently accessible scope, see below)
|
||||
// So: dispatch receiver = given explicit or implicit receiver
|
||||
// So: extension receiver = NONE
|
||||
// So: dispatch receiver = given explicit or implicit receiver (always present)
|
||||
// So: extension receiver = either none, if dispatch receiver = explicit receiver, or given explicit receiver, otherwise
|
||||
class MemberScopeTowerLevel(
|
||||
session: FirSession,
|
||||
val dispatchReceiver: ReceiverValue
|
||||
|
||||
@@ -10,15 +10,21 @@ class Foo {
|
||||
class Bar {
|
||||
val x = ""
|
||||
|
||||
// NB: unused
|
||||
fun Foo.abc() = x
|
||||
|
||||
fun bar(): Bar = this
|
||||
|
||||
// NB: unused
|
||||
operator fun String.plus(bar: Bar): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
// NB! abc() here is resolved to member Foo.abc(), and not to extension member of Bar
|
||||
fun Foo.check() = abc() + bar()
|
||||
|
||||
// NB! + here is resolved to member String.plus (not to extension member above)
|
||||
fun Foo.check2() = "" + bar()
|
||||
}
|
||||
|
||||
fun Foo.ext() = x
|
||||
|
||||
@@ -40,6 +40,10 @@ FILE: access.kt
|
||||
^check R|/Foo.abc|().<Inapplicable(INAPPLICABLE): [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(R|/bar|())
|
||||
}
|
||||
|
||||
public final fun R|Foo|.check2(): R|kotlin/String| {
|
||||
^check2 String().R|kotlin/String.plus|(R|/bar|())
|
||||
}
|
||||
|
||||
}
|
||||
public final fun R|Foo|.ext(): R|kotlin/Int| {
|
||||
^ext R|/Foo.x|
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class Foo {
|
||||
fun bar(arg: Bar) {
|
||||
arg.foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun Bar.foo() {}
|
||||
|
||||
class Bar {
|
||||
fun Foo.foo() {}
|
||||
|
||||
fun bar(arg: Foo) {
|
||||
arg.foo()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
FILE: memberExtension.kt
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun bar(arg: R|Bar|): R|kotlin/Unit| {
|
||||
R|<local>/arg|.R|/foo|()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun R|Bar|.foo(): R|kotlin/Unit| {
|
||||
}
|
||||
public final class Bar : R|kotlin/Any| {
|
||||
public constructor(): R|Bar| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun R|Foo|.foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final fun bar(arg: R|Foo|): R|kotlin/Unit| {
|
||||
R|<local>/arg|.R|/Bar.foo|()
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -222,6 +222,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/localImplicitBodies.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberExtension.kt")
|
||||
public void testMemberExtension() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/memberExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectVsProperty.kt")
|
||||
public void testObjectVsProperty() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/objectVsProperty.kt");
|
||||
|
||||
Reference in New Issue
Block a user