Fix for Bug 370666 - [format] cannot format base call due to synthetic
boolean arg
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java
index aba1c3b..3f59227 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java
@@ -66,6 +66,9 @@
return source;
}
public void traverse(ASTVisitor visitor, BlockScope scope) {
+//{ObjectTeams: hide synthetic nodes from visitors (e.g., inserted into a base call)
+ if ((this.bits & ASTNode.IsGenerated) != 0) return;
+// SH}
visitor.visit(this, scope);
visitor.endVisit(this, scope);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java
index d685f81..9928685 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java
@@ -67,6 +67,9 @@
return source;
}
public void traverse(ASTVisitor visitor, BlockScope scope) {
+//{ObjectTeams: hide synthetic nodes from visitors (e.g., inserted into a base call)
+ if ((this.bits & ASTNode.IsGenerated) != 0) return;
+// SH}
visitor.visit(this, scope);
visitor.endVisit(this, scope);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/BaseCallMessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/BaseCallMessageSend.java
index ca914ab..6fe28ae 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/BaseCallMessageSend.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/BaseCallMessageSend.java
@@ -25,10 +25,8 @@
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.FalseLiteral;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TrueLiteral;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
@@ -116,8 +114,9 @@
System.arraycopy(args, 0, args=new Expression[len+extra], extra, len);
}
// insert before regular args:
- if (!CallinImplementorDyn.DYNAMIC_WEAVING) // FIXME(OTDYN): base.super calls not supported by dynamic weaver.
- args[0] = this.isSuperAccess ? new TrueLiteral(this.sourceStart, this.sourceEnd) : new FalseLiteral(this.sourceStart, this.sourceEnd);
+ if (!CallinImplementorDyn.DYNAMIC_WEAVING) { // FIXME(OTDYN): base.super calls not supported by dynamic weaver.
+ args[0] = new AstGenerator(this).booleanLiteral(this.isSuperAccess);
+ }
this._sendOrig.arguments = args;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java
index 7c44a0c..0419c6a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java
@@ -277,10 +277,11 @@
return result;
}
public Literal booleanLiteral(boolean val) {
- if (val)
- return new TrueLiteral(this.sourceStart, this.sourceEnd);
- else
- return new FalseLiteral(this.sourceStart, this.sourceEnd);
+ Literal result = val
+ ? new TrueLiteral(this.sourceStart, this.sourceEnd)
+ : new FalseLiteral(this.sourceStart, this.sourceEnd);
+ result.bits |= ASTNode.IsGenerated;
+ return result;
}
public StringLiteral stringLiteral(char[] cs) {
return new StringLiteral(cs, this.sourceStart, this.sourceEnd, /*lineNumber*/0);