@@ -192,20 +192,25 @@ enum Tree extends AutoLocated:
192
192
LetLike (letLike, id, S (App (Ident (nme.init), Tup (id :: r :: Nil ))), bodo).withLocOf(this ).desugared
193
193
case _ => this
194
194
195
- /** S(true) means eager spread, S(false) means lazy spread, N means no spread. */
196
- def asParam : Opt [(Opt [Bool ], Ident , Opt [Tree ])] = this match
195
+ /**
196
+ * Parameter `inUsing` means the param list is modified by `using`.
197
+ * In the first result, `S(true)` means eager spread, `S(false)` means lazy spread, and `N` means no spread.
198
+ */
199
+ def asParam (inUsing : Bool ): Opt [(Opt [Bool ], Ident , Opt [Tree ])] = this match
197
200
case und : Under => S (N , new Ident (" _" ).withLocOf(und), N )
201
+ // * In `using` clauses, identifiers are understood as type names for unnamed contextual parameters:
202
+ case id : Ident if inUsing => S (N , Ident (" " ), S (id))
198
203
case id : Ident => S (N , id, N )
199
204
case Spread (Keyword .`..`, _, S (id : Ident )) => S (S (false ), id, N )
200
205
case Spread (Keyword .`...`, _, S (id : Ident )) => S (S (true ), id, N )
201
206
case Spread (Keyword .`..`, _, S (und : Under )) => S (S (false ), new Ident (" _" ).withLocOf(und), N )
202
207
case Spread (Keyword .`...`, _, S (und : Under )) => S (S (true ), new Ident (" _" ).withLocOf(und), N )
203
208
case InfixApp (lhs : Ident , Keyword .`:`, rhs) => S (N , lhs, S (rhs))
204
- case TermDef (ImmutVal , inner, _) => inner.asParam
209
+ case TermDef (ImmutVal , inner, _) => inner.asParam(inUsing)
205
210
case Modified (Keyword .`using`, _, inner) => inner match
206
- // Param of form (using ..., name: Type). Parse it as usual.
207
- case inner : InfixApp => inner.asParam
208
- // Param of form (using ..., Type). Synthesize an identifier for it.
211
+ // Param of form (using name: Type). Parse it as usual.
212
+ case inner : InfixApp => inner.asParam(inUsing)
213
+ // Param of form (using Type). Synthesize an identifier for it.
209
214
case _ => S (N , Ident (" " ), S (inner))
210
215
211
216
def isModuleModifier : Bool = this match
@@ -400,7 +405,7 @@ trait TypeDefImpl(using State) extends TypeOrTermDef:
400
405
401
406
lazy val clsParams : Ls [semantics.TermSymbol ] =
402
407
this .paramLists.headOption.fold(Nil ): tup =>
403
- tup.fields.iterator.flatMap(_.asParam).map:
408
+ tup.fields.iterator.flatMap(_.asParam( false ) ).map:
404
409
case (S (spd), id, _) => ??? // spreads are not allowed in class parameters
405
410
case (N , id, _) => semantics.TermSymbol (ParamBind , symbol.asClsLike, id)
406
411
.toList
0 commit comments