Enforce that the file name doesn’t collide with any of its messages
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
The Google protobuf generator for Java creates a class for each .proto, and a nested class for each message in that .proto. So if we define say, Dinosaur.proto like this:
...
message Dinosaur {
}
Then the Google generator generates Dinosaur.java that looks like this:
...
class Dinosaur {
class Dinosaur {
}
}
And then javac refuses to compile this, because a class cannot have the same name as its enclosing class.
Reasonable people have been making this mistake in projects that only use Wire. But then when they attempt to use protobuf their builds fail because of the Google protobuf limitation.
We should detect this problem in Wire and report an error.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example from Dinosaur.proto and inspect the generated Dinosaur.java, focusing on the Java generation path and how Wire reports invalid schema definitions. The work is done when a message sharing the .proto file name is detected before generation and reported as an error, preventing the javac failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100