Repository navigation
refactor: centralize erasure-aware Java signature calculation - #486
Conversation
Extracts method/constructor signature calculation into JavaSignatures in codegen-core: type variables are erased to their first upper bound (Java type erasure), array dimensions are preserved, and owner type variables are resolved through caller-provided context. Adopted in MethodDto/BuilderMethodDto getSignatureKey, Roaster conflict resolution and BuilderDefinitionCreator method grouping, replacing the duplicated raw-qualified-name concatenations that treated type variables as their own names instead of their erasures. Preparation for generation-target validation (java-helpers#465), which needs correct signatures to detect duplicate methods and constructors.
| List<MethodDto> resolvedMethods = | ||
| resolveMethodConflicts( | ||
| classDef.getMethods(), JavaSignatures.typeVariableUpperBounds(classDef.getGenerics())); |
There was a problem hiding this comment.
| List<MethodDto> resolvedMethods = | |
| resolveMethodConflicts( | |
| classDef.getMethods(), JavaSignatures.typeVariableUpperBounds(classDef.getGenerics())); | |
| classGenerics = JavaSignatures.typeVariableUpperBounds(classDef); | |
| List<MethodDto> resolvedMethods = | |
| resolveMethodConflicts( | |
| classDef.getMethods(), classGenerics); |
There was a problem hiding this comment.
Applied — added a typeVariableUpperBounds(GenerationTargetClassDto) overload to JavaSignatures and used it here.
| return JavaSignatures.methodSignature( | ||
| method.getMethodName(), | ||
| method.getParameters(), | ||
| method.getGenericParameters(), | ||
| typeVariableUpperBounds); |
There was a problem hiding this comment.
This should be then provided by ruhe builder specific signature helper
There was a problem hiding this comment.
Done — the private helper is gone; BuilderDefinitionCreator now uses BuilderSignatures.methodSignature(method, typeVariableUpperBounds) from the new builder-specific signature helper.
- BuilderSignatures in the processor project provides erasure-aware signatures for BuilderMethodDto, used by getSignatureKey and BuilderDefinitionCreator instead of a local helper - JavaSignatures.typeVariableUpperBounds overload taking the generation target directly
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |



Summary
Extracts method/constructor signature calculation into a shared
JavaSignaturesutility in codegen-core:Twas keyed as"T"instead of its erasure, so e.g.void m(T)andvoid m(String)with<T extends String>did not collide the way javac sees themtypeVariableUpperBounds)Adopted in:
MethodDto.getSignatureKey()/BuilderMethodDto.getSignatureKey()— now delegate instead of duplicating the concatenation logicRoasterCodeGenerator.resolveMethodConflicts— owner-generics-aware duplicate detectionBuilderDefinitionCreator.collectMethodsBySignature— same for builder methodsPreparation for #465: the generation-target validation in #479 needs correct erasure-aware signatures to detect duplicate methods/constructors; this PR is the signature-calculation part split out of #479 so it can be reviewed and merged independently. #479 will be rebased once this lands.