Added tests for choosing 'most specific' resolution candidate

Fixed test (while resolve with library on android): 'run' resolves to library function
This commit is contained in:
Svetlana Isakova
2014-07-10 19:00:40 +04:00
parent eca2c7beea
commit fb4c256d08
6 changed files with 78 additions and 3 deletions
@@ -1,11 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
<!NO_TAIL_CALLS_FOUND!>tailRecursive fun foo()<!> {
run {
bar {
<!NON_TAIL_RECURSIVE_CALL!>foo<!>()
}
}
fun run(a: Any) {}
fun bar(a: Any) {}
fun box(): String {
foo()
@@ -0,0 +1,8 @@
fun <T> emptyList(): List<T> = throw Exception()
fun <T> doSmth(l: List<T>) {}
fun doSmth(a: Any) {}
fun bar() {
<caret>doSmth(emptyList())
}
@@ -0,0 +1,22 @@
fun <T> emptyList(): List<T> = throw Exception()
fun <T> doSmth(l: List<T>) {}
fun doSmth(a: Any) {}
fun bar() {
<caret>doSmth(emptyList())
}
Resolved call:
Candidate descriptor: fun <T> doSmth(l: List<T>): Unit
Resulting descriptor: fun <T> doSmth(l: List<???>): Unit
Explicit receiver kind = NO_EXPLICIT_RECEIVER
This object = NO_RECEIVER
Receiver argument = NO_RECEIVER
Value arguments mapping:
MATCH_MODULO_UNINFERRED_TYPES l : List<???> = emptyList()
@@ -0,0 +1,6 @@
fun foo() {
<caret>bar { }
}
fun bar(a: Any) = a
fun <T> bar(f: () -> T): T = f()
@@ -0,0 +1,20 @@
fun foo() {
<caret>bar { }
}
fun bar(a: Any) = a
fun <T> bar(f: () -> T): T = f()
Resolved call:
Candidate descriptor: fun <T> bar(f: () -> T): T
Resulting descriptor: fun <T> bar(f: () -> Unit): Unit
Explicit receiver kind = NO_EXPLICIT_RECEIVER
This object = NO_RECEIVER
Receiver argument = NO_RECEIVER
Value arguments mapping:
SUCCESS f : () -> Unit = { }
@@ -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.DifferentCallElements.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.RealExamples.class, ResolvedCallsTestGenerated.ThisOrSuper.class})
@InnerTestClasses({ResolvedCallsTestGenerated.Arguments.class, ResolvedCallsTestGenerated.DifferentCallElements.class, ResolvedCallsTestGenerated.FunctionTypes.class, ResolvedCallsTestGenerated.Invoke.class, ResolvedCallsTestGenerated.RealExamples.class, ResolvedCallsTestGenerated.Resolve.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);
@@ -342,6 +342,24 @@ public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
}
@TestMetadata("compiler/testData/resolvedCalls/resolve")
public static class Resolve extends AbstractResolvedCallsTest {
public void testAllFilesPresentInResolve() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/resolvedCalls/resolve"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("mostSpecificUninferredParam.kt")
public void testMostSpecificUninferredParam() throws Exception {
doTest("compiler/testData/resolvedCalls/resolve/mostSpecificUninferredParam.kt");
}
@TestMetadata("mostSpecificWithLambda.kt")
public void testMostSpecificWithLambda() throws Exception {
doTest("compiler/testData/resolvedCalls/resolve/mostSpecificWithLambda.kt");
}
}
@TestMetadata("compiler/testData/resolvedCalls/thisOrSuper")
public static class ThisOrSuper extends AbstractResolvedCallsTest {
public void testAllFilesPresentInThisOrSuper() throws Exception {
@@ -383,6 +401,7 @@ public class ResolvedCallsTestGenerated extends AbstractResolvedCallsTest {
suite.addTestSuite(FunctionTypes.class);
suite.addTestSuite(Invoke.class);
suite.addTestSuite(RealExamples.class);
suite.addTestSuite(Resolve.class);
suite.addTestSuite(ThisOrSuper.class);
return suite;
}