proposal to update generated function names#265
Open
davissuber wants to merge 4 commits intouber:mainfrom
Open
proposal to update generated function names#265davissuber wants to merge 4 commits intouber:mainfrom
davissuber wants to merge 4 commits intouber:mainfrom
Conversation
This is quite a useful annotation for kotlin/java interop - and people do use it with motif - so we'd like to add tests with this annotation
We no longer need to map the primitive names for tests - possibly due to a room compiler processing version bump. However, we do notice that there's still a space difference when generating the java/kotlin string representation of generic classes
This commit updates the name generation to always add a trailing underscore for the following reasons: 1. There are some missing keywords - for example, a custom type named `Null` will crash motif since it will try to name the function `null()`, it seems that adding to the list is not as safe as always append 2. Motif append a `2` (or `3` and so on) to a function name to avoid collision, so a type whose name ends with a `2` e.g. `Function2` will have its name `Function22` (or `Function23` and so on) - it's not wrong, but reads a bit funny
This commit adds a test that would fail without the changes in this pull request, such as JvmSuppressWildcard, `Null` class name, and kotlin/java generic name difference
davissuber
commented
Mar 28, 2024
| @RunWith(Parameterized::class) | ||
| @OptIn(ExperimentalProcessingApi::class) | ||
| class XNamesTest(private val processorType: ProcessorType, private val srcLang: SourceLanguage) { | ||
| class NamesTest(private val processorType: ProcessorType, private val srcLang: SourceLanguage) { |
Contributor
Author
There was a problem hiding this comment.
Matching the file name
davissuber
commented
Mar 28, 2024
|
|
||
| fun child(): ChildScope | ||
|
|
||
| fun myByte(): Byte |
Contributor
Author
There was a problem hiding this comment.
This is to verify the name renderer change is not breaking stuff
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.
Note for reviewers: I have NOT tested this against Uber's apps at the time of this writing - this pull request is more of a "is this even a problem worth changing" type of deal - if this seems agreeable, I'll test out the code generation in buck/bazel.
The main behavioral change in this pull request is in the function name generation in
Names.kt, one can run into the following problems:Null, it would break the keyword check since it's not in the keywordnullto the keyword list as alternative2such asFunction2will pass through the uniqueness check and be converted asfunction22function2_2