From ea8e09faa0c362718a7e4f73f58661e13ee68852 Mon Sep 17 00:00:00 2001 From: Xinyuan Lin Date: Sun, 9 Aug 2026 04:54:57 -0700 Subject: [PATCH 1/2] chore(amber): remove the unused ElidableStatement --- .../engine/common/ElidableStatement.scala | 34 ----- .../engine/common/ElidableStatementSpec.scala | 141 ------------------ 2 files changed, 175 deletions(-) delete mode 100644 amber/src/main/scala/org/apache/texera/amber/engine/common/ElidableStatement.scala delete mode 100644 amber/src/test/scala/org/apache/texera/amber/engine/common/ElidableStatementSpec.scala diff --git a/amber/src/main/scala/org/apache/texera/amber/engine/common/ElidableStatement.scala b/amber/src/main/scala/org/apache/texera/amber/engine/common/ElidableStatement.scala deleted file mode 100644 index bf78b290c31..00000000000 --- a/amber/src/main/scala/org/apache/texera/amber/engine/common/ElidableStatement.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.texera.amber.engine.common - -import scala.annotation.elidable -import scala.annotation.elidable._ - -object ElidableStatement { - - @elidable(FINEST) def finest(operations: => Unit): Unit = operations - - @elidable(FINER) def finer(operations: => Unit): Unit = operations - - @elidable(FINE) def fine(operations: => Unit): Unit = operations - - @elidable(INFO) def info(operations: => Unit): Unit = operations -} diff --git a/amber/src/test/scala/org/apache/texera/amber/engine/common/ElidableStatementSpec.scala b/amber/src/test/scala/org/apache/texera/amber/engine/common/ElidableStatementSpec.scala deleted file mode 100644 index 6f7e2eb2b33..00000000000 --- a/amber/src/test/scala/org/apache/texera/amber/engine/common/ElidableStatementSpec.scala +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.texera.amber.engine.common - -import org.scalatest.flatspec.AnyFlatSpec - -class ElidableStatementSpec extends AnyFlatSpec { - - // --------------------------------------------------------------------------- - // Context — the texera build sets `-Xelide-below WARNING` (see - // `amber/build.sbt`). Every `ElidableStatement` helper is annotated with - // an elide level strictly below WARNING (FINEST / FINER / FINE / INFO), - // so the Scala compiler replaces every CALL to these helpers with a - // `()` Unit value at *compile* time. The by-name block argument is - // never even constructed, let alone evaluated, in production / test - // builds — that is the entire point of the abstraction. - // - // This spec pins that contract: a regression that bumped a method's - // elide level above WARNING (e.g. `@elidable(SEVERE)`), removed the - // `@elidable` annotation, or relaxed `-Xelide-below` in the build - // would re-enable side effects and break the silent-in-production - // promise — and this spec would catch it. - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Each helper compiles to a no-op (block side effect does NOT fire) - // --------------------------------------------------------------------------- - - "ElidableStatement.finest" should - "be elided at the build's elide level — its by-name block must NOT execute" in { - var counter = 0 - ElidableStatement.finest { counter += 1 } - assert(counter == 0, "block should be elided away, counter must remain at 0") - } - - "ElidableStatement.finer" should - "be elided at the build's elide level — its by-name block must NOT execute" in { - var counter = 0 - ElidableStatement.finer { counter += 1 } - assert(counter == 0) - } - - "ElidableStatement.fine" should - "be elided at the build's elide level — its by-name block must NOT execute" in { - var counter = 0 - ElidableStatement.fine { counter += 1 } - assert(counter == 0) - } - - "ElidableStatement.info" should - "be elided at the build's elide level — its by-name block must NOT execute" in { - var counter = 0 - ElidableStatement.info { counter += 1 } - assert(counter == 0) - } - - // --------------------------------------------------------------------------- - // Even a throwing block must NOT propagate — it's never evaluated. - // --------------------------------------------------------------------------- - - "Elided helpers" should - "not propagate an exception that would have been thrown by their block" in { - // If `info` accidentally stopped being elided, this would re-raise the - // RuntimeException and fail the test. Pinning the suppression directly - // catches that regression. - ElidableStatement.info { throw new RuntimeException("must never fire") } - ElidableStatement.fine { throw new RuntimeException("must never fire") } - ElidableStatement.finer { throw new RuntimeException("must never fire") } - ElidableStatement.finest { throw new RuntimeException("must never fire") } - succeed - } - - // --------------------------------------------------------------------------- - // Multiple calls don't accumulate side effects (each one is independently - // elided). - // --------------------------------------------------------------------------- - - "Repeated elided calls" should "stay no-ops across 1000 invocations" in { - var counter = 0 - var i = 0 - while (i < 1000) { - ElidableStatement.info { counter += 1 } - i += 1 - } - assert( - counter == 0, - s"1000 elided info calls should not accumulate side effects, got: $counter" - ) - } - - // --------------------------------------------------------------------------- - // Return-type contract — each helper still type-checks as `=> Unit ⇒ Unit`. - // --------------------------------------------------------------------------- - - "ElidableStatement methods" should "all return Unit (compile-time enforced)" in { - // Assignments would fail to typecheck if a method's signature drifted - // — e.g. someone made `info` return the block's result. The fact that - // these compile under `-Xelide-below WARNING` also confirms each call - // is replaced with the Unit `()` value, not with an exception. - val r1: Unit = ElidableStatement.info { () } - val r2: Unit = ElidableStatement.fine { () } - val r3: Unit = ElidableStatement.finer { () } - val r4: Unit = ElidableStatement.finest { () } - assert(r1 == r2 && r2 == r3 && r3 == r4) - } - - // --------------------------------------------------------------------------- - // By-name parameter shape — each helper accepts a `=> Unit` block - // (verified at compile time by passing a parameter-less lambda body). - // --------------------------------------------------------------------------- - - "ElidableStatement methods" should "accept a by-name `=> Unit` argument (compile-time enforced)" in { - // The fact that these expressions compile proves the parameter shape: - // a value-typed expression of type Unit AND a thunk that runs side - // effects are both accepted. Under `-Xelide-below WARNING`, neither - // executes — but the type contract still holds. - ElidableStatement.info { () } - ElidableStatement.info { val x = 1; val y = x + 1; () } - ElidableStatement.info { - println("debug") - } - succeed - } -} From a3440a75a2fd451e94485e5b7f91c3460a48ab73 Mon Sep 17 00:00:00 2001 From: Xinyuan Lin Date: Sun, 16 Aug 2026 19:30:23 -0700 Subject: [PATCH 2/2] chore(build): remove the dead -Xelide-below scalac option `-Xelide-below WARNING` was set in sixteen build.sbt files. The only `@elidable`-annotated code in the repo was ElidableStatement, whose four wrappers (FINEST 300 / FINER 400 / FINE 500 / INFO 800) all sat below the WARNING (900) threshold. It had no callers and is deleted in #7451, after which no `@elidable` annotation remains and the flag switches nothing. Not a behaviour change: `assert`/`assume` are `@elidable(ASSERTION)` = 2000, above WARNING, so they are compiled in today; scalac elides nothing when the flag is absent, so they are compiled in after this too. Also drops the comments that only existed to explain the flag, including amber's "to turn on, use: INFO" note. --- access-control-service/build.sbt | 1 - amber/build.sbt | 4 ---- common/auth/build.sbt | 1 - common/config/build.sbt | 1 - common/dao/build.sbt | 1 - common/pybuilder/build.sbt | 1 - common/resource/build.sbt | 1 - common/util/build.sbt | 1 - common/workflow-compiler/build.sbt | 2 -- common/workflow-core/build.sbt | 1 - common/workflow-operator/build.sbt | 1 - computing-unit-managing-service/build.sbt | 1 - config-service/build.sbt | 1 - file-service/build.sbt | 1 - notebook-migration-service/build.sbt | 1 - workflow-compiling-service/build.sbt | 1 - 16 files changed, 20 deletions(-) diff --git a/access-control-service/build.sbt b/access-control-service/build.sbt index 48c63d21482..93af38e4420 100644 --- a/access-control-service/build.sbt +++ b/access-control-service/build.sbt @@ -48,7 +48,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/amber/build.sbt b/amber/build.sbt index b1f8a0d4819..f4915589e7e 100644 --- a/amber/build.sbt +++ b/amber/build.sbt @@ -35,10 +35,6 @@ Universal / mappings := AddMetaInfLicenseFiles.distMappings( semanticdbEnabled := true semanticdbVersion := scalafixSemanticdb.revision -// to turn on, use: INFO -// to turn off, use: WARNING -scalacOptions ++= Seq("-Xelide-below", "WARNING") - // to check feature warnings scalacOptions += "-feature" // to check deprecation warnings diff --git a/common/auth/build.sbt b/common/auth/build.sbt index 4f325bf77ef..866babec959 100644 --- a/common/auth/build.sbt +++ b/common/auth/build.sbt @@ -41,7 +41,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/common/config/build.sbt b/common/config/build.sbt index f6a8aa05682..e1b8c5a1e18 100644 --- a/common/config/build.sbt +++ b/common/config/build.sbt @@ -38,7 +38,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/common/dao/build.sbt b/common/dao/build.sbt index 8bc49072d23..d010ebd40c0 100644 --- a/common/dao/build.sbt +++ b/common/dao/build.sbt @@ -114,7 +114,6 @@ Compile / sourceGenerators += jooqGenerate // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/common/pybuilder/build.sbt b/common/pybuilder/build.sbt index aeec3f2722e..cf6bf9fb268 100644 --- a/common/pybuilder/build.sbt +++ b/common/pybuilder/build.sbt @@ -42,7 +42,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/common/resource/build.sbt b/common/resource/build.sbt index 53d23706144..ab974601558 100644 --- a/common/resource/build.sbt +++ b/common/resource/build.sbt @@ -38,7 +38,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/common/util/build.sbt b/common/util/build.sbt index 0f4446edccd..addb2ff9fd3 100644 --- a/common/util/build.sbt +++ b/common/util/build.sbt @@ -37,7 +37,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/common/workflow-compiler/build.sbt b/common/workflow-compiler/build.sbt index d8d7aea89cd..b5224529668 100644 --- a/common/workflow-compiler/build.sbt +++ b/common/workflow-compiler/build.sbt @@ -26,8 +26,6 @@ scalacOptions += "-Ymacro-annotations" // Scala compiler options (mirrors the other common modules; `-Ywarn-unused:imports` // is required by the scalafix RemoveUnused rule that CI runs via scalafixAll). Compile / scalacOptions ++= Seq( - "-Xelide-below", - "WARNING", "-feature", "-deprecation", "-Ywarn-unused:imports" diff --git a/common/workflow-core/build.sbt b/common/workflow-core/build.sbt index 0d48fc4048f..bfc14670419 100644 --- a/common/workflow-core/build.sbt +++ b/common/workflow-core/build.sbt @@ -80,7 +80,6 @@ Test / testGrouping := { // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/common/workflow-operator/build.sbt b/common/workflow-operator/build.sbt index 2bb41754a51..7fb262cda53 100644 --- a/common/workflow-operator/build.sbt +++ b/common/workflow-operator/build.sbt @@ -55,7 +55,6 @@ Test / testOptions ++= TestFilters.integrationSplit( // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/computing-unit-managing-service/build.sbt b/computing-unit-managing-service/build.sbt index 952544a6d0b..04c403687ed 100644 --- a/computing-unit-managing-service/build.sbt +++ b/computing-unit-managing-service/build.sbt @@ -56,7 +56,6 @@ libraryDependencies ++= Seq( // Compiler Options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", "-feature", "-deprecation", "-Ywarn-unused:imports" diff --git a/config-service/build.sbt b/config-service/build.sbt index a7f85badefa..de3e034852f 100644 --- a/config-service/build.sbt +++ b/config-service/build.sbt @@ -48,7 +48,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/file-service/build.sbt b/file-service/build.sbt index 3e557383b7b..defbb99c1fb 100644 --- a/file-service/build.sbt +++ b/file-service/build.sbt @@ -48,7 +48,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/notebook-migration-service/build.sbt b/notebook-migration-service/build.sbt index 53dc3c9e315..e907d977f1c 100644 --- a/notebook-migration-service/build.sbt +++ b/notebook-migration-service/build.sbt @@ -48,7 +48,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports diff --git a/workflow-compiling-service/build.sbt b/workflow-compiling-service/build.sbt index 96fb874a7d3..2af92efc4d4 100644 --- a/workflow-compiling-service/build.sbt +++ b/workflow-compiling-service/build.sbt @@ -50,7 +50,6 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1) // Scala compiler options Compile / scalacOptions ++= Seq( - "-Xelide-below", "WARNING", // Turn on optimizations with "WARNING" as the threshold "-feature", // Check feature warnings "-deprecation", // Check deprecation warnings "-Ywarn-unused:imports" // Check for unused imports