dongjoon-hyun commented on code in PR #60119:
URL: https://github.com/apache/spark/pull/60119#discussion_r4495389673


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExprUtilsSuite.scala:
##########
@@ -39,17 +64,342 @@ class ExprUtilsSuite extends SparkFunSuite {
   test("canEvaluateUnconditionally: expressions that can throw are excluded") {
     // Arithmetic can throw (overflow, div-by-zero in ANSI mode) even though 
it does not
     // override `throwable` and inherits false from its non-throwing children, 
which is
-    // why the whitelist is used instead of the throwable flag.
-    val arithmetic = LessThan(Add(a, Literal(1L)), Literal(5L))
+    // why the allowlist is used instead of the throwable flag.
+    val arithmetic = LessThan(Add(a, Literal(1L), ansi), Literal(5L))
     assert(!arithmetic.throwable)
     assert(!ExprUtils.canEvaluateUnconditionally(arithmetic))
-    assert(!ExprUtils.canEvaluateUnconditionally(EqualTo(Remainder(a, 
Literal(3L)), Literal(0L))))
-    assert(!ExprUtils.canEvaluateUnconditionally(Cast(a, StringType)))
+    assert(!ExprUtils.canEvaluateUnconditionally(
+      EqualTo(Remainder(a, Literal(3L), ansi), Literal(0L))))
+    assert(!ExprUtils.canEvaluateUnconditionally(
+      Cast(AttributeReference("s", StringType)(), IntegerType, evalMode = 
EvalMode.ANSI)))
     // GetArrayItem/ElementAt can throw on invalid ordinals in ANSI mode.
     val arr = AttributeReference("arr", ArrayType(IntegerType))()
     assert(!ExprUtils.canEvaluateUnconditionally(GetArrayItem(arr, 
Literal(0))))
-    // A whitelisted predicate over a non-whitelisted child is still excluded.
-    assert(!ExprUtils.canEvaluateUnconditionally(IsNotNull(Add(a, 
Literal(1L)))))
+    // An allowlisted predicate over a child that is not allowlisted is still 
excluded.
+    assert(!ExprUtils.canEvaluateUnconditionally(IsNotNull(Add(a, Literal(1L), 
ansi))))
+  }
+
+  test("SPARK-60882: canEvaluateUnconditionally: size and numeric up-casts are 
included") {
+    val arr = AttributeReference("arr", ArrayType(IntegerType))()
+    val i = AttributeReference("i", IntegerType)()
+    assert(ExprUtils.canEvaluateUnconditionally(GreaterThan(Size(arr), 
Literal(0))))
+    assert(ExprUtils.canEvaluateUnconditionally(
+      EqualTo(Cast(i, LongType, evalMode = EvalMode.ANSI), a)))
+    assert(ExprUtils.canEvaluateUnconditionally(Cast(i, DoubleType, evalMode = 
EvalMode.ANSI)))
+    assert(ExprUtils.canEvaluateUnconditionally(
+      Cast(i, DecimalType(20, 0), evalMode = EvalMode.ANSI)))
+    // A decimal to an integral type is an up-cast too, but can overflow in 
ANSI mode.
+    assert(Cast.canUpCast(DecimalType(19, 0), LongType))

Review Comment:
   **1. [High] This assertion fails on the current master**
   
   [SPARK-60943](https://issues.apache.org/jira/browse/SPARK-60943) (#60145), 
merged after the base of this PR, made `DecimalType.isTighterThan(LongType)` 
accept at most 18 integral digits, so `Cast.canUpCast(DecimalType(19, 0), 
LongType)` is now `false`. The CI of this head, which merges the latest master, 
reports this test as failing:
   
   ```
   ExprUtilsSuite.SPARK-60882: canEvaluateUnconditionally: size and numeric 
up-casts are included
   Cast.canUpCast(DecimalType.apply(19, 0), LongType) was false
   ```
   
   After a rebase, this line could become 
`assert(!Cast.canUpCast(DecimalType(19, 0), LongType))`, which still documents 
why the cast is rejected. Item 3 covers the code side.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ExprUtils.scala:
##########
@@ -266,13 +294,71 @@ object ExprUtils extends EvalHelper with QueryErrorsBase {
     e.deterministic && !e.containsPattern(PLAN_EXPRESSION) &&
       canEvaluateUnconditionallyInternal(e)
 
+  // Only the numeric pairs are taken from `Cast.canUpCast`, which also covers 
e.g. DATE to
+  // TIMESTAMP, which can overflow, and casts between complex types. Among the 
numeric ones, a
+  // decimal to an integral type can overflow in ANSI mode, e.g. DECIMAL(19, 
0) to BIGINT, as
+  // `Cast.nullable` notes.
+  private def isNumericUpCast(from: DataType, to: DataType): Boolean = (from, 
to) match {
+    case (_: DecimalType, _: IntegralType) => false
+    case (_: NumericType, _: NumericType) => Cast.canUpCast(from, to)
+    case _ => false
+  }
+
+  // Whether a cast can not fail. A cast of a date to a timestamp is left out 
also in LEGACY mode,
+  // as converting a date far from the epoch to microseconds overflows there.
+  private def cannotFailCast(c: Cast): Boolean = (c.child.dataType, 
c.dataType) match {
+    case (from, to) if isNumericUpCast(from, to) => true
+    case (TimestampType | TimestampNTZType, DateType) => true
+    // A CHAR or VARCHAR target checks the length of the string.
+    case (_: NumericType | BooleanType, s: StringType) if 
StringHelper.isPlainString(s) => true
+    case _ if c.evalMode == EvalMode.TRY => true
+    // `Cast.isNoThrowLegacyCast` covers the numbers, booleans and strings. A 
string to a date or
+    // a timestamp does not raise in LEGACY mode either: the parsers catch the 
errors and return
+    // None, which becomes NULL.
+    case (_: StringType, DateType | TimestampType | TimestampNTZType)
+        if c.evalMode == EvalMode.LEGACY => true
+    case (from, to) if c.evalMode == EvalMode.LEGACY => 
Cast.isNoThrowLegacyCast(from, to)
+    case _ => false
+  }
+
+  // Whether numeric arithmetic can not fail, in its own eval mode.
+  private def cannotFailArithmetic(b: BinaryArithmetic): Boolean = {
+    val decimal = b.left.dataType.isInstanceOf[DecimalType]
+    b.children.forall(_.dataType.isInstanceOf[NumericType]) && (b.evalMode 
match {
+      case EvalMode.LEGACY => b match {
+        case _: Add | _: Subtract | _: Multiply | _: Divide => true

Review Comment:
   **2. [Medium] The SPARK-60980 test in `FilterPushdownSuite` will fail with 
ANSI mode off**
   
   [SPARK-60980](https://issues.apache.org/jira/browse/SPARK-60980) (#60157), 
merged after the base of this PR, added a caller: `CombineFilters` ([master 
L2430](https://github.com/apache/spark/blob/b2fc1bef1b418eb68dcf58a00017b91fa3359456/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala#L2430))
 moves a conjunct written after a non-deterministic or throwable one into the 
lower filter only when `canEvaluateUnconditionally` accepts it. Its test 
([master 
L138-L155](https://github.com/apache/spark/blob/b2fc1bef1b418eb68dcf58a00017b91fa3359456/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala#L138-L155))
 builds the division with the session's eval mode:
   
   ```scala
   .where($"a" / $"b" > 1 && blocker && $"b" / $"a" > 1 && $"a" === 1)
   ```
   
   and expects `blocker && b / a > 1` to stay above. In the scheduled non-ANSI 
build (`build_non_ansi.yml`, `SPARK_ANSI_SQL_MODE=false`), `b / a` is a LEGACY 
`Divide` over two widening casts, which this line now accepts. So 
`CombineFilters` combines it, and `comparePlans` fails. The CI of this PR runs 
with ANSI mode on, so it does not show this. I did not run it; this comes from 
reading the code.
   
   After a rebase, pinning that division to ANSI mode, as this PR does in 
`RewriteDistinctAggregatesSuite` and `SplitStreamedSideJoinConditionSuite`, 
would keep the test meaningful in both builds.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ExprUtils.scala:
##########
@@ -266,13 +294,71 @@ object ExprUtils extends EvalHelper with QueryErrorsBase {
     e.deterministic && !e.containsPattern(PLAN_EXPRESSION) &&
       canEvaluateUnconditionallyInternal(e)
 
+  // Only the numeric pairs are taken from `Cast.canUpCast`, which also covers 
e.g. DATE to
+  // TIMESTAMP, which can overflow, and casts between complex types. Among the 
numeric ones, a
+  // decimal to an integral type can overflow in ANSI mode, e.g. DECIMAL(19, 
0) to BIGINT, as
+  // `Cast.nullable` notes.
+  private def isNumericUpCast(from: DataType, to: DataType): Boolean = (from, 
to) match {
+    case (_: DecimalType, _: IntegralType) => false
+    case (_: NumericType, _: NumericType) => Cast.canUpCast(from, to)
+    case _ => false
+  }
+
+  // Whether a cast can not fail. A cast of a date to a timestamp is left out 
also in LEGACY mode,
+  // as converting a date far from the epoch to microseconds overflows there.
+  private def cannotFailCast(c: Cast): Boolean = (c.child.dataType, 
c.dataType) match {
+    case (from, to) if isNumericUpCast(from, to) => true
+    case (TimestampType | TimestampNTZType, DateType) => true
+    // A CHAR or VARCHAR target checks the length of the string.
+    case (_: NumericType | BooleanType, s: StringType) if 
StringHelper.isPlainString(s) => true
+    case _ if c.evalMode == EvalMode.TRY => true
+    // `Cast.isNoThrowLegacyCast` covers the numbers, booleans and strings. A 
string to a date or
+    // a timestamp does not raise in LEGACY mode either: the parsers catch the 
errors and return
+    // None, which becomes NULL.
+    case (_: StringType, DateType | TimestampType | TimestampNTZType)
+        if c.evalMode == EvalMode.LEGACY => true
+    case (from, to) if c.evalMode == EvalMode.LEGACY => 
Cast.isNoThrowLegacyCast(from, to)
+    case _ => false
+  }
+
+  // Whether numeric arithmetic can not fail, in its own eval mode.
+  private def cannotFailArithmetic(b: BinaryArithmetic): Boolean = {
+    val decimal = b.left.dataType.isInstanceOf[DecimalType]
+    b.children.forall(_.dataType.isInstanceOf[NumericType]) && (b.evalMode 
match {
+      case EvalMode.LEGACY => b match {
+        case _: Add | _: Subtract | _: Multiply | _: Divide => true
+        // `Decimal.quot` and `Decimal.%` raise when the integral quotient is 
too long.
+        case _: IntegralDivide | _: Remainder | _: Pmod => !decimal
+        case _ => false
+      }
+      // `DivModLike` and Pmod override `eval` without the catch of TRY mode, 
and IntegralDivide
+      // and Pmod check a zero divisor there as in ANSI mode.
+      case EvalMode.TRY => b match {
+        case _: Add | _: Subtract | _: Multiply | _: Divide => true
+        case _: Remainder => !decimal
+        case _ => false
+      }
+      case _ => false
+    })
+  }
+
   private def canEvaluateUnconditionallyInternal(e: Expression): Boolean = e 
match {
     case _: AttributeReference | _: Literal => true
-    case _: GetStructField | _: GetArrayStructFields | _: GetMapValue =>
+    case _: GetStructField | _: GetArrayStructFields | _: GetMapValue | _: 
CreateNamedStruct =>

Review Comment:
   **5. [Low] The existing `NoThrow` marker could be used instead of 
`CreateNamedStruct`**
   
   `complexTypeCreator.scala` already has a `NoThrow` marker for expressions 
that do not throw, and `CreateArray` and `CreateNamedStruct` carry it. 
`ConstantFolding.hasNoSideEffect` uses it for the same purpose as this check. 
Listing only `CreateNamedStruct` here leaves out `CreateArray`, so `array(a, b) 
= array(1, 2)` is still rejected.
   
   ```scala
   case _: NoThrow => e.children.forall(canEvaluateUnconditionallyInternal)
   ```
   
   would keep the two checks on one marker, and an expression that gets 
`NoThrow` later would be accepted by both.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ExprUtils.scala:
##########
@@ -266,13 +294,71 @@ object ExprUtils extends EvalHelper with QueryErrorsBase {
     e.deterministic && !e.containsPattern(PLAN_EXPRESSION) &&
       canEvaluateUnconditionallyInternal(e)
 
+  // Only the numeric pairs are taken from `Cast.canUpCast`, which also covers 
e.g. DATE to
+  // TIMESTAMP, which can overflow, and casts between complex types. Among the 
numeric ones, a
+  // decimal to an integral type can overflow in ANSI mode, e.g. DECIMAL(19, 
0) to BIGINT, as
+  // `Cast.nullable` notes.
+  private def isNumericUpCast(from: DataType, to: DataType): Boolean = (from, 
to) match {
+    case (_: DecimalType, _: IntegralType) => false

Review Comment:
   **3. [Low] The decimal to integral exclusion is no longer needed on master**
   
   On master, `Cast.canUpCast` accepts a decimal to an integral type only when 
every value fits, e.g. `DECIMAL(18, 0)` to `BIGINT` or `DECIMAL(9, 0)` to 
`INT`, so such a cast cannot overflow in ANSI mode either. The note in 
`Cast.nullable` that the comment above refers to was removed by 
[SPARK-60970](https://issues.apache.org/jira/browse/SPARK-60970) (#60152).
   
   With this case, a condition such as `CAST(d AS BIGINT) = id` over a 
`DECIMAL(18, 0)` column is still treated as one that can fail. Dropping this 
case, so that numeric pairs use `Cast.canUpCast` as is, would also let the 
comment above, the Scaladoc ("other than a decimal to an integral type, which 
can overflow") and the PR description say the same thing as the code. The test 
could then check that `DECIMAL(18, 0)` to `BIGINT` is accepted and `DECIMAL(19, 
0)` to `BIGINT` is not.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ExprUtils.scala:
##########
@@ -266,13 +294,71 @@ object ExprUtils extends EvalHelper with QueryErrorsBase {
     e.deterministic && !e.containsPattern(PLAN_EXPRESSION) &&

Review Comment:
   **4. [Low] `CombineFilters` is a caller now, but the PR description and 
tests do not cover it**
   
   The PR description lists `FilterExec`, `StreamedSideJoinCondition` and 
`RewriteDistinctAggregates` as the callers. On master, `CombineFilters` (item 
2) uses this check too. After a rebase, a newly accepted conjunct, such as `a + 
1 > 0` with ANSI mode off, `substr(s, 1, 4) = '2024'`, `year(dt) = 2024` or a 
`try_cast`, written after a non-deterministic or throwable conjunct is moved 
into the lower filter, where it stayed above before:
   
   ```
   Filter(rand(10) < 0.5 AND a + 1 > 0, Filter(c > 0, t))
   -> Filter(rand(10) < 0.5, Filter(c > 0 AND a + 1 > 0, t))
   ```
   
   Then `rand(10)` is evaluated on fewer rows and picks different rows. This is 
the intended trade-off of SPARK-60980, but it means the optimized plans of 
`CombineFilters` change too. Could the description mention it, and could 
`FilterPushdownSuite` get a case where a newly accepted conjunct is combined?



##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/RewriteDistinctAggregatesSuite.scala:
##########
@@ -805,10 +806,10 @@ class RewriteDistinctAggregatesSuite extends PlanTest {
     val unsafeBases = Seq(
       // Division may throw (e.g. divide-by-zero under ANSI mode) on rows 
where the
       // original IF branch is not taken.
-      Symbol("c") / Symbol("b"),
+      Divide(Symbol("c"), Symbol("b"), NumericEvalContext(EvalMode.ANSI)),
       // Cast may throw under ANSI mode.
-      Cast(Symbol("c"), StringType),
-      // String functions are not in the branch-safe whitelist.
+      Cast(Symbol("d"), IntegerType, evalMode = EvalMode.ANSI),
+      // Lower is not in the branch-safe allowlist.

Review Comment:
   **7. [Low] No test checks that a newly accepted base is rewritten**
   
   The PR description says that `RewriteDistinctAggregates` now rewrites more 
`COUNT(DISTINCT IF(...))` aggregates, but this suite only updates the bases 
that must not be rewritten. `conditional: rewrite branch-safe expression bases` 
still checks only comparisons, `Coalesce` and struct and map accessors. Adding 
a few newly accepted bases there, such as `Add($"b", $"c", 
NumericEvalContext(EvalMode.LEGACY))` and `Substring($"d", 1, 2)`, would show 
the effect on this caller and fail if `extractCondAndBase` stops accepting them.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ExprUtils.scala:
##########
@@ -266,13 +294,71 @@ object ExprUtils extends EvalHelper with QueryErrorsBase {
     e.deterministic && !e.containsPattern(PLAN_EXPRESSION) &&
       canEvaluateUnconditionallyInternal(e)
 
+  // Only the numeric pairs are taken from `Cast.canUpCast`, which also covers 
e.g. DATE to
+  // TIMESTAMP, which can overflow, and casts between complex types. Among the 
numeric ones, a
+  // decimal to an integral type can overflow in ANSI mode, e.g. DECIMAL(19, 
0) to BIGINT, as
+  // `Cast.nullable` notes.
+  private def isNumericUpCast(from: DataType, to: DataType): Boolean = (from, 
to) match {
+    case (_: DecimalType, _: IntegralType) => false
+    case (_: NumericType, _: NumericType) => Cast.canUpCast(from, to)
+    case _ => false
+  }
+
+  // Whether a cast can not fail. A cast of a date to a timestamp is left out 
also in LEGACY mode,
+  // as converting a date far from the epoch to microseconds overflows there.
+  private def cannotFailCast(c: Cast): Boolean = (c.child.dataType, 
c.dataType) match {
+    case (from, to) if isNumericUpCast(from, to) => true
+    case (TimestampType | TimestampNTZType, DateType) => true
+    // A CHAR or VARCHAR target checks the length of the string.
+    case (_: NumericType | BooleanType, s: StringType) if 
StringHelper.isPlainString(s) => true
+    case _ if c.evalMode == EvalMode.TRY => true
+    // `Cast.isNoThrowLegacyCast` covers the numbers, booleans and strings. A 
string to a date or
+    // a timestamp does not raise in LEGACY mode either: the parsers catch the 
errors and return
+    // None, which becomes NULL.
+    case (_: StringType, DateType | TimestampType | TimestampNTZType)
+        if c.evalMode == EvalMode.LEGACY => true
+    case (from, to) if c.evalMode == EvalMode.LEGACY => 
Cast.isNoThrowLegacyCast(from, to)
+    case _ => false
+  }
+
+  // Whether numeric arithmetic can not fail, in its own eval mode.
+  private def cannotFailArithmetic(b: BinaryArithmetic): Boolean = {
+    val decimal = b.left.dataType.isInstanceOf[DecimalType]
+    b.children.forall(_.dataType.isInstanceOf[NumericType]) && (b.evalMode 
match {
+      case EvalMode.LEGACY => b match {
+        case _: Add | _: Subtract | _: Multiply | _: Divide => true
+        // `Decimal.quot` and `Decimal.%` raise when the integral quotient is 
too long.
+        case _: IntegralDivide | _: Remainder | _: Pmod => !decimal
+        case _ => false
+      }
+      // `DivModLike` and Pmod override `eval` without the catch of TRY mode, 
and IntegralDivide
+      // and Pmod check a zero divisor there as in ANSI mode.
+      case EvalMode.TRY => b match {

Review Comment:
   **8. [Nit] The LEGACY and TRY branches repeat the same case**
   
   Both branches accept `Add`, `Subtract`, `Multiply` and `Divide`. Matching 
the operator first gives the same result in one place:
   
   ```scala
   b.evalMode != EvalMode.ANSI && (b match {
     case _: Add | _: Subtract | _: Multiply | _: Divide => true
     case _: Remainder => !decimal
     case _: IntegralDivide | _: Pmod => !decimal && b.evalMode == 
EvalMode.LEGACY
     case _ => false
   })
   ```



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ExprUtils.scala:
##########
@@ -266,13 +294,71 @@ object ExprUtils extends EvalHelper with QueryErrorsBase {
     e.deterministic && !e.containsPattern(PLAN_EXPRESSION) &&
       canEvaluateUnconditionallyInternal(e)
 
+  // Only the numeric pairs are taken from `Cast.canUpCast`, which also covers 
e.g. DATE to
+  // TIMESTAMP, which can overflow, and casts between complex types. Among the 
numeric ones, a
+  // decimal to an integral type can overflow in ANSI mode, e.g. DECIMAL(19, 
0) to BIGINT, as
+  // `Cast.nullable` notes.
+  private def isNumericUpCast(from: DataType, to: DataType): Boolean = (from, 
to) match {
+    case (_: DecimalType, _: IntegralType) => false
+    case (_: NumericType, _: NumericType) => Cast.canUpCast(from, to)
+    case _ => false
+  }
+
+  // Whether a cast can not fail. A cast of a date to a timestamp is left out 
also in LEGACY mode,
+  // as converting a date far from the epoch to microseconds overflows there.
+  private def cannotFailCast(c: Cast): Boolean = (c.child.dataType, 
c.dataType) match {
+    case (from, to) if isNumericUpCast(from, to) => true
+    case (TimestampType | TimestampNTZType, DateType) => true
+    // A CHAR or VARCHAR target checks the length of the string.
+    case (_: NumericType | BooleanType, s: StringType) if 
StringHelper.isPlainString(s) => true
+    case _ if c.evalMode == EvalMode.TRY => true
+    // `Cast.isNoThrowLegacyCast` covers the numbers, booleans and strings. A 
string to a date or
+    // a timestamp does not raise in LEGACY mode either: the parsers catch the 
errors and return
+    // None, which becomes NULL.
+    case (_: StringType, DateType | TimestampType | TimestampNTZType)
+        if c.evalMode == EvalMode.LEGACY => true
+    case (from, to) if c.evalMode == EvalMode.LEGACY => 
Cast.isNoThrowLegacyCast(from, to)
+    case _ => false
+  }
+
+  // Whether numeric arithmetic can not fail, in its own eval mode.
+  private def cannotFailArithmetic(b: BinaryArithmetic): Boolean = {
+    val decimal = b.left.dataType.isInstanceOf[DecimalType]
+    b.children.forall(_.dataType.isInstanceOf[NumericType]) && (b.evalMode 
match {
+      case EvalMode.LEGACY => b match {
+        case _: Add | _: Subtract | _: Multiply | _: Divide => true
+        // `Decimal.quot` and `Decimal.%` raise when the integral quotient is 
too long.
+        case _: IntegralDivide | _: Remainder | _: Pmod => !decimal
+        case _ => false
+      }
+      // `DivModLike` and Pmod override `eval` without the catch of TRY mode, 
and IntegralDivide
+      // and Pmod check a zero divisor there as in ANSI mode.
+      case EvalMode.TRY => b match {
+        case _: Add | _: Subtract | _: Multiply | _: Divide => true
+        case _: Remainder => !decimal
+        case _ => false
+      }
+      case _ => false
+    })
+  }
+
   private def canEvaluateUnconditionallyInternal(e: Expression): Boolean = e 
match {
     case _: AttributeReference | _: Literal => true
-    case _: GetStructField | _: GetArrayStructFields | _: GetMapValue =>
+    case _: GetStructField | _: GetArrayStructFields | _: GetMapValue | _: 
CreateNamedStruct =>
       e.children.forall(canEvaluateUnconditionallyInternal)
     case _: And | _: Or | _: Not | _: BinaryComparison | _: IsNull | _: 
IsNotNull |
-         _: IsNaN | _: NullIf | _: Coalesce | _: In | _: InSet =>
+         _: IsNaN | _: NullIf | _: Coalesce | _: In | _: InSet | _: Size | _: 
StartsWith |
+         _: EndsWith | _: Contains | _: Length | _: OctetLength | _: Substring 
| _: GetDateField |

Review Comment:
   **6. [Low] Matching `GetDateField` and `GetTimeField` by trait accepts any 
later subclass**
   
   Every subclass of these traits is accepted, including one added later whose 
function can throw, and no test would notice: the evaluation tests list the 
current subclasses. The same goes for the eval mode details kept in 
`cannotFailArithmetic`, such as `DivModLike` and `Pmod` not catching errors in 
TRY mode, which live far from `arithmetic.scala`. `Cast.isNoThrowLegacyCast` 
warns about the same kind of drift ("must stay in sync with it").
   
   Marking the accepted expressions next to their implementations, e.g. with 
`NoThrow` (item 5), would make whoever changes one of them see this contract. 
This does not need to block the PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to