File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -194,8 +194,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
194194 else
195195 if sym.is(Param ) then
196196 // @unused is getter/setter but we want it on ordinary method params
197- if ! sym.owner.is(Method ) || sym.owner.isConstructor then
198- sym.keepAnnotationsCarrying(thisPhase, Set (defn.ParamMetaAnnot ), orNoneOf = defn.NonBeanMetaAnnots )
197+ // @param should be consulted only for fields
198+ val unusing = sym.getAnnotation(defn.UnusedAnnot )
199+ sym.keepAnnotationsCarrying(thisPhase, Set (defn.ParamMetaAnnot ), orNoneOf = defn.NonBeanMetaAnnots )
200+ unusing.foreach(sym.addAnnotation)
199201 else if sym.is(ParamAccessor ) then
200202 sym.keepAnnotationsCarrying(thisPhase, Set (defn.GetterMetaAnnot , defn.FieldMetaAnnot ))
201203 else
Original file line number Diff line number Diff line change 1+ //> using options -Werror -Wunused:all
2+
3+ import scala .annotation .unused
4+ import scala .concurrent .ExecutionContext
5+ import scala .util .NotGiven
6+
7+ object Test {
8+ given [T ](using @ unused ev : NotGiven [T <:< Int ]): AnyRef with {}
9+ }
10+ object Useful :
11+ given [T ](using @ unused ec : ExecutionContext ): AnyRef with {}
12+ object Syntax :
13+ given [T ] => (@ unused ec : ExecutionContext ) => AnyRef
You can’t perform that action at this time.
0 commit comments