Skip to content

fix: allow enum auto-mapping when source is a strict subset of target#28

Merged
wilmveel merged 1 commit intomainfrom
fix/enum-subset-mapping
Apr 22, 2026
Merged

fix: allow enum auto-mapping when source is a strict subset of target#28
wilmveel merged 1 commit intomainfrom
fix/enum-subset-mapping

Conversation

@wilmveel
Copy link
Copy Markdown
Contributor

Summary

  • Relax symmetric enum auto-mapping so a source enum whose entries are a strict subset of the target is accepted — every source value still has an unambiguous name match, and target-only entries are simply unreachable.
  • Swap set equality for toEntries.containsAll(fromEntries) in both KMapperFirMappingChecker (direct enum-to-enum early return) and KmapperFirLogic.enumsEqual (nested enum field check).
  • No IR changes: the existing Enum.valueOf(source.name) emission already handles subset mapping correctly at runtime.

Test plan

  • New integration test EnumMappingTest.shouldCompile_sourceSubsetOfTarget covers the issue's reproducer (Generation { GEN_Z, BOOMER }GenerationDto { GEN_Z, MILLENNIALS, BOOMER }) and asserts the expected runtime output.
  • Renamed shouldFail_notEqualEnumsshouldFail_sourceSupersetOfTarget and flipped the enums so the failing direction (source has entries the target lacks) still produces Missing mapping for: gender.
  • ./gradlew :test-integration:test passes end-to-end — no regressions in other enum / nested / label-property / collection scenarios.

Closes #27

🤖 Generated with Claude Code

Replace set equality with toEntries.containsAll(fromEntries) in the FIR
checker and enumsEqual. The IR side already emits Enum.valueOf(source.name),
which resolves correctly whenever every source entry name exists in the
target. Target-only entries remain unreachable by construction.

Closes #27

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wilmveel wilmveel merged commit ff80bb3 into main Apr 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enum auto-mapping fails when source is a strict subset of target

1 participant