Fixed #1807 Proper parenthesis around call inside another call

This commit is contained in:
Jindra Petřík
2022-11-20 22:12:19 +01:00
parent 78d83110b6
commit 06feae4113
11 changed files with 313 additions and 356 deletions
@@ -53,11 +53,18 @@ public class ConstructAVM2Item extends AVM2Item {
return object.toString(writer, localData);
}
writer.append("new ");
if (object.getPrecedence() > getPrecedence()) {
boolean objectIsCall = (object instanceof CallAVM2Item) ||
(object instanceof CallPropertyAVM2Item) ||
(object instanceof CallMethodAVM2Item) ||
(object instanceof CallStaticAVM2Item) ||
(object instanceof CallSuperAVM2Item);
if (object.getPrecedence() > getPrecedence() || objectIsCall) {
writer.append("(");
}
object.toString(writer, localData);
if (object.getPrecedence() > getPrecedence()) {
if (object.getPrecedence() > getPrecedence() || objectIsCall) {
writer.append(")");
}
writer.spaceBeforeCallParenthesies(args.size());