@@ -205,12 +205,12 @@ object desugar {
205
205
206
206
def makeImplicitParameters (
207
207
tpts : List [Tree ], implicitFlag : FlagSet ,
208
- mkParamName : () => TermName ,
208
+ mkParamName : Int => TermName ,
209
209
forPrimaryConstructor : Boolean = false
210
210
)(using Context ): List [ValDef ] =
211
211
for (tpt, i) <- tpts.zipWithIndex yield {
212
212
val paramFlags : FlagSet = if (forPrimaryConstructor) LocalParamAccessor else Param
213
- val epname = mkParamName()
213
+ val epname = mkParamName(i )
214
214
ValDef (epname, tpt, EmptyTree ).withFlags(paramFlags | implicitFlag)
215
215
}
216
216
@@ -254,7 +254,7 @@ object desugar {
254
254
// using clauses, we only need names that are unique among the
255
255
// parameters of the method since shadowing does not affect
256
256
// implicit resolution in Scala 3.
257
- mkParamName = () =>
257
+ mkParamName = i =>
258
258
val index = seenContextBounds + 1 // Start at 1 like FreshNameCreator.
259
259
val ret = ContextBoundParamName (EmptyTermName , index)
260
260
seenContextBounds += 1
@@ -1602,9 +1602,12 @@ object desugar {
1602
1602
case vd : ValDef => vd
1603
1603
}
1604
1604
1605
- def makeContextualFunction (formals : List [Tree ], body : Tree , erasedParams : List [Boolean ])(using Context ): Function = {
1605
+ def makeContextualFunction (formals : List [Tree ], paramNamesOrNil : List [ TermName ], body : Tree , erasedParams : List [Boolean ])(using Context ): Function = {
1606
1606
val mods = Given
1607
- val params = makeImplicitParameters(formals, mods, mkParamName = () => ContextFunctionParamName .fresh())
1607
+ val params = makeImplicitParameters(formals, mods,
1608
+ mkParamName = i =>
1609
+ if paramNamesOrNil.isEmpty then ContextFunctionParamName .fresh()
1610
+ else paramNamesOrNil(i))
1608
1611
FunctionWithMods (params, body, Modifiers (mods), erasedParams)
1609
1612
}
1610
1613
0 commit comments