Skip to content

Commit 4791aaa

Browse files
committed
Kotlin: Use an enum for compiler-generated-kinds
For now this is in KotlinFileExtractor, but we can move it out later if we have generated things elsewhere.
1 parent 27b83a0 commit 4791aaa

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ open class KotlinFileExtractor(
595595
tw.writeMethods(clinitId, "<clinit>", "<clinit>()", returnType.javaResult.id, parentId, clinitId)
596596
tw.writeMethodsKotlinType(clinitId, returnType.kotlinResult.id)
597597

598-
tw.writeCompiler_generated(clinitId, 4)
598+
tw.writeCompiler_generated(clinitId, CompilerGeneratedKinds.CLASS_INITIALISATION_METHOD.kind)
599599

600600
val locId = tw.getWholeFileLocation()
601601
tw.writeHasLocation(clinitId, locId)
@@ -787,11 +787,11 @@ open class KotlinFileExtractor(
787787
tw.writeMethodsKotlinType(methodId, returnType.kotlinResult.id)
788788
when (f.origin) {
789789
IrDeclarationOrigin.GENERATED_DATA_CLASS_MEMBER ->
790-
tw.writeCompiler_generated(methodId, 2)
790+
tw.writeCompiler_generated(methodId, CompilerGeneratedKinds.GENERATED_DATA_CLASS_MEMBER.kind)
791791
IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR ->
792-
tw.writeCompiler_generated(methodId, 3)
792+
tw.writeCompiler_generated(methodId, CompilerGeneratedKinds.DEFAULT_PROPERTY_ACCESSOR.kind)
793793
IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER ->
794-
tw.writeCompiler_generated(methodId, 5)
794+
tw.writeCompiler_generated(methodId, CompilerGeneratedKinds.ENUM_CLASS_SPECIAL_MEMBER.kind)
795795
}
796796

797797
if (extractMethodAndParameterTypeAccesses) {
@@ -1083,7 +1083,7 @@ open class KotlinFileExtractor(
10831083
tw.writeKtLocalFunction(ids.function)
10841084

10851085
if (s.origin == IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE) {
1086-
tw.writeCompiler_generated(classId, 1)
1086+
tw.writeCompiler_generated(classId, CompilerGeneratedKinds.DECLARING_CLASSES_OF_ADAPTER_FUNCTIONS.kind)
10871087
}
10881088
} else {
10891089
logger.errorElement("Expected to find local function", s)
@@ -4380,4 +4380,12 @@ open class KotlinFileExtractor(
43804380
declarationStack.pop()
43814381
}
43824382
}
4383+
4384+
private enum class CompilerGeneratedKinds(val kind: Int) {
4385+
DECLARING_CLASSES_OF_ADAPTER_FUNCTIONS(1),
4386+
GENERATED_DATA_CLASS_MEMBER(2),
4387+
DEFAULT_PROPERTY_ACCESSOR(3),
4388+
CLASS_INITIALISATION_METHOD(4),
4389+
ENUM_CLASS_SPECIAL_MEMBER(5)
4390+
}
43834391
}

0 commit comments

Comments
 (0)