From a0a9c637a9bc604b17154f3f62c468c3b7bb804e Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Sun, 22 Oct 2023 08:19:24 -0700 Subject: [PATCH] Loosen a type test for constants corresponding to their expressions. PiperOrigin-RevId: 575618753 --- .../google/template/soy/jbcsrc/restricted/Expression.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/java/src/com/google/template/soy/jbcsrc/restricted/Expression.java b/java/src/com/google/template/soy/jbcsrc/restricted/Expression.java index 033a8be74c..5b13d50855 100644 --- a/java/src/com/google/template/soy/jbcsrc/restricted/Expression.java +++ b/java/src/com/google/template/soy/jbcsrc/restricted/Expression.java @@ -418,8 +418,8 @@ protected Expression( this.constantValue = checkNotNull(constantValue); if (Flags.DEBUG && constantValue.isPresent()) { checkState( - resultType.equals(constantValue.get().type), - "Type mismatch. Expected constant value of type %s to have type %s", + BytecodeUtils.isPossiblyAssignableFrom(resultType, constantValue.get().type), + "Type mismatch. Expected constant value of type %s to to be assignable to %s", constantValue.get().type, resultType); } @@ -583,7 +583,10 @@ public Expression asSoyNullish() { if (!isNonSoyNullish()) { return this; } + checkAssignableTo(BytecodeUtils.SOY_VALUE_TYPE); return new DelegatingExpression( + // The only type that is a super type of a NullData,UndefinedData and any other SoyValue is + // SoyValue itself. this, BytecodeUtils.SOY_VALUE_TYPE, features.minus(Feature.NON_SOY_NULLISH)); }