File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -4363,7 +4363,7 @@ object Parsers {
43634363 else
43644364 // structural instance
43654365 val vparamss1 = vparamss.nestedMap: vparam =>
4366- if vparam.mods.is(Private )
4366+ if vparam.mods.is(Private ) && ! vparam.name. isInstanceOf [ DerivedName ]
43674367 then vparam.withMods(vparam.mods &~ PrivateLocal | Protected )
43684368 else vparam
43694369 val constr = makeConstructor(tparams, vparamss1)
Original file line number Diff line number Diff line change @@ -585,7 +585,10 @@ object CheckUnused:
585585 val alias = m.owner.info.member(sym.name)
586586 if alias.exists then
587587 val aliasSym = alias.symbol
588- if aliasSym.is(ParamAccessor ) && ! infos.refs(alias.symbol) then
588+ val checking =
589+ aliasSym.isAllOf(PrivateParamAccessor , butNot = CaseAccessor )
590+ || aliasSym.isAllOf(Protected | ParamAccessor , butNot = CaseAccessor ) && m.owner.is(Given )
591+ if checking && ! infos.refs(alias.symbol) then
589592 warnAt(pos)(UnusedSymbol .implicitParams)
590593 else
591594 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