@@ -2,14 +2,18 @@ package io.deepmedia.tools.knee.plugin.compiler.utils
22
33import com.squareup.kotlinpoet.*
44import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
5+ import io.deepmedia.tools.knee.plugin.compiler.codegen.CodegenType
56import org.jetbrains.kotlin.descriptors.*
67import org.jetbrains.kotlin.ir.declarations.*
78import org.jetbrains.kotlin.ir.expressions.IrConst
89import org.jetbrains.kotlin.ir.expressions.IrConstKind
910import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
11+ import org.jetbrains.kotlin.ir.expressions.IrGetEnumValue
1012import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
13+ import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
1114import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
1215import org.jetbrains.kotlin.ir.types.*
16+ import org.jetbrains.kotlin.ir.util.dump
1317import org.jetbrains.kotlin.types.Variance
1418
1519
@@ -212,8 +216,12 @@ fun IrValueParameter.defaultValueForCodegen(functionExpects: List<IrDeclarationW
212216 // is IrConstKind.Long -> CodeBlock.of(kind.valueOf(expression).toString() + "L")
213217 // else -> return null
214218 }
219+ } else if (expression is IrGetEnumValue && type is IrSimpleType ) {
220+ // No need to check whether the type is serializable, that would throw an error somewhere else
221+ val type: TypeName = (type as IrSimpleType ).asTypeName()
222+ val entry: String = expression.symbol.owner.name.asString()
223+ return CodeBlock .of(" %T.%N" , type, entry)
215224 }
216- // risky option: take expression.dumpKotlinLike() as string.
217225 return null
218226}
219227
0 commit comments