Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,22 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
}

override def prepareForDefDef(tree: tpd.DefDef)(using Context): Context =
unusedDataApply{ ud =>
unusedDataApply: ud =>
if !tree.symbol.is(Private) then
tree.termParamss.flatten.foreach { p =>
ud.addIgnoredParam(p.symbol)
}
import ud.registerTrivial
tree.registerTrivial
ud.registerTrivial(tree)
traverseAnnotations(tree.symbol)
ud.registerDef(tree)
ud.addIgnoredUsage(tree.symbol)
}

override def prepareForTypeDef(tree: tpd.TypeDef)(using Context): Context =
unusedDataApply{ ud =>
unusedDataApply: ud =>
traverseAnnotations(tree.symbol)
if !tree.symbol.is(Param) then // Ignore type parameter (as Scala 2)
traverseAnnotations(tree.symbol)
ud.registerDef(tree)
ud.addIgnoredUsage(tree.symbol)
}

override def prepareForBind(tree: tpd.Bind)(using Context): Context =
traverseAnnotations(tree.symbol)
Expand Down
27 changes: 27 additions & 0 deletions tests/warn/i20536.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//> using options -Wunused:all
object Anns {
final class S extends annotation.StaticAnnotation
}

object Main {
locally {
import Anns.*
class C[@S A]
C().toString
}
locally {
import Anns.S as T
class C[@T A]
C().toString
}
locally {
import scala.specialized as T
class C[@T A]
C().toString
}
locally {
import scala.specialized as T // warn
class C[A]
C().toString
}
}
Loading