mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 20:15:09 +00:00
Fixed @AllArgsConstructor screwing up with final fields that have been initialized.
This commit is contained in:
1 parent
c86d0fcc37
commit
ca24a4c3ec
2 files changed
+8
-4
No files matched your search
@@ -130,10 +130,12 @@ public class HandleConstructor {
|
||||
for (EclipseNode child : typeNode.down()) {
|
||||
if (child.getKind() != Kind.FIELD) continue;
|
||||
FieldDeclaration fieldDecl = (FieldDeclaration) child.get();
|
||||
//Skip fields that start with $
|
||||
// Skip fields that start with $
|
||||
if (fieldDecl.name.length > 0 && fieldDecl.name[0] == '$') continue;
|
||||
//Skip static fields.
|
||||
// Skip static fields.
|
||||
if ((fieldDecl.modifiers & ClassFileConstants.AccStatic) != 0) continue;
|
||||
// Skip initialized final fields.
|
||||
if (((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0) && fieldDecl.initialization != null) continue;
|
||||
fields.add(child);
|
||||
}
|
||||
new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, false, suppressConstructorProperties, ast);
|
||||
|
||||
@@ -130,11 +130,13 @@ public class HandleConstructor {
|
||||
for (JavacNode child : typeNode.down()) {
|
||||
if (child.getKind() != Kind.FIELD) continue;
|
||||
JCVariableDecl fieldDecl = (JCVariableDecl) child.get();
|
||||
//Skip fields that start with $
|
||||
// Skip fields that start with $
|
||||
if (fieldDecl.name.toString().startsWith("$")) continue;
|
||||
long fieldFlags = fieldDecl.mods.flags;
|
||||
//Skip static fields.
|
||||
// Skip static fields.
|
||||
if ((fieldFlags & Flags.STATIC) != 0) continue;
|
||||
// Skip initialized final fields.
|
||||
if (((fieldFlags & Flags.FINAL) != 0) && fieldDecl.init != null) continue;
|
||||
fields.append(child);
|
||||
}
|
||||
new HandleConstructor().generateConstructor(typeNode, level, fields.toList(), staticName, false, suppressConstructorProperties);
|
||||
|
||||
Reference in new issue
Block a user