[FE] Resolve overload conflict between contextual and non-contextual declarations

This commit is contained in:
Anastasiya Shadrina
2021-06-30 19:07:26 +07:00
committed by TeamCityServer
parent 7fd5034cd6
commit f427265739
12 changed files with 267 additions and 125 deletions
@@ -10567,128 +10567,154 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/extensions/variableInvoke.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/extensions/contextReceivers")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ContextReceivers extends AbstractDiagnosisCompilerTestDataTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class ContextReceivers {
@Test
public void testAllFilesPresentInContextReceivers() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/extensions/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("ambiguityInGroup.kt")
public void testAmbiguityInGroup() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/ambiguityInGroup.kt");
}
@Test
@TestMetadata("dp.kt")
public void testDp() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/dp.kt");
}
@Test
@TestMetadata("genericOuterClass.kt")
public void testGenericOuterClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/genericOuterClass.kt");
}
@Test
@TestMetadata("insideDeclaration.kt")
public void testInsideDeclaration() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/insideDeclaration.kt");
}
@Test
@TestMetadata("lazy.kt")
public void testLazy() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/lazy.kt");
}
@Test
@TestMetadata("localDeclaration.kt")
public void testLocalDeclaration() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/localDeclaration.kt");
}
@Test
@TestMetadata("manyReceivers.kt")
public void testManyReceivers() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/manyReceivers.kt");
}
@Test
@TestMetadata("noBackingField.kt")
public void testNoBackingField() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noBackingField.kt");
}
@Test
@TestMetadata("noContextReceiversOnInlineClasses.kt")
public void testNoContextReceiversOnInlineClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnInlineClasses.kt");
}
@Test
@TestMetadata("noExplicitReceiver.kt")
public void testNoExplicitReceiver() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/noExplicitReceiver.kt");
}
@Test
@TestMetadata("outerClass.kt")
public void testOuterClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.kt");
}
@Test
@TestMetadata("overloadPriority.kt")
public void testOverloadPriority() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.kt");
}
@Test
@TestMetadata("plusMatrix.kt")
public void testPlusMatrix() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/plusMatrix.kt");
}
@Test
@TestMetadata("superWithContext.kt")
public void testSuperWithContext() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/superWithContext.kt");
}
@Test
@TestMetadata("syntaxError.kt")
public void testSyntaxError() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/syntaxError.kt");
}
@Test
@TestMetadata("thisIdentifierInfo.kt")
public void testThisIdentifierInfo() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/thisIdentifierInfo.kt");
}
@Test
@TestMetadata("thisWithCustomLabel.kt")
public void testThisWithCustomLabel() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithCustomLabel.kt");
}
@Test
@TestMetadata("thisWithReceiverLabelsClasses.kt")
public void testThisWithReceiverLabelsClasses() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsClasses.kt");
}
@Test
@TestMetadata("thisWithReceiverLabelsFunctions.kt")
public void testThisWithReceiverLabelsFunctions() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsFunctions.kt");
}
@Test
@TestMetadata("thisWithReceiverLabelsProperties.kt")
public void testThisWithReceiverLabelsProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/thisWithReceiverLabelsProperties.kt");
}
@Test
@TestMetadata("typeParameterized.kt")
public void testTypeParameterized() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterized.kt");
}
@Test
@TestMetadata("typeParameterizedList.kt")
public void testTypeParameterizedList() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/typeParameterizedList.kt");
}
@Test
@TestMetadata("withExplicitReceiver.kt")
public void testWithExplicitReceiver() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiver.kt");
}
@Test
@TestMetadata("withExplicitReceiverError.kt")
public void testWithExplicitReceiverError() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/withExplicitReceiverError.kt");
@@ -33,64 +33,49 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/annotations")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Annotations extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Annotations {
@Test
public void testAllFilesPresentInAnnotations() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/annotations"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/annotations/annotation-targets")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Annotation_targets extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Annotation_targets {
@Test
public void testAllFilesPresentInAnnotation_targets() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/annotations/annotation-targets"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/built-in-types-and-their-semantics")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Built_in_types_and_their_semantics extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Built_in_types_and_their_semantics {
@Test
public void testAllFilesPresentInBuilt_in_types_and_their_semantics() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/built-in-types-and-their-semantics"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/built-in-types-and-their-semantics/built-in-integer-types-1")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Built_in_integer_types_1 extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Built_in_integer_types_1 {
@Test
public void testAllFilesPresentInBuilt_in_integer_types_1() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/built-in-types-and-their-semantics/built-in-integer-types-1"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/built-in-types-and-their-semantics/built-in-integer-types-1/integer-type-widening")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Integer_type_widening extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Integer_type_widening {
@Test
public void testAllFilesPresentInInteger_type_widening() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/built-in-types-and-their-semantics/built-in-integer-types-1/integer-type-widening"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -215,26 +200,20 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Performing_analysis_on_the_control_flow_graph extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Performing_analysis_on_the_control_flow_graph {
@Test
public void testAllFilesPresentInPerforming_analysis_on_the_control_flow_graph() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph/variable-initialization-analysis")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Variable_initialization_analysis extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Variable_initialization_analysis {
@Test
public void testAllFilesPresentInVariable_initialization_analysis() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph/variable-initialization-analysis"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -242,14 +221,11 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Control__and_data_flow_analysis_control_flow_graph_expressions_1_conditional_expressions extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Control__and_data_flow_analysis_control_flow_graph_expressions_1_conditional_expressions {
@Test
public void testAllFilesPresentInControl__and_data_flow_analysis_control_flow_graph_expressions_1_conditional_expressions() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -622,55 +598,43 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/nested-and-inner-classifiers")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Nested_and_inner_classifiers extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Nested_and_inner_classifiers {
@Test
public void testAllFilesPresentInNested_and_inner_classifiers() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/nested-and-inner-classifiers"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/classifier-initialization")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Classifier_initialization extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Classifier_initialization {
@Test
public void testAllFilesPresentInClassifier_initialization() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/classifier-initialization"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/data-class-declaration")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Data_class_declaration extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Data_class_declaration {
@Test
public void testAllFilesPresentInData_class_declaration() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/data-class-declaration"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/declarations/function-declaration")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Function_declaration extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Function_declaration {
@Test
public void testAllFilesPresentInFunction_declaration() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/declarations/function-declaration"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -721,28 +685,22 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/declarations/property-declaration/property-initialization")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Property_initialization extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Property_initialization {
@Test
public void testAllFilesPresentInProperty_initialization() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/declarations/property-declaration/property-initialization"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/declarations/type-alias")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Type_alias extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Type_alias {
@Test
public void testAllFilesPresentInType_alias() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/declarations/type-alias"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -876,6 +834,36 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/call-and-property-access-expressions")
@TestDataPath("$PROJECT_ROOT")
public class Call_and_property_access_expressions {
@Test
public void testAllFilesPresentInCall_and_property_access_expressions() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/call-and-property-access-expressions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/call-and-property-access-expressions/callable-references")
@TestDataPath("$PROJECT_ROOT")
public class Callable_references {
@Test
public void testAllFilesPresentInCallable_references() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/call-and-property-access-expressions/callable-references"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/call-and-property-access-expressions/navigation-operators")
@TestDataPath("$PROJECT_ROOT")
public class Navigation_operators {
@Test
public void testAllFilesPresentInNavigation_operators() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/call-and-property-access-expressions/navigation-operators"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/comparison-expressions")
@TestDataPath("$PROJECT_ROOT")
@@ -1946,6 +1934,26 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/function-literals")
@TestDataPath("$PROJECT_ROOT")
public class Function_literals {
@Test
public void testAllFilesPresentInFunction_literals() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/function-literals"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/function-literals/lambda-literals")
@TestDataPath("$PROJECT_ROOT")
public class Lambda_literals {
@Test
public void testAllFilesPresentInLambda_literals() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/function-literals/lambda-literals"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/jump-expressions")
@TestDataPath("$PROJECT_ROOT")
@@ -3355,6 +3363,26 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/inheritance")
@TestDataPath("$PROJECT_ROOT")
public class Inheritance {
@Test
public void testAllFilesPresentInInheritance() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/inheritance"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/inheritance/overriding")
@TestDataPath("$PROJECT_ROOT")
public class Overriding {
@Test
public void testAllFilesPresentInOverriding() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/inheritance/overriding"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution")
@TestDataPath("$PROJECT_ROOT")
@@ -4356,6 +4384,16 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/c-level-partition")
@TestDataPath("$PROJECT_ROOT")
public class C_level_partition {
@Test
public void testAllFilesPresentInC_level_partition() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/c-level-partition"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/callables-and-invoke-convention")
@TestDataPath("$PROJECT_ROOT")
@@ -4853,14 +4891,11 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/determining-function-applicability-for-a-specific-call/rationale")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Rationale extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Rationale {
@Test
public void testAllFilesPresentInRationale() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overload-resolution/determining-function-applicability-for-a-specific-call/rationale"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -5136,6 +5171,16 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/overloadable-operators")
@TestDataPath("$PROJECT_ROOT")
public class Overloadable_operators {
@Test
public void testAllFilesPresentInOverloadable_operators() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/overloadable-operators"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/statements")
@TestDataPath("$PROJECT_ROOT")
@@ -5264,14 +5309,11 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/statements/assignments/simple-assignments")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Simple_assignments extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Simple_assignments {
@Test
public void testAllFilesPresentInSimple_assignments() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/statements/assignments/simple-assignments"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -5422,14 +5464,11 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-inference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-inference/local-type-inference")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Local_type_inference extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Local_type_inference {
@Test
public void testAllFilesPresentInLocal_type_inference() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-inference/local-type-inference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -5496,14 +5535,11 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-types")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Smart_cast_types extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Smart_cast_types {
@Test
public void testAllFilesPresentInSmart_cast_types() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-types"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -5657,6 +5693,16 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-for-nullable-types")
@TestDataPath("$PROJECT_ROOT")
public class Subtyping_for_nullable_types {
@Test
public void testAllFilesPresentInSubtyping_for_nullable_types() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-for-nullable-types"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-rules")
@TestDataPath("$PROJECT_ROOT")
@@ -5893,14 +5939,11 @@ public class FirIdeSpecTest extends AbstractDiagnosisCompilerTestDataSpecTest {
}
}
@Nested
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/type-system/type-kinds/type-parameters")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Type_parameters extends AbstractDiagnosisCompilerTestDataSpecTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public class Type_parameters {
@Test
public void testAllFilesPresentInType_parameters() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/type-system/type-kinds/type-parameters"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@@ -10642,6 +10642,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.kt");
}
@Test
@TestMetadata("overloadPriority.kt")
public void testOverloadPriority() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.kt");
}
@Test
@TestMetadata("plusMatrix.kt")
public void testPlusMatrix() throws Exception {
@@ -10642,6 +10642,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.kt");
}
@Test
@TestMetadata("overloadPriority.kt")
public void testOverloadPriority() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.kt");
}
@Test
@TestMetadata("plusMatrix.kt")
public void testPlusMatrix() throws Exception {
@@ -113,6 +113,7 @@ abstract class AbstractConeCallConflictResolver(
(variable as? FirProperty)?.typeParameters?.map { it.symbol.toLookupTag() }.orEmpty(),
listOfNotNull(variable.receiverTypeRef?.coneType),
variable.receiverTypeRef != null,
0, // TODO
false,
0,
(variable as? FirProperty)?.isExpect == true,
@@ -127,6 +128,7 @@ abstract class AbstractConeCallConflictResolver(
computeParameterTypes(call, constructor),
//constructor.receiverTypeRef != null,
false,
0, // TODO
constructor.valueParameters.any { it.isVararg },
call.numDefaults,
constructor.isExpect,
@@ -140,6 +142,7 @@ abstract class AbstractConeCallConflictResolver(
function.typeParameters.map { it.symbol.toLookupTag() },
computeParameterTypes(call, function),
function.receiverTypeRef != null,
0, // TODO
function.valueParameters.any { it.isVararg },
call.numDefaults,
function.isExpect,
@@ -168,6 +171,7 @@ abstract class AbstractConeCallConflictResolver(
(klass as? FirTypeParameterRefsOwner)?.typeParameters?.map { it.symbol.toLookupTag() }.orEmpty(),
emptyList(),
hasExtensionReceiver = false,
0, // TODO
hasVarargs = false,
numDefaults = 0,
isExpect = (klass as? FirRegularClass)?.isExpect == true,
@@ -18,6 +18,7 @@ class FlatSignature<out T> constructor(
val origin: T,
val typeParameters: Collection<TypeParameterMarker>,
val hasExtensionReceiver: Boolean,
val contextReceiverCount: Int,
val hasVarargs: Boolean,
val numDefaults: Int,
val isExpect: Boolean,
@@ -31,12 +32,13 @@ class FlatSignature<out T> constructor(
typeParameters: Collection<TypeParameterMarker>,
valueParameterTypes: List<KotlinTypeMarker?>,
hasExtensionReceiver: Boolean,
contextReceiverCount: Int,
hasVarargs: Boolean,
numDefaults: Int,
isExpect: Boolean,
isSyntheticMember: Boolean,
) : this(
origin, typeParameters, hasExtensionReceiver, hasVarargs, numDefaults, isExpect,
origin, typeParameters, hasExtensionReceiver, contextReceiverCount, hasVarargs, numDefaults, isExpect,
isSyntheticMember, valueParameterTypes.map(::TypeWithConversion)
)
@@ -106,6 +108,7 @@ fun <T> SimpleConstraintSystem.isSignatureNotLessSpecific(
useOriginalSamTypes: Boolean = false
): Boolean {
if (specific.hasExtensionReceiver != general.hasExtensionReceiver) return false
if (specific.contextReceiverCount != general.contextReceiverCount) return false
if (specific.valueParameterTypes.size != general.valueParameterTypes.size) return false
if (!isValueParameterTypeNotLessSpecific(specific, general, callbacks, specificityComparator) { it?.resultType }) {
@@ -27,6 +27,7 @@ fun <T> FlatSignature.Companion.createFromReflectionType(
// Plus, currently, receiver for reflection type is taking from *candidate*, see buildReflectionType, this candidate can
// have transient receiver which is not the same in its signature
val receiver = descriptor.extensionReceiverParameter?.type
val contextReceiversTypes = descriptor.contextReceiverParameters.mapNotNull { it.type }
val parameters = reflectionType.getValueParameterTypesFromCallableReflectionType(
receiver != null && !hasBoundExtensionReceiver
).map { it.type }
@@ -34,8 +35,9 @@ fun <T> FlatSignature.Companion.createFromReflectionType(
return FlatSignature(
origin,
descriptor.typeParameters,
listOfNotNull(receiver) + parameters,
contextReceiversTypes + listOfNotNull(receiver) + parameters,
hasExtensionReceiver = receiver != null,
contextReceiverCount = contextReceiversTypes.size,
hasVarargs = descriptor.valueParameters.any { it.varargElementType != null },
numDefaults = numDefaults,
isExpect = descriptor is MemberDescriptor && descriptor.isExpect,
@@ -52,12 +54,14 @@ fun <T> FlatSignature.Companion.create(
parameterTypes: List<TypeWithConversion?>,
): FlatSignature<T> {
val extensionReceiverType = descriptor.extensionReceiverParameter?.type
val contextReceiverTypes = descriptor.contextReceiverParameters.mapNotNull { TypeWithConversion(it.type) }
return FlatSignature(
origin,
descriptor.typeParameters,
valueParameterTypes = extensionReceiverType?.let { listOf(TypeWithConversion(it)) }.orEmpty() + parameterTypes,
valueParameterTypes = contextReceiverTypes + extensionReceiverType?.let { listOf(TypeWithConversion(it)) }.orEmpty() + parameterTypes,
hasExtensionReceiver = extensionReceiverType != null,
contextReceiverCount = contextReceiverTypes.size,
hasVarargs = descriptor.valueParameters.any { it.varargElementType != null },
numDefaults = numDefaults,
isExpect = descriptor is MemberDescriptor && descriptor.isExpect,
@@ -72,12 +76,14 @@ fun <T> FlatSignature.Companion.create(
parameterTypes: List<KotlinType?>
): FlatSignature<T> {
val extensionReceiverType = descriptor.extensionReceiverParameter?.type
val contextReceiverTypes = descriptor.contextReceiverParameters.mapNotNull { it.type }
return FlatSignature(
origin,
descriptor.typeParameters,
valueParameterTypes = listOfNotNull(extensionReceiverType) + parameterTypes,
valueParameterTypes = contextReceiverTypes + listOfNotNull(extensionReceiverType) + parameterTypes,
hasExtensionReceiver = extensionReceiverType != null,
contextReceiverCount = contextReceiverTypes.size,
hasVarargs = descriptor.valueParameters.any { it.varargElementType != null },
numDefaults = numDefaults,
isExpect = descriptor is MemberDescriptor && descriptor.isExpect,
@@ -89,9 +95,11 @@ fun <D : CallableDescriptor> FlatSignature.Companion.createFromCallableDescripto
FlatSignature(
descriptor,
descriptor.typeParameters,
valueParameterTypes = listOfNotNull(descriptor.extensionReceiverParameter?.type)
valueParameterTypes = descriptor.contextReceiverParameters.map { it.type }
+ listOfNotNull(descriptor.extensionReceiverParameter?.type)
+ descriptor.valueParameters.map { it.argumentValueType },
hasExtensionReceiver = descriptor.extensionReceiverParameter?.type != null,
contextReceiverCount = descriptor.contextReceiverParameters.size,
hasVarargs = descriptor.valueParameters.any { it.varargElementType != null },
numDefaults = 0,
isExpect = descriptor is MemberDescriptor && descriptor.isExpect,
@@ -104,6 +112,7 @@ fun <D : CallableDescriptor> FlatSignature.Companion.createForPossiblyShadowedEx
descriptor.typeParameters,
valueParameterTypes = descriptor.valueParameters.map { it.argumentValueType },
hasExtensionReceiver = false,
contextReceiverCount = 0,
hasVarargs = descriptor.valueParameters.any { it.varargElementType != null },
numDefaults = descriptor.valueParameters.count { it.hasDefaultValue() },
isExpect = descriptor is MemberDescriptor && descriptor.isExpect,
@@ -310,6 +310,9 @@ open class OverloadingConflictResolver<C : Any>(
if (!call1.isExpect && call2.isExpect) return true
if (call1.isExpect && !call2.isExpect) return false
if (call1.contextReceiverCount > call2.contextReceiverCount) return true
if (call1.contextReceiverCount < call2.contextReceiverCount) return false
return createEmptyConstraintSystem().isSignatureNotLessSpecific(
call1,
call2,
@@ -0,0 +1,12 @@
class Context
<!CONFLICTING_OVERLOADS!>context(Context)
fun f(): String<!> = TODO()
<!CONFLICTING_OVERLOADS!>fun f(): Any<!> = TODO()
fun test() {
with(Context()) {
f().length
}
}
@@ -0,0 +1,12 @@
class Context
context(Context)
fun f(): String = TODO()
fun f(): Any = TODO()
fun test() {
with(Context()) {
f().length
}
}
@@ -0,0 +1,12 @@
package
public fun f(): kotlin.Any
public fun f(): kotlin.String
public fun test(): kotlin.Unit
public final class Context {
public constructor Context()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -10648,6 +10648,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/outerClass.kt");
}
@Test
@TestMetadata("overloadPriority.kt")
public void testOverloadPriority() throws Exception {
runTest("compiler/testData/diagnostics/tests/extensions/contextReceivers/overloadPriority.kt");
}
@Test
@TestMetadata("plusMatrix.kt")
public void testPlusMatrix() throws Exception {