Skip to content

Conversation

devgianlu
Copy link

This PR ensures that custom enums are encoded as the expected Long type in the Kotlin generator.

Without this change it is not possible to perform encoding <-> decoding in Kotlin, because enums are generated to have an Int raw value and encoded without first casting to Long.

Fixes: flutter/flutter#176081

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a ClassCastException in the Kotlin generator by ensuring custom enums are encoded as Long instead of Int. The core change correctly adds a .toLong() call during the serialization of enum raw values. The PR is well-structured, including updates to the version number in pubspec.yaml and generator_tools.dart, a clear entry in CHANGELOG.md, and a new test expectation to verify the fix and prevent regressions. The changes are correct and effectively resolve the reported issue.

@devgianlu devgianlu changed the title [pigeon] Fix encode logic for custom enum in Kotlin generator [pigeon] Encode custom enum as long in Kotlin generator Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pigeon] ClassCastException when round-tripping enums within Kotlin
2 participants