|
16 | 16 |
|
17 | 17 | import com.google.errorprone.annotations.CheckReturnValue; |
18 | 18 | import dev.cel.common.annotations.Internal; |
19 | | -import java.util.LinkedHashSet; |
20 | | -import java.util.Set; |
21 | 19 | import org.jspecify.annotations.Nullable; |
22 | 20 |
|
23 | 21 | /** |
@@ -74,42 +72,11 @@ static AccumulatedUnknowns adaptToAccumulatedUnknowns(CelUnknownSet unknowns) { |
74 | 72 | return AccumulatedUnknowns.create(unknowns.unknownExprIds(), unknowns.attributes()); |
75 | 73 | } |
76 | 74 |
|
77 | | - static AccumulatedUnknowns combineUnknownExprValue(Object... objs) { |
78 | | - Set<Long> ids = new LinkedHashSet<>(); |
79 | | - for (Object object : objs) { |
80 | | - if (isAccumulatedUnknowns(object)) { |
81 | | - ids.addAll(((AccumulatedUnknowns) object).exprIds()); |
82 | | - } |
83 | | - } |
84 | | - |
85 | | - return AccumulatedUnknowns.create(ids); |
86 | | - } |
87 | | - |
88 | 75 | /** |
89 | | - * Short circuit unknown or error arguments to logical operators. |
90 | | - * |
91 | | - * <p>Given two arguments, one of which must be throwable (error) or unknown, returns the result |
92 | | - * from the && or || operators for these arguments, assuming that the result cannot be determined |
93 | | - * from any boolean arguments alone. This allows us to consolidate the error/unknown handling for |
94 | | - * both of these operators. |
| 76 | + * Enforces strictness on both lhs/rhs arguments from logical operators (i.e: intentionally throws |
| 77 | + * an appropriate exception when {@link Throwable} is encountered as part of evaluated result. |
95 | 78 | */ |
96 | | - public static Object shortcircuitUnknownOrThrowable(Object left, Object right) |
97 | | - throws CelEvaluationException { |
98 | | - // unknown <op> unknown ==> unknown combined |
99 | | - if (InterpreterUtil.isAccumulatedUnknowns(left) |
100 | | - && InterpreterUtil.isAccumulatedUnknowns(right)) { |
101 | | - return InterpreterUtil.combineUnknownExprValue(left, right); |
102 | | - } |
103 | | - // unknown <op> <error> ==> unknown |
104 | | - // unknown <op> t|f ==> unknown |
105 | | - if (InterpreterUtil.isAccumulatedUnknowns(left)) { |
106 | | - return left; |
107 | | - } |
108 | | - // <error> <op> unknown ==> unknown |
109 | | - // t|f <op> unknown ==> unknown |
110 | | - if (InterpreterUtil.isAccumulatedUnknowns(right)) { |
111 | | - return right; |
112 | | - } |
| 79 | + public static Object enforceStrictness(Object left, Object right) throws CelEvaluationException { |
113 | 80 | // Throw left or right side exception for now, should combine them into ErrorSet. |
114 | 81 | // <error> <op> <error> ==> <error> |
115 | 82 | if (left instanceof Throwable) { |
|
0 commit comments