Fix code generation for nested types with same name as parent type#96
Merged
jacobperron merged 3 commits intomainfrom Sep 28, 2022
Merged
Fix code generation for nested types with same name as parent type#96jacobperron merged 3 commits intomainfrom
jacobperron merged 3 commits intomainfrom
Conversation
I.e. try to generate code for Nested.action that contains members of type Nested.msg. This commit will not compile as-is, demonstrating a bug in the Java code generator. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
If we have an action that has a nested message and both use the same basename, then the Java compiler cannot resolve the two different types. The solution is to fully qualify the action name wherever it is used. This change also splits the 'marker_interfaces' variable into two variables, 'imports' and 'implements', in an effort to simplify the code templates. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
wjwwood
approved these changes
Sep 28, 2022
Member
wjwwood
left a comment
There was a problem hiding this comment.
Seems reasonable to me, using the full type names to avoid ambiguity.
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.
The first commit demonstrates the issue and fails to compile on it's own 0509f1c
The second commit proposes a fix by using fully qualified names for action types 5163571
And the third commit adds a simple unit test for sanity ba85bd1
Note, this issue does not appear to affect services, it was only an issue in the action code generator.