Fix generated code when a service has the name of an imported type - #355
Open
zZHorizonZz wants to merge 1 commit into
Open
Fix generated code when a service has the name of an imported type#355zZHorizonZz wants to merge 1 commit into
zZHorizonZz wants to merge 1 commit into
Conversation
Motivation: A .proto service named `Service` generates a contract interface `Service` alongside a `ServiceService` class that imports io.vertx.grpc.server.Service. The single type import shadows the same package contract, so the generated class implements the wrong `Service` and does not compile. The same happens for any service named after a type the templates import. Changes: The templates now declare their own type from prefixedServiceName and refer to the other generated types with the package qualified names held by the contractFqn/clientFqn/serviceFqn/outerFqn fields, which were not qualified before despite their name. grpcClientFqn/grpcServiceFqn/grpcIoFqn only ever spelled their own declaration and are gone. Qualifying is not enough for the contract template since it declares the bare service name: an import of the same simple name is a compile error there. It has no imports anymore and qualifies the two types it uses. Dead imports are removed from the other templates as well, io.vertx.grpc.server.Service in the service template being the one reported. Closes eclipse-vertx#351
zZHorizonZz
force-pushed
the
fix-generated-service-name-clash
branch
from
September 4, 2026 15:49
aa0d5be to
f1d3107
Compare
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.
Motivation:
The generator gives the contract interface the name of the service. A service with the name
Servicethus gets a contract interfaceService. The generatedServiceServiceclass importsio.vertx.grpc.server.Service. In Java, an import hides a type of the same name in the same package. Thus the class implements the wrongService, and the code does not compile. This occurs for each service that has the name of a type that the templates import.Futureis another example.Changes:
prefixedServiceName.contractFqn,clientFqn,serviceFqnandouterFqn. These fields did not contain full names before.grpcClientFqn,grpcServiceFqnandgrpcIoFqnare removed. Each of them spelled only its own declaration.io.vertx.grpc.server.Servicein the service template is the import of the report.Closes #351