Skip to content

Commit ad240d0

Browse files
committed
Fix #8397: Make context parameters of given instances protected
1 parent fc29643 commit ad240d0

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3508,7 +3508,7 @@ object Parsers {
35083508
possibleTemplateStart()
35093509
val tparams1 = tparams.map(tparam => tparam.withMods(tparam.mods | PrivateLocal))
35103510
val vparamss1 = vparamss.map(_.map(vparam =>
3511-
vparam.withMods(vparam.mods &~ Param | ParamAccessor | PrivateLocal)))
3511+
vparam.withMods(vparam.mods &~ Param | ParamAccessor | Protected)))
35123512
val templ = templateBodyOpt(makeConstructor(tparams1, vparamss1), parents, Nil)
35133513
if tparams.isEmpty && vparamss.isEmpty then ModuleDef(name, templ)
35143514
else TypeDef(name.toTypeName, templ)

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,8 @@ object Checking {
510510
var tp1 =
511511
if (isLeaked(tp.symbol)) {
512512
errors =
513-
(() => em"non-private ${sym.showLocated} refers to private ${tp.symbol}\nin its type signature ${sym.info}") ::
514-
errors
513+
(() => em"non-private ${sym.showLocated} refers to private ${tp.symbol}\nin its type signature ${sym.info}")
514+
:: errors
515515
tp
516516
}
517517
else mapOver(tp)

tests/pos/i8397.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
given foo(using x: Int) as AnyRef:
2+
type T = x.type
3+

0 commit comments

Comments
 (0)