Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Commit

Permalink
Don't use fields for non-strict interop enum constants
Browse files Browse the repository at this point in the history
  • Loading branch information
SvyatoslavScherbina committed Aug 30, 2018
1 parent 2b86126 commit 71405c3
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,15 @@ class StubGenerator(
it.name !in macroConstantsByName
}

val typeName: String
val kotlinType: KotlinType

val baseKotlinType = mirror(e.baseType).argType.render(kotlinFile)
val baseKotlinType = mirror(e.baseType).argType
if (e.isAnonymous) {
if (constants.isNotEmpty()) {
out("// ${e.spelling}:")
}

typeName = baseKotlinType
kotlinType = baseKotlinType
} else {
val typeMirror = mirror(EnumType(e))
if (typeMirror !is TypeMirror.ByValue) {
Expand All @@ -538,18 +538,18 @@ class StubGenerator(
val varTypeClassifier = typeMirror.pointedType.classifier
val valueTypeClassifier = typeMirror.valueType.classifier
out("typealias ${kotlinFile.declare(varTypeClassifier)} = $varTypeName")
out("typealias ${kotlinFile.declare(valueTypeClassifier)} = $baseKotlinType")
out("typealias ${kotlinFile.declare(valueTypeClassifier)} = ${baseKotlinType.render(kotlinFile)}")

if (constants.isNotEmpty()) {
out("")
}

typeName = typeMirror.valueType.render(kotlinFile)
kotlinType = typeMirror.valueType
}

for (constant in constants) {
val literal = integerLiteral(e.baseType, constant.value) ?: continue
out("val ${constant.name.asSimpleName()}: $typeName = $literal")
out(topLevelValWithGetter(constant.name, kotlinType, literal))
}
}

Expand Down

0 comments on commit 71405c3

Please sign in to comment.