Skip to content

Commit b1e128b

Browse files
committed
Pretty-print a ClassInstanceExpr without a bound constructor nicely
1 parent 9670f20 commit b1e128b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

java/ql/lib/semmle/code/java/Expr.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,11 @@ class ClassInstanceExpr extends Expr, ConstructorCall, @classinstancexpr {
12441244
override Stmt getEnclosingStmt() { result = Expr.super.getEnclosingStmt() }
12451245

12461246
/** Gets a printable representation of this expression. */
1247-
override string toString() { result = "new " + this.getConstructor().getName() + "(...)" }
1247+
override string toString() {
1248+
result = "new " + this.getConstructor().getName() + "(...)"
1249+
or
1250+
not exists(this.getConstructor()) and result = "<ClassInstanceExpr that calls a missing constructor>"
1251+
}
12481252

12491253
override string getAPrimaryQlClass() { result = "ClassInstanceExpr" }
12501254
}

0 commit comments

Comments
 (0)