File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -592,7 +592,10 @@ object CheckUnused:
592592 val alias = m.owner.info.member(sym.name)
593593 if alias.exists then
594594 val aliasSym = alias.symbol
595- if aliasSym.is(ParamAccessor ) && ! infos.refs(alias.symbol) then
595+ val checking =
596+ aliasSym.isAllOf(PrivateParamAccessor , butNot = CaseAccessor )
597+ || aliasSym.isAllOf(Protected | ParamAccessor , butNot = CaseAccessor ) && m.owner.is(Given )
598+ if checking && ! infos.refs(alias.symbol) then
596599 warnAt(pos)(UnusedSymbol .implicitParams)
597600 else
598601 warnAt(pos)(UnusedSymbol .implicitParams)
Original file line number Diff line number Diff line change @@ -52,3 +52,35 @@ object Unmatched:
5252 case Ident (name) =>
5353 case _ =>
5454 e
55+
56+ trait Ctx
57+ case class K (i : Int )(using val ctx : Ctx ) // nowarn
58+ class L (val i : Int )(using val ctx : Ctx ) // nowarn
59+ class M (val i : Int )(using ctx : Ctx ) // warn
60+
61+ package givens:
62+
63+ trait X :
64+ def doX : Int
65+
66+ trait Y :
67+ def doY : String
68+
69+ given X :
70+ def doX = 7
71+
72+ given X => Y : // warn protected param to given class
73+ def doY = " 7"
74+ /* desugared. It is protected so that its type can be used in member defs without leaking.
75+ * possibly it should be protected only for named parameters.
76+ given class given_Y(using x$1: givens.X) extends Object(), givens.Y {
77+ protected given val x$1: givens.X
78+ def doY: String = "7"
79+ }
80+ final given def given_Y(using x$1: givens.X): givens.given_Y =
81+ new givens.given_Y(using x$1)()
82+ */
83+
84+ given namely : (x : X ) => Y : // warn protected param to given class
85+ def doY = " 8"
86+ end givens
You can’t perform that action at this time.
0 commit comments