diff options
author | cushon <cushon@google.com> | 2018-10-02 17:15:06 -0700 |
---|---|---|
committer | Liam Miller-Cushon <cushon@google.com> | 2018-10-17 20:45:22 -0700 |
commit | 0af44c70c53671cc65568c402dc31272a56f97aa (patch) | |
tree | 463433b3976934025f9c66e4069747852926d3c1 /java | |
parent | 51b0ce5712ece6b67a5b2d841bd51e7f5ee96d56 (diff) | |
download | turbine-0af44c70c53671cc65568c402dc31272a56f97aa.tar.gz |
Don't crash on explicit boxing casts
e.g.: `static final boolean Z = (Boolean) true;` is well-formed, but not
a constant expression.
MOE_MIGRATED_REVID=215487485
Diffstat (limited to 'java')
-rw-r--r-- | java/com/google/turbine/binder/ConstEvaluator.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/java/com/google/turbine/binder/ConstEvaluator.java b/java/com/google/turbine/binder/ConstEvaluator.java index 8c8257e..450c686 100644 --- a/java/com/google/turbine/binder/ConstEvaluator.java +++ b/java/com/google/turbine/binder/ConstEvaluator.java @@ -444,7 +444,8 @@ public strictfp class ConstEvaluator { ClassTy classTy = (ClassTy) t.ty(); // TODO(cushon): check package? if (!classTy.name().equals("String")) { - throw new AssertionError(classTy); + // Explicit boxing cases (e.g. `(Boolean) false`) are legal, but not const exprs. + return null; } return expr.asString(); } |