KT-7897 Do not require to call enum constructor for each entry if all parameters have default values

Do not report an error on enum entry without initializer if all parameters have default values
(error is still reported if there is no such constructor, or if the constructor call is ambiguous).

Record resolved call on KtEnumEntry.

NB is the enum entry has a corresponding subclass, we still have to generate the "default" constructor call,
because FE doesn't know about the platform-specific representation of that class and its constructors.

See also KT-14097, KT-15900
This commit is contained in:
Dmitry Petrov
2017-01-20 14:47:42 +03:00
parent d13c34200b
commit ee9a174c1f
23 changed files with 539 additions and 16 deletions
@@ -7018,6 +7018,39 @@ public class LightAnalysisModeCodegenTestGenerated extends AbstractLightAnalysis
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/valueof.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/codegen/box/enum/defaultCtor")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class DefaultCtor extends AbstractLightAnalysisModeCodegenTest {
public void testAllFilesPresentInDefaultCtor() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/enum/defaultCtor"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("constructorWithDefaultArguments.kt")
public void testConstructorWithDefaultArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/defaultCtor/constructorWithDefaultArguments.kt");
doTest(fileName);
}
@TestMetadata("constructorWithVararg.kt")
public void testConstructorWithVararg() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/defaultCtor/constructorWithVararg.kt");
doTest(fileName);
}
@TestMetadata("secondaryConstructorWithDefaultArguments.kt")
public void testSecondaryConstructorWithDefaultArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/defaultCtor/secondaryConstructorWithDefaultArguments.kt");
doTest(fileName);
}
@TestMetadata("secondaryConstructorWithVararg.kt")
public void testSecondaryConstructorWithVararg() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/defaultCtor/secondaryConstructorWithVararg.kt");
doTest(fileName);
}
}
}
@TestMetadata("compiler/testData/codegen/box/evaluate")