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
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/PostTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
if sym.is(Param) then
registerIfUnrolledParam(sym)
// @unused is getter/setter but we want it on ordinary method params
if !sym.owner.is(Method) || sym.owner.isConstructor then
sym.keepAnnotationsCarrying(thisPhase, Set(defn.ParamMetaAnnot), orNoneOf = defn.NonBeanMetaAnnots)
// @param should be consulted only for fields
val unusing = sym.getAnnotation(defn.UnusedAnnot)
sym.keepAnnotationsCarrying(thisPhase, Set(defn.ParamMetaAnnot), orNoneOf = defn.NonBeanMetaAnnots)
unusing.foreach(sym.addAnnotation)
else if sym.is(ParamAccessor) then
// @publicInBinary is not a meta-annotation and therefore not kept by `keepAnnotationsCarrying`
val publicInBinaryAnnotOpt = sym.getAnnotation(defn.PublicInBinaryAnnot)
Expand Down
13 changes: 13 additions & 0 deletions tests/warn/i23033.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//> using options -Werror -Wunused:all

import scala.annotation.unused
import scala.concurrent.ExecutionContext
import scala.util.NotGiven

object Test {
given [T](using @unused ev: NotGiven[T <:< Int]): AnyRef with {}
}
object Useful:
given [T](using @unused ec: ExecutionContext): AnyRef with {}
object Syntax:
given [T] => (@unused ec: ExecutionContext) => AnyRef
Loading