Don't generate enum entry initializers for 'expect enum class'
This commit is contained in:
@@ -282,9 +282,11 @@ class ClassGenerator(declarationGenerator: DeclarationGenerator) : DeclarationGe
|
||||
IrDeclarationOrigin.DEFINED,
|
||||
enumEntryDescriptor
|
||||
).buildWithScope { irEnumEntry ->
|
||||
irEnumEntry.initializerExpression =
|
||||
createBodyGenerator(irEnumEntry.symbol)
|
||||
.generateEnumEntryInitializer(ktEnumEntry, enumEntryDescriptor)
|
||||
if (!enumEntryDescriptor.isExpect) {
|
||||
irEnumEntry.initializerExpression =
|
||||
createBodyGenerator(irEnumEntry.symbol)
|
||||
.generateEnumEntryInitializer(ktEnumEntry, enumEntryDescriptor)
|
||||
}
|
||||
|
||||
if (ktEnumEntry.declarations.isNotEmpty()) {
|
||||
irEnumEntry.correspondingClass = generateClass(ktEnumEntry)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
expect enum class MyEnum {
|
||||
FOO,
|
||||
BAR
|
||||
}
|
||||
|
||||
actual enum class MyEnum {
|
||||
FOO,
|
||||
BAR,
|
||||
BAZ
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
FILE fqName:<root> fileName:/expectedEnumClass.kt
|
||||
CLASS ENUM_CLASS name:MyEnum modality:FINAL visibility:public flags:
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:MyEnum flags:
|
||||
ENUM_ENTRY name:FOO
|
||||
ENUM_ENTRY name:BAR
|
||||
FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:Any flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:Unit flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:(java.lang.Class<(MyEnum..MyEnum?)>..java.lang.Class<(MyEnum..MyEnum?)>?) flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>, other:MyEnum) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
VALUE_PARAMETER name:other index:0 type:MyEnum flags:
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>, other:kotlin.Any?) returnType:Boolean flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags:
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
PROPERTY FAKE_OVERRIDE name:name type:kotlin.String visibility:public modality:FINAL flags:val
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:String flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
PROPERTY FAKE_OVERRIDE name:ordinal type:kotlin.Int visibility:public modality:FINAL flags:val
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<MyEnum>) returnType:String flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:Array<MyEnum> flags:
|
||||
SYNTHETIC_BODY kind=ENUM_VALUES
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:MyEnum flags:
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.String flags:
|
||||
SYNTHETIC_BODY kind=ENUM_VALUEOF
|
||||
CLASS ENUM_CLASS name:MyEnum modality:FINAL visibility:public flags:
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:MyEnum flags:
|
||||
CONSTRUCTOR visibility:private <> () returnType:MyEnum flags:
|
||||
BLOCK_BODY
|
||||
ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)'
|
||||
<E : Enum<E>>: null
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='MyEnum'
|
||||
ENUM_ENTRY name:FOO
|
||||
init: ENUM_CONSTRUCTOR_CALL 'constructor MyEnum()'
|
||||
ENUM_ENTRY name:BAR
|
||||
init: ENUM_CONSTRUCTOR_CALL 'constructor MyEnum()'
|
||||
ENUM_ENTRY name:BAZ
|
||||
init: ENUM_CONSTRUCTOR_CALL 'constructor MyEnum()'
|
||||
FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:Any flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:Unit flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:(java.lang.Class<(MyEnum..MyEnum?)>..java.lang.Class<(MyEnum..MyEnum?)>?) flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>, other:MyEnum) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
VALUE_PARAMETER name:other index:0 type:MyEnum flags:
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>, other:kotlin.Any?) returnType:Boolean flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags:
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
PROPERTY FAKE_OVERRIDE name:name type:kotlin.String visibility:public modality:FINAL flags:val
|
||||
FUN FAKE_OVERRIDE name:<get-name> visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:String flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
PROPERTY FAKE_OVERRIDE name:ordinal type:kotlin.Int visibility:public modality:FINAL flags:val
|
||||
FUN FAKE_OVERRIDE name:<get-ordinal> visibility:public modality:FINAL <> ($this:kotlin.Enum<MyEnum>) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<MyEnum>) returnType:String flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Enum<MyEnum> flags:
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:Array<MyEnum> flags:
|
||||
SYNTHETIC_BODY kind=ENUM_VALUES
|
||||
FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:MyEnum flags:
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.String flags:
|
||||
SYNTHETIC_BODY kind=ENUM_VALUEOF
|
||||
@@ -0,0 +1,7 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
expect sealed class Ops()
|
||||
expect class Add() : Ops
|
||||
|
||||
actual sealed class Ops actual constructor()
|
||||
actual class Add actual constructor() : Ops()
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
FILE fqName:<root> fileName:/expectedSealedClass.kt
|
||||
CLASS CLASS name:Ops modality:SEALED visibility:public flags:
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:Ops flags:
|
||||
CONSTRUCTOR visibility:private <> () returnType:Ops flags:
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags:
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
CLASS CLASS name:Add modality:FINAL visibility:public flags:
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:Add flags:
|
||||
CONSTRUCTOR visibility:public <> () returnType:Add flags:
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags:
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
CLASS CLASS name:Ops modality:SEALED visibility:public flags:
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:Ops flags:
|
||||
CONSTRUCTOR visibility:private <> () returnType:Ops flags:
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'constructor Any()'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='Ops'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags:
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
CLASS CLASS name:Add modality:FINAL visibility:public flags:
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:Add flags:
|
||||
CONSTRUCTOR visibility:public <> () returnType:Add flags:
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'constructor Ops()'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='Add'
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags:
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags:
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||
@@ -331,6 +331,18 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedEnumClass.kt")
|
||||
public void testExpectedEnumClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedSealedClass.kt")
|
||||
public void testExpectedSealedClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/ir/irText/declarations/parameters")
|
||||
|
||||
Reference in New Issue
Block a user