Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankoppier committed Sep 28, 2024
1 parent 7e13813 commit a714540
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tech.mappie.generation.enums

import org.jetbrains.kotlin.ir.declarations.IrEnumEntry
import org.jetbrains.kotlin.ir.declarations.IrFunction
import tech.mappie.generation.CodeGenerationModelFactory
import tech.mappie.generation.EnumMappieCodeGenerationModel
Expand All @@ -9,15 +10,18 @@ import tech.mappie.resolving.enums.ResolvedEnumMappingTarget

class EnumMappieCodeGenerationModelFactory(private val request: EnumMappingRequest) : CodeGenerationModelFactory {

@Suppress("UNCHECKED_CAST")
override fun construct(function: IrFunction): EnumMappieCodeGenerationModel =
EnumMappieCodeGenerationModel(
function,
request.source,
request.target,
request.mappings.mapValues { (_, targets) -> select(targets) }
request.mappings
.mapValues { (_, targets) -> select(targets) }
.filterValues { it != null } as Map<IrEnumEntry, EnumMappingTarget>
)

private fun select(targets: List<EnumMappingTarget>): EnumMappingTarget =
private fun select(targets: List<EnumMappingTarget>): EnumMappingTarget? =
targets.firstOrNull { it !is ResolvedEnumMappingTarget }
?: targets.first { it is ResolvedEnumMappingTarget }
?: targets.firstOrNull { it is ResolvedEnumMappingTarget }
}
4 changes: 4 additions & 0 deletions website/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
title: "Changelog"
layout: "layouts/changelog.html"
changelog:
- date: "tbd"
title: "v0.9.0"
items:
- "fixed a bug where the `strictness.enums` option set to `true` possibly resulted in a compilation error."
- date: "2024-09-22"
title: "v0.8.0"
items:
Expand Down

0 comments on commit a714540

Please sign in to comment.