From ab36d2f8797ca34f3eefeb2008233985a856f0e4 Mon Sep 17 00:00:00 2001 From: Jan Rieke Date: Fri, 17 Jun 2022 11:13:22 +0200 Subject: (fixes #3202) check extends/implements for collisions (SuperBuilder) --- src/core/lombok/javac/handlers/HandleSuperBuilder.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/core/lombok/javac') 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 { } } + // 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 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 typeParamStrings) { if (!typeParamStrings.contains(classGenericName)) return classGenericName; int counter = 2; -- cgit