Added tests for 'super' resolved calls

This commit is contained in:
Svetlana Isakova
2014-07-10 17:17:13 +04:00
parent 11ea241efb
commit 22624186f6
12 changed files with 75 additions and 10 deletions
@@ -48,6 +48,7 @@ import org.jetbrains.jet.lang.resolve.calls.CallTransformer.CallForImplicitInvok
import org.jetbrains.kotlin.util.sure
import org.jetbrains.jet.lang.psi.JetCallElement
import org.jetbrains.jet.lang.psi.psiUtil.getTextWithLocation
import org.jetbrains.jet.lang.psi.JetInstanceExpressionWithLabel
/**
* For expressions like <code>a(), a[i], a.b.c(), +a, a + b, (a()), a(): Int, @label a()</code>
@@ -62,7 +63,7 @@ public fun JetElement.getCall(context: BindingContext): Call? {
val parent = element.getParent()
val reference = when {
parent is JetThisExpression -> parent : JetThisExpression
parent is JetInstanceExpressionWithLabel -> parent : JetInstanceExpressionWithLabel
else -> element.getCalleeExpressionIfAny()
}
if (reference != null) {
@@ -0,0 +1,9 @@
open class A {
open fun foo() {}
}
class B: A() {
override fun foo() {
<caret>super@B.foo()
}
}
@@ -0,0 +1,18 @@
open class A {
open fun foo() {}
}
class B: A() {
override fun foo() {
<caret>super@B.foo()
}
}
Resolved call:
Resulting descriptor: Class{B}::this
Explicit receiver kind = NO_EXPLICIT_RECEIVER
This object = NO_RECEIVER
Receiver argument = NO_RECEIVER
@@ -0,0 +1,9 @@
open class A {
open fun foo() {}
}
class B: A() {
override fun foo() {
<caret>super.foo()
}
}
@@ -0,0 +1,18 @@
open class A {
open fun foo() {}
}
class B: A() {
override fun foo() {
<caret>super.foo()
}
}
Resolved call:
Resulting descriptor: Class{B}::this
Explicit receiver kind = NO_EXPLICIT_RECEIVER
This object = NO_RECEIVER
Receiver argument = NO_RECEIVER
@@ -31,7 +31,7 @@ import org.jetbrains.jet.resolve.calls.AbstractResolvedCallsTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/resolvedCalls")
@InnerTestClasses({ResolvedCallsTestGenerated.Arguments.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.RealExamples.class, ResolvedCallsTestGenerated.This.class})
@InnerTestClasses({ResolvedCallsTestGenerated.Arguments.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.RealExamples.class, ResolvedCallsTestGenerated.ThisOrSuper.class})
public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
public void testAllFilesPresentInResolvedCalls() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/resolvedCalls"), Pattern.compile("^(.+)\\.kt$"), true);
@@ -319,25 +319,35 @@ public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
}
@TestMetadata("compiler/testData/resolvedCalls/this")
public static class This extends AbstractResolvedCallsTest {
public void testAllFilesPresentInThis() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/resolvedCalls/this"), Pattern.compile("^(.+)\\.kt$"), true);
@TestMetadata("compiler/testData/resolvedCalls/thisOrSuper")
public static class ThisOrSuper extends AbstractResolvedCallsTest {
public void testAllFilesPresentInThisOrSuper() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/resolvedCalls/thisOrSuper"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("labeledSuper.kt")
public void testLabeledSuper() throws Exception {
doTest("compiler/testData/resolvedCalls/thisOrSuper/labeledSuper.kt");
}
@TestMetadata("labeledThis.kt")
public void testLabeledThis() throws Exception {
doTest("compiler/testData/resolvedCalls/this/labeledThis.kt");
doTest("compiler/testData/resolvedCalls/thisOrSuper/labeledThis.kt");
}
@TestMetadata("simpleSuper.kt")
public void testSimpleSuper() throws Exception {
doTest("compiler/testData/resolvedCalls/thisOrSuper/simpleSuper.kt");
}
@TestMetadata("simpleThis.kt")
public void testSimpleThis() throws Exception {
doTest("compiler/testData/resolvedCalls/this/simpleThis.kt");
doTest("compiler/testData/resolvedCalls/thisOrSuper/simpleThis.kt");
}
@TestMetadata("thisInExtensionFunction.kt")
public void testThisInExtensionFunction() throws Exception {
doTest("compiler/testData/resolvedCalls/this/thisInExtensionFunction.kt");
doTest("compiler/testData/resolvedCalls/thisOrSuper/thisInExtensionFunction.kt");
}
}
@@ -349,7 +359,7 @@ public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
suite.addTestSuite(FunctionTypes.class);
suite.addTestSuite(Invoke.class);
suite.addTestSuite(RealExamples.class);
suite.addTestSuite(This.class);
suite.addTestSuite(ThisOrSuper.class);
return suite;
}
}