Frontend: fixed explicit receiver kind for dynamic call with implicit dispatch receiver.
Additionally added tests for other cases.
This commit is contained in:
@@ -191,17 +191,11 @@ public class TaskPrioritizer(private val storageManager: StorageManager) {
|
||||
c.result.addCandidates {
|
||||
val dynamicScope = DynamicCallableDescriptors.createDynamicDescriptorScope(c.context.call, c.scope.getContainingDeclaration())
|
||||
|
||||
val dynamicDescriptors = ArrayList<D>()
|
||||
for (collector in c.callableDescriptorCollectors) {
|
||||
dynamicDescriptors.addAll(collector.getNonExtensionsByName(dynamicScope, c.name, c.context.trace))
|
||||
val dynamicDescriptors = c.callableDescriptorCollectors.flatMap {
|
||||
it.getNonExtensionsByName(dynamicScope, c.name, c.context.trace)
|
||||
}
|
||||
|
||||
dynamicDescriptors.map {
|
||||
val dynamicCandidate = ResolutionCandidate.create<D>(c.context.call, it)
|
||||
dynamicCandidate.setDispatchReceiver(explicitReceiver)
|
||||
dynamicCandidate.setExplicitReceiverKind(DISPATCH_RECEIVER)
|
||||
dynamicCandidate
|
||||
}
|
||||
convertWithReceivers(dynamicDescriptors, explicitReceiver, NO_RECEIVER, createKind(DISPATCH_RECEIVER, isExplicit), c.context.call)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun bar(a: dynamic ) {
|
||||
a.<caret>foo()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fun bar(a: dynamic ) {
|
||||
a.<caret>foo()
|
||||
}
|
||||
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(): dynamic defined in bar
|
||||
|
||||
Explicit receiver kind = DISPATCH_RECEIVER
|
||||
Dispatch receiver = a {('Nothing'..'Any?')}
|
||||
Extension receiver = NO_RECEIVER
|
||||
@@ -0,0 +1,5 @@
|
||||
fun dynamic.foo() {}
|
||||
|
||||
fun bar(a: dynamic) {
|
||||
a.<caret>foo()
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fun dynamic.foo() {}
|
||||
|
||||
fun bar(a: dynamic) {
|
||||
a.<caret>foo()
|
||||
}
|
||||
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun dynamic.foo(): Unit defined in root package
|
||||
|
||||
Explicit receiver kind = EXTENSION_RECEIVER
|
||||
Dispatch receiver = NO_RECEIVER
|
||||
Extension receiver = a {('Nothing'..'Any?')}
|
||||
@@ -0,0 +1,9 @@
|
||||
class A {
|
||||
fun dynamic.foo() {}
|
||||
}
|
||||
|
||||
fun bar(a: A, b: dynamic) {
|
||||
with (a) {
|
||||
b.<caret>foo()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class A {
|
||||
fun dynamic.foo() {}
|
||||
}
|
||||
|
||||
fun bar(a: A, b: dynamic) {
|
||||
with (a) {
|
||||
b.<caret>foo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun dynamic.foo(): Unit defined in A
|
||||
|
||||
Explicit receiver kind = EXTENSION_RECEIVER
|
||||
Dispatch receiver = AExt{fun A.<anonymous>(): Unit defined in bar}
|
||||
Extension receiver = b {('Nothing'..'Any?')}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class A {
|
||||
fun dynamic.foo() {}
|
||||
}
|
||||
|
||||
fun bar(a: A, b: dynamic) {
|
||||
with (a) {
|
||||
with (b) {
|
||||
<caret>foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
class A {
|
||||
fun dynamic.foo() {}
|
||||
}
|
||||
|
||||
fun bar(a: A, b: dynamic) {
|
||||
with (a) {
|
||||
with (b) {
|
||||
<caret>foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun dynamic.foo(): Unit defined in A
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
Dispatch receiver = AExt{fun A.<anonymous>(): Unit defined in bar}
|
||||
Extension receiver = ('Nothing'..'Any?')Ext{fun dynamic.<anonymous>(): Unit defined in bar.<anonymous>}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun dynamic.bar() {
|
||||
<caret>foo()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fun dynamic.bar() {
|
||||
<caret>foo()
|
||||
}
|
||||
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun foo(): dynamic defined in bar
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
Dispatch receiver = ('Nothing'..'Any?')Ext{fun dynamic.bar(): Unit defined in root package}
|
||||
Extension receiver = NO_RECEIVER
|
||||
@@ -0,0 +1,5 @@
|
||||
fun dynamic.foo() {}
|
||||
|
||||
fun dynamic.bar() {
|
||||
<caret>foo()
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fun dynamic.foo() {}
|
||||
|
||||
fun dynamic.bar() {
|
||||
<caret>foo()
|
||||
}
|
||||
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: fun dynamic.foo(): Unit defined in root package
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
Dispatch receiver = NO_RECEIVER
|
||||
Extension receiver = ('Nothing'..'Any?')Ext{fun dynamic.bar(): Unit defined in root package}
|
||||
@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/resolvedCalls")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@InnerTestClasses({ResolvedCallsTestGenerated.Arguments.class, ResolvedCallsTestGenerated.DifferentCallElements.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.ObjectsAndClassObjects.class, ResolvedCallsTestGenerated.RealExamples.class, ResolvedCallsTestGenerated.Resolve.class, ResolvedCallsTestGenerated.ThisOrSuper.class})
|
||||
@InnerTestClasses({ResolvedCallsTestGenerated.Arguments.class, ResolvedCallsTestGenerated.DifferentCallElements.class, ResolvedCallsTestGenerated.Dynamic.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.ObjectsAndClassObjects.class, ResolvedCallsTestGenerated.RealExamples.class, ResolvedCallsTestGenerated.Resolve.class, ResolvedCallsTestGenerated.ThisOrSuper.class})
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
|
||||
public void testAllFilesPresentInResolvedCalls() throws Exception {
|
||||
@@ -290,6 +290,51 @@ public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/resolvedCalls/dynamic")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Dynamic extends AbstractResolvedCallsTest {
|
||||
public void testAllFilesPresentInDynamic() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/resolvedCalls/dynamic"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("explicitReceiverIsDispatchReceiver.kt")
|
||||
public void testExplicitReceiverIsDispatchReceiver() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/resolvedCalls/dynamic/explicitReceiverIsDispatchReceiver.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("explicitReceiverIsExtensionReceiver.kt")
|
||||
public void testExplicitReceiverIsExtensionReceiver() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/resolvedCalls/dynamic/explicitReceiverIsExtensionReceiver.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("hasBothDispatchAndExtensionReceivers.kt")
|
||||
public void testHasBothDispatchAndExtensionReceivers() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/resolvedCalls/dynamic/hasBothDispatchAndExtensionReceivers.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("hasBothDispatchAndExtensionReceiversWithoutExplicitReceiver.kt")
|
||||
public void testHasBothDispatchAndExtensionReceiversWithoutExplicitReceiver() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/resolvedCalls/dynamic/hasBothDispatchAndExtensionReceiversWithoutExplicitReceiver.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("implicitReceiverIsDispatchReceiver.kt")
|
||||
public void testImplicitReceiverIsDispatchReceiver() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/resolvedCalls/dynamic/implicitReceiverIsDispatchReceiver.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("implicitReceiverIsExtensionReceiver.kt")
|
||||
public void testImplicitReceiverIsExtensionReceiver() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/resolvedCalls/dynamic/implicitReceiverIsExtensionReceiver.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/resolvedCalls/functionTypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user