Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Fix #1818 by substituting a temporary variable and assigning the fiel…
Browse files Browse the repository at this point in the history
…d to it after successful completion of the loop, as we do for non-shared attributes.
  • Loading branch information
tombentley committed Sep 24, 2014
1 parent 79aa2c6 commit c539ec1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,15 @@ public void transform(AttributeDeclaration decl, ClassDefinitionBuilder classBui
classBuilder.field(modifiers, attrName, type, initialValue, !useField, makeAtIgnore());
}
}

// A shared attribute might be initialized in a for statement, so
// we might need a def-assignment subst for it
List<JCAnnotation> annots = makeJavaTypeAnnotations(decl.getDeclarationModel());
JCStatement outerSubs = statementGen().openOuterSubstitutionIfNeeded(
decl.getDeclarationModel(), model.getType(), annots, 0);
if (outerSubs != null) {
classBuilder.init(outerSubs);
}
}

boolean withinInterface = Decl.withinInterface(decl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@ public List<JCStatement> transform(Tree.AttributeDeclaration decl) {
return result.toList();
}

private JCStatement openOuterSubstitutionIfNeeded(
JCStatement openOuterSubstitutionIfNeeded(
Value value, ProducedType t,
List<JCAnnotation> annots, int modifiers) {
JCStatement result = null;
Expand Down

0 comments on commit c539ec1

Please sign in to comment.