KT-5963 Call to super shouldn't require type specification if there is no conflict

Implemented unqualified 'super' type resolution (in BasicExpressionTypingVisitor).

No overload resolution of any kind is involved.
Corresponding supertype is determined by the expected member name only:
- 'super.foo(...)' - function or property (of possibly callable type) 'foo'
- 'super.x' - property 'x'
Supertype should provide a non-abstract implementation of such member.
As a fall-back solution for diagnostics purposes, consider supertypes with abstract implementation of such member.

Diagnostics:
- AMBIGUOUS_SUPER on 'super', if multiple possible supertypes are available;
- ABSTRACT_SUPER_CALL on selector expression, if the only available implementation is abstract.

#KT-5963 Fixed
This commit is contained in:
dnpetrov
2015-06-08 15:35:32 +03:00
parent 46baffc233
commit 046189087a
28 changed files with 1070 additions and 2 deletions
@@ -13406,6 +13406,75 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/traitSuperCall.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class UnqualifiedSuper extends AbstractJetDiagnosticsTest {
public void testAllFilesPresentInUnqualifiedSuper() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("ambiguousSuperWithGenerics.kt")
public void testAmbiguousSuperWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/ambiguousSuperWithGenerics.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuper.kt")
public void testUnqualifiedSuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuper.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithAbstractMembers.kt")
public void testUnqualifiedSuperWithAbstractMembers() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithAbstractMembers.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithCallableProperty.kt")
public void testUnqualifiedSuperWithCallableProperty() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithCallableProperty.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithDeeperHierarchies.kt")
public void testUnqualifiedSuperWithDeeperHierarchies() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithDeeperHierarchies.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithGenerics.kt")
public void testUnqualifiedSuperWithGenerics() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithGenerics.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithInnerClass.kt")
public void testUnqualifiedSuperWithInnerClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithInnerClass.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithInterfaces.kt")
public void testUnqualifiedSuperWithInterfaces() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithInterfaces.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithLocalClass.kt")
public void testUnqualifiedSuperWithLocalClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithLocalClass.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithUnresolvedBase.kt")
public void testUnqualifiedSuperWithUnresolvedBase() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithUnresolvedBase.kt");
doTest(fileName);
}
}
}
@TestMetadata("compiler/testData/diagnostics/tests/traitWithRequired")
@@ -6807,6 +6807,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/super/traitproperty.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuper.kt")
public void testUnqualifiedSuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/super/unqualifiedSuper.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithDeeperHierarchies.kt")
public void testUnqualifiedSuperWithDeeperHierarchies() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/super/unqualifiedSuperWithDeeperHierarchies.kt");
doTest(fileName);
}
@TestMetadata("unqualifiedSuperWithLocalClass.kt")
public void testUnqualifiedSuperWithLocalClass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/super/unqualifiedSuperWithLocalClass.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/superConstructorCall")