@@ -192,20 +192,25 @@ enum Tree extends AutoLocated:
192192 LetLike (letLike, id, S (App (Ident (nme.init), Tup (id :: r :: Nil ))), bodo).withLocOf(this ).desugared
193193 case _ => this
194194
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
197200 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))
198203 case id : Ident => S (N , id, N )
199204 case Spread (Keyword .`..`, _, S (id : Ident )) => S (S (false ), id, N )
200205 case Spread (Keyword .`...`, _, S (id : Ident )) => S (S (true ), id, N )
201206 case Spread (Keyword .`..`, _, S (und : Under )) => S (S (false ), new Ident (" _" ).withLocOf(und), N )
202207 case Spread (Keyword .`...`, _, S (und : Under )) => S (S (true ), new Ident (" _" ).withLocOf(und), N )
203208 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)
205210 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.
209214 case _ => S (N , Ident (" " ), S (inner))
210215
211216 def isModuleModifier : Bool = this match
@@ -400,7 +405,7 @@ trait TypeDefImpl(using State) extends TypeOrTermDef:
400405
401406 lazy val clsParams : Ls [semantics.TermSymbol ] =
402407 this .paramLists.headOption.fold(Nil ): tup =>
403- tup.fields.iterator.flatMap(_.asParam).map:
408+ tup.fields.iterator.flatMap(_.asParam( false ) ).map:
404409 case (S (spd), id, _) => ??? // spreads are not allowed in class parameters
405410 case (N , id, _) => semantics.TermSymbol (ParamBind , symbol.asClsLike, id)
406411 .toList
0 commit comments