aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2023-01-12 01:40:23 +0100
committerGitHub <noreply@github.com>2023-01-12 01:40:23 +0100
commitef916881ad85371b905b0104072df2a2b133eee8 (patch)
treeb9ab8f366f655c9904747eda8eb815003d2e6956 /src/core/lombok/javac
parentf090e50d0d5d75c121b6170927b1e776160eb37d (diff)
parent0fcb446265348753c2b448f98f2ad020d6d07d13 (diff)
downloadlombok-ef916881ad85371b905b0104072df2a2b133eee8.tar.gz
lombok-ef916881ad85371b905b0104072df2a2b133eee8.tar.bz2
lombok-ef916881ad85371b905b0104072df2a2b133eee8.zip
Merge pull request #3215 from janrieke/superBuilderExtendsClauseCollisions
SuperBuilder: check extends/implements for collisions (fixes #3202)
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 7418ac87..3b66f076 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -1051,9 +1051,28 @@ 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;
+ if (type instanceof JCTypeApply) {
+ type = ((JCTypeApply)type).clazz;
+ }
+ 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;