aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers
diff options
context:
space:
mode:
authorJan Rieke <rieke@subshell.com>2022-06-17 11:13:22 +0200
committerJan Rieke <rieke@subshell.com>2022-06-17 12:35:28 +0200
commitab36d2f8797ca34f3eefeb2008233985a856f0e4 (patch)
treebed95c73583a7c5d7000500f5d11daa76732b437 /src/core/lombok/javac/handlers
parent1473389f397579a224d57b496f6387f3b8cbb6a9 (diff)
downloadlombok-ab36d2f8797ca34f3eefeb2008233985a856f0e4.tar.gz
lombok-ab36d2f8797ca34f3eefeb2008233985a856f0e4.tar.bz2
lombok-ab36d2f8797ca34f3eefeb2008233985a856f0e4.zip
(fixes #3202) check extends/implements for collisions (SuperBuilder)
Diffstat (limited to 'src/core/lombok/javac/handlers')
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 7418ac87..967141cd 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -1051,9 +1051,25 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}
}
+ // 4. Add extends and implements clauses.
+ addFirstToken(usedNames, Javac.getExtendsClause(td));
+ for (JCExpression impl : td.getImplementsClause()) {
+ addFirstToken(usedNames, impl);
+ }
+
return usedNames;
}
+ private void addFirstToken(java.util.Set<String> usedNames, JCTree type) {
+ if (type == null)
+ return;
+ while (type instanceof JCFieldAccess && ((JCFieldAccess)type).selected != null) {
+ // Add the first token, because only that can collide.
+ type = ((JCFieldAccess)type).selected;
+ }
+ usedNames.add(type.toString());
+ }
+
private String generateNonclashingNameFor(String classGenericName, java.util.HashSet<String> typeParamStrings) {
if (!typeParamStrings.contains(classGenericName)) return classGenericName;
int counter = 2;