+
+ /**
+ * Throw an instance of this exception if an expression evaluates to true. If the expression evaluates to false,
+ * this method does nothing.
+ *
+ * @param expression Expression to be evaluated
+ * @param stmt Statement context
+ * @param format Format string, according to {@link String#format(String, Object...)}.
+ * @param args Format string arguments, according to {@link String#format(String, Object...)}
+ * @throws InferenceException if the expression evaluates to true.
+ */
+ public static void throwIf(final boolean expression, final @NonNull CommonStmtCtx stmt,
+ final @NonNull String format, final Object... args) {
+ if (expression) {
+ throw new InferenceException(stmt.sourceReference(), format, args);
+ }
+ }