Javascript: avoid null pointer exception on boolean values

This commit is contained in:
Paolo Tranquilli
2025-11-11 12:11:49 +01:00
parent 6ef314ed03
commit ff62c65cdf
17 changed files with 22 additions and 22 deletions

View File

@@ -3115,7 +3115,7 @@ public class Parser {
}
first = false;
}
if (oldStrict.equals(Boolean.FALSE)) this.setStrict(false);
if (Boolean.FALSE.equals(oldStrict)) this.setStrict(false);
return this.finishNode(new BlockStatement(new SourceLocation(startLoc), body));
}

View File

@@ -35,8 +35,8 @@ public abstract class AFunctionExpression extends Expression implements IFunctio
id,
params,
body,
generator.equals(Boolean.TRUE),
async.equals(Boolean.TRUE),
Boolean.TRUE.equals(generator),
Boolean.TRUE.equals(async),
typeParameters,
parameterTypes,
parameterDecorators,

View File

@@ -10,7 +10,7 @@ public class ComprehensionBlock extends Expression {
super("ComprehensionBlock", loc);
this.left = left;
this.right = right;
this.of = !of.equals(Boolean.FALSE);
this.of = !Boolean.FALSE.equals(of);
}
@Override

View File

@@ -19,7 +19,7 @@ public class ComprehensionExpression extends Expression {
this.body = body;
this.blocks = blocks;
this.filter = filter;
this.generator = generator.equals(Boolean.TRUE);
this.generator = Boolean.TRUE.equals(generator);
}
@Override

View File

@@ -16,7 +16,7 @@ public class ForInStatement extends EnhancedForStatement {
public ForInStatement(
SourceLocation loc, Node left, Expression right, Statement body, Boolean each) {
super("ForInStatement", loc, left, right, body);
this.each = each.equals(Boolean.TRUE);
this.each = Boolean.TRUE.equals(each);
}
public boolean isEach() {

View File

@@ -27,8 +27,8 @@ public abstract class InvokeExpression extends Expression implements INodeWithSy
this.callee = callee;
this.typeArguments = typeArguments;
this.arguments = arguments;
this.optional = optional.equals(Boolean.TRUE);
this.onOptionalChain = onOptionalChain.equals(Boolean.TRUE);
this.optional = Boolean.TRUE.equals(optional);
this.onOptionalChain = Boolean.TRUE.equals(onOptionalChain);
}
/** The callee expression of this invocation. */

View File

@@ -76,7 +76,7 @@ public class Literal extends Expression implements ITypeExpression {
if (isRegExp()) return false;
return value == null
|| value instanceof Number && ((Number) value).intValue() == 0
|| value.equals(Boolean.FALSE)
|| Boolean.FALSE.equals(value)
|| value instanceof String && ((String) value).isEmpty();
}

View File

@@ -22,9 +22,9 @@ public class MemberExpression extends Expression
super("MemberExpression", loc);
this.object = object;
this.property = property;
this.computed = computed.equals(Boolean.TRUE);
this.optional = optional.equals(Boolean.TRUE);
this.onOptionalChain = onOptionalChain.equals(Boolean.TRUE);
this.computed = Boolean.TRUE.equals(computed);
this.optional = Boolean.TRUE.equals(optional);
this.onOptionalChain = Boolean.TRUE.equals(onOptionalChain);
}
@Override

View File

@@ -59,8 +59,8 @@ public class Property extends Node {
}
this.rawValue = rawValue;
this.kind = Kind.valueOf(StringUtil.uc(kind));
this.computed = computed.equals(Boolean.TRUE);
this.method = method.equals(Boolean.TRUE);
this.computed = Boolean.TRUE.equals(computed);
this.method = Boolean.TRUE.equals(method);
this.decorators = new ArrayList<Decorator>();
}

View File

@@ -10,7 +10,7 @@ public class TemplateElement extends Expression {
super("TemplateElement", loc);
this.cooked = cooked;
this.raw = raw;
this.tail = tail.equals(Boolean.TRUE);
this.tail = Boolean.TRUE.equals(tail);
}
@Override

View File

@@ -14,7 +14,7 @@ public class UnaryExpression extends Expression {
super("UnaryExpression", loc);
this.operator = operator;
this.argument = argument;
this.prefix = prefix.equals(Boolean.TRUE);
this.prefix = Boolean.TRUE.equals(prefix);
}
@Override

View File

@@ -11,7 +11,7 @@ public class UpdateExpression extends Expression {
super("UpdateExpression", loc);
this.operator = operator;
this.argument = argument;
this.prefix = prefix.equals(Boolean.TRUE);
this.prefix = Boolean.TRUE.equals(prefix);
}
@Override

View File

@@ -8,7 +8,7 @@ public class YieldExpression extends Expression {
public YieldExpression(SourceLocation loc, Expression argument, Boolean delegating) {
super("YieldExpression", loc);
this.argument = argument;
this.delegating = delegating.equals(Boolean.TRUE);
this.delegating = Boolean.TRUE.equals(delegating);
}
@Override

View File

@@ -18,7 +18,7 @@ public class FunctionType extends JSDocTypeExpression {
JSDocTypeExpression result) {
super(loc, "FunctionType");
this._this = _this;
this._new = _new.equals(Boolean.TRUE);
this._new = _Boolean.TRUE.equals(new);
this.params = params;
this.result = result;
}

View File

@@ -19,7 +19,7 @@ public abstract class UnaryTypeConstructor extends JSDocTypeExpression {
String operator) {
super(loc, type);
this.expression = expression;
this.prefix = prefix.equals(Boolean.TRUE);
this.prefix = Boolean.TRUE.equals(prefix);
this.operator = operator;
}

View File

@@ -11,7 +11,7 @@ public class CharacterClass extends RegExpTerm {
public CharacterClass(SourceLocation loc, List<RegExpTerm> elements, Boolean inverted) {
super(loc, "CharacterClass");
this.elements = elements;
this.inverted = inverted.equals(Boolean.TRUE);
this.inverted = Boolean.TRUE.equals(inverted);
}
@Override

View File

@@ -10,7 +10,7 @@ public abstract class Quantifier extends RegExpTerm {
public Quantifier(SourceLocation loc, String type, RegExpTerm operand, Boolean greedy) {
super(loc, type);
this.operand = operand;
this.greedy = greedy.equals(Boolean.TRUE);
this.greedy = Boolean.TRUE.equals(greedy);
}
/** The quantified term. */