From a980d6518368317779b8a39f401e2d6c2b5c5782 Mon Sep 17 00:00:00 2001 From: som-snytt Date: Tue, 28 Oct 2025 03:36:32 -0700 Subject: [PATCH 1/2] Lint avoids revisiting Inlined.call (#24277) Fixes #24266 Restores empty check and "already seen" check for Inlined.call sites. [Cherry-picked b14afef63d0abe10ba036c28fbf12ebd5ca12772] --- compiler/src/dotty/tools/dotc/transform/CheckUnused.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala index 3378ce06f848..b1d3c2d4438b 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala @@ -166,7 +166,10 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha tree.expansion.putAttachment(InlinedParameter, ()) ctx override def transformInlined(tree: Inlined)(using Context): tree.type = - transformAllDeep(tree.call) + if !tree.call.isEmpty then + if !refInfos.calls.containsKey(tree.call) then + refInfos.calls.put(tree.call, ()) + transformAllDeep(tree.call) tree override def prepareForBind(tree: Bind)(using Context): Context = @@ -491,6 +494,7 @@ object CheckUnused: val asss = mutable.Set.empty[Symbol] // targets of assignment val skip = mutable.Set.empty[Symbol] // methods to skip (don't warn about their params) val nowarn = mutable.Set.empty[Symbol] // marked @nowarn + val calls = new IdentityHashMap[Tree, Unit] // inlined call already seen val imps = new IdentityHashMap[Import, Unit] // imports val sels = new IdentityHashMap[ImportSelector, Unit] // matched selectors def register(tree: Tree)(using Context): Unit = if tree.srcPos.isUserCode then From 6ce3ac5f8f811714465019b579b4b1b329196175 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Mon, 10 Nov 2025 15:28:08 +0100 Subject: [PATCH 2/2] bugfix: Fix issue after backporting --- .../src/dotty/tools/dotc/transform/PostTyper.scala | 5 +---- tests/pos-custom-args/captures/i24207.scala | 14 -------------- tests/warn/i24263.scala | 6 ------ 3 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 tests/pos-custom-args/captures/i24207.scala delete mode 100644 tests/warn/i24263.scala diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index e5eb03c24cd4..6d5175bf17a0 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -369,10 +369,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase case UnApply(fun, implicits, patterns) => // Reverse transform order for the same reason as in `app1` above. val patterns1 = transform(patterns) - val tree1 = cpy.UnApply(tree)(transform(fun), transform(implicits), patterns1) - // The pickling of UnApply trees uses the tpe of the tree, - // so we need to clean retains from it here - tree1.withType(transformAnnotsIn(CleanupRetains()(tree1.tpe))) + cpy.UnApply(tree)(transform(fun), transform(implicits), patterns1) case tree: TypeApply => if tree.symbol == defn.QuotedTypeModule_of then ctx.compilationUnit.needsStaging = true diff --git a/tests/pos-custom-args/captures/i24207.scala b/tests/pos-custom-args/captures/i24207.scala deleted file mode 100644 index 075b42315a3c..000000000000 --- a/tests/pos-custom-args/captures/i24207.scala +++ /dev/null @@ -1,14 +0,0 @@ -import language.experimental.captureChecking - -class Generator: - private def generateTable(table: Table) = - val (ownRelations, _) = calculateOwnRelations(table) - ownRelations - - private def calculateOwnRelations(table: Table) = - val ownRelations = table.relations.filter(_.association.isDefined) - (ownRelations, Nil) - -case class Table(relations: Seq[TableRelation]) -case class TableRelation(association: Option[Association]) -trait Association diff --git a/tests/warn/i24263.scala b/tests/warn/i24263.scala deleted file mode 100644 index fc4768de2597..000000000000 --- a/tests/warn/i24263.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Werror -Wunused:all - -object test { - def f(t: Tuple): Nothing = ??? - val _ = (inputTuple: NamedTuple.NamedTuple[Tuple, Tuple]) => f(inputTuple) -}