File tree 2 files changed +17
-2
lines changed
compiler/src/dotty/tools/dotc/transform
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -247,8 +247,10 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
247
247
if sym.is(Param ) then
248
248
registerIfUnrolledParam(sym)
249
249
// @unused is getter/setter but we want it on ordinary method params
250
- if ! sym.owner.is(Method ) || sym.owner.isConstructor then
251
- sym.keepAnnotationsCarrying(thisPhase, Set (defn.ParamMetaAnnot ), orNoneOf = defn.NonBeanMetaAnnots )
250
+ // @param should be consulted only for fields
251
+ val unusing = sym.getAnnotation(defn.UnusedAnnot )
252
+ sym.keepAnnotationsCarrying(thisPhase, Set (defn.ParamMetaAnnot ), orNoneOf = defn.NonBeanMetaAnnots )
253
+ unusing.foreach(sym.addAnnotation)
252
254
else if sym.is(ParamAccessor ) then
253
255
// @publicInBinary is not a meta-annotation and therefore not kept by `keepAnnotationsCarrying`
254
256
val publicInBinaryAnnotOpt = sym.getAnnotation(defn.PublicInBinaryAnnot )
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