fix(compiler): fix Java, Kotlin and Scala codegen emission bugs - #4109
Open
ayush00git wants to merge 3 commits into
Open
ayush00git wants to merge 3 commits into
ayush00git wants to merge 3 commits into
Conversation
- java: union cases of duration/decimal types emitted Types.UNKNOWN instead of Types.DURATION/Types.DECIMAL, writing a wrong wire type id. - java: reserved-word field names were never escaped, so a field such as `string class = 1;` generated invalid Java; a field or union case named `class` also generated getClass(), clashing with the final Object.getClass(). - java: optional list elements and map values lost the @nullable type-use annotation, diverging from Kotlin/Scala/Go output for the same schema. - java/kotlin/scala: a schema type named after a module-file runtime import (e.g. `message Fory`) compiled but silently registered the wrong class; registrations of shadowed names are now package-qualified, and a shadowed name in the default package is rejected. - kotlin: `message Empty {}` generated `data class Empty()`, which does not compile; empty messages now use a plain class. Claude-Session: https://claude.ai/code/session_01YcPbRyTJYmU8t6mkGCbnUf
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes five code-emission bugs in the Java, Kotlin and Scala compiler generators:
Types.UNKNOWNinstead ofTypes.DURATION/Types.DECIMAL, producing a wrong wire type id.string class = 1;generatedprivate String class;, which does not compile; a field or union case namedclassalso generatedgetClass(), clashing with the finalObject.getClass().@Nullabletype-use annotation, so generated Java treated them as non-null while Kotlin, Scala and Go emit nullable for the same schema.message Fory) compiled but silently registered the wrong class; registrations of shadowed names are now package-qualified, and a shadowed name in the default package is rejected with a clear error.message Empty {}generateddata class Empty(), which does not compile; empty messages now use a plain class.Verification
Regression tests added for each bug; each fails without its corresponding generator fix. Full compiler suite passes:
python3 -m pytest fory_compiler/tests -q(500 passed, 1 skipped).