Don't generate default no-args constructor for enums
#KT-8438 Fixed
This commit is contained in:
@@ -206,6 +206,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
|
||||
|
||||
private fun isEmptyConstructorNeeded(constructorDescriptor: ConstructorDescriptor, classOrObject: JetClassOrObject): Boolean {
|
||||
val classDescriptor = constructorDescriptor.getContainingDeclaration()
|
||||
if (classDescriptor.getKind() != ClassKind.CLASS) return false
|
||||
|
||||
if (classOrObject.isLocal()) return false
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// KT-8438 org.jetbrains.org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 4: Cannot pop operand off an empty stack
|
||||
|
||||
enum class E public constructor(x: String = "OK") {
|
||||
ENTRY();
|
||||
|
||||
val result = x
|
||||
}
|
||||
|
||||
fun box(): String = E.ENTRY.result
|
||||
+6
@@ -3475,6 +3475,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("publicConstructorWithDefault.kt")
|
||||
public void testPublicConstructorWithDefault() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/publicConstructorWithDefault.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/simple.kt");
|
||||
|
||||
Reference in New Issue
Block a user