Skip to content

Commit dee7e44

Browse files
committed
Use correct flags for anonymous given parameters in classes
1 parent 944c08b commit dee7e44

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
415415
vdef.withMods(mods | Param)
416416
}
417417

418-
def makeSyntheticParameter(n: Int = 1, tpt: Tree = null, flags: FlagSet = EmptyFlags)(implicit ctx: Context): ValDef =
418+
def makeSyntheticParameter(n: Int = 1, tpt: Tree = null, flags: FlagSet = SyntheticTermParam)(implicit ctx: Context): ValDef =
419419
ValDef(nme.syntheticParamName(n), if (tpt == null) TypeTree() else tpt, EmptyTree)
420-
.withFlags(flags | SyntheticTermParam)
420+
.withFlags(flags)
421421

422422
def lambdaAbstract(tparams: List[TypeDef], tpt: Tree)(implicit ctx: Context): Tree =
423423
if (tparams.isEmpty) tpt else LambdaTypeTree(tparams, tpt)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,8 @@ object Parsers {
22472247
val tps = commaSeparated(() => annotType())
22482248
var counter = nparams
22492249
def nextIdx = { counter += 1; counter }
2250-
val params = tps.map(makeSyntheticParameter(nextIdx, _, Given | Implicit))
2250+
val paramFlags = if (ofClass) Private | Local | ParamAccessor else Param
2251+
val params = tps.map(makeSyntheticParameter(nextIdx, _, paramFlags | Synthetic | Given | Implicit))
22512252
params :: recur(firstClause = false, nparams + params.length)
22522253
}
22532254
else Nil

0 commit comments

Comments
 (0)