@@ -376,17 +376,55 @@ object SymDenotations {
376
376
/** If this is a method, the parameter symbols, by section.
377
377
* Both type and value parameters are included. Empty sections are skipped.
378
378
*/
379
- final def paramss : List [List [Symbol ]] = myParamss
380
- final def paramss_ = (pss : List [List [Symbol ]]): Unit =
379
+ final def rawParamss : List [List [Symbol ]] = myParamss
380
+ final def rawParamss_ = (pss : List [List [Symbol ]]): Unit =
381
381
myParamss = pss
382
382
383
383
final def setParamss (tparams : List [Symbol ], vparamss : List [List [Symbol ]])(using Context ): Unit =
384
- paramss = (if tparams.isEmpty then vparamss else tparams :: vparamss)
384
+ rawParamss = (if tparams.isEmpty then vparamss else tparams :: vparamss)
385
385
.filterConserve(! _.isEmpty)
386
386
387
387
final def setParamssFromDefs (tparams : List [TypeDef [? ]], vparamss : List [List [ValDef [? ]]])(using Context ): Unit =
388
388
setParamss(tparams.map(_.symbol), vparamss.map(_.map(_.symbol)))
389
389
390
+ /** A pair consistsing of type paremeter symbols and value parameter symbol lists
391
+ * of this method definition, or (Nil, Nil) for other symbols.
392
+ * Makes use of `rawParamss` when present, or constructs fresh parameter symbols otherwise.
393
+ * This method can be allocation-heavy.
394
+ */
395
+ final def paramSymss (using ctx : Context ): (List [TypeSymbol ], List [List [TermSymbol ]]) =
396
+
397
+ def recurWithParamss (info : Type , paramss : List [List [Symbol ]]): List [List [Symbol ]] =
398
+ info match
399
+ case info : LambdaType =>
400
+ if info.paramNames.isEmpty then Nil :: recurWithParamss(info.resType, paramss)
401
+ else paramss.head :: recurWithParamss(info.resType, paramss.tail)
402
+ case _ =>
403
+ Nil
404
+
405
+ def recurWithoutParamss (info : Type ): List [List [Symbol ]] = info match
406
+ case info : LambdaType =>
407
+ val params = info.paramNames.lazyZip(info.paramInfos).map((pname, ptype) =>
408
+ ctx.newSymbol(symbol, pname, SyntheticParam , ptype))
409
+ val prefs = params.map(_.namedType)
410
+ for param <- params do
411
+ param.info = param.info.substParams(info, prefs)
412
+ params :: recurWithoutParamss(info.instantiate(prefs))
413
+ case _ =>
414
+ Nil
415
+
416
+ try
417
+ val allParamss =
418
+ if rawParamss.isEmpty then recurWithoutParamss(info)
419
+ else recurWithParamss(info, rawParamss)
420
+ info match
421
+ case info : PolyType => (allParamss.head, allParamss.tail).asInstanceOf
422
+ case _ => (Nil , allParamss).asInstanceOf
423
+ catch case NonFatal (ex) =>
424
+ println(i " paramSymss failure for $symbol, $info, $rawParamss" )
425
+ throw ex
426
+ end paramSymss
427
+
390
428
/** The denotation is completed: info is not a lazy type and attributes have defined values */
391
429
final def isCompleted : Boolean = ! myInfo.isInstanceOf [LazyType ]
392
430
@@ -1466,7 +1504,7 @@ object SymDenotations {
1466
1504
info : Type = null ,
1467
1505
privateWithin : Symbol = null ,
1468
1506
annotations : List [Annotation ] = null ,
1469
- paramss : List [List [Symbol ]] = null )(
1507
+ rawParamss : List [List [Symbol ]] = null )(
1470
1508
using ctx : Context ): SymDenotation = {
1471
1509
// simulate default parameters, while also passing implicit context ctx to the default values
1472
1510
val initFlags1 = (if (initFlags != UndefinedFlags ) initFlags else this .flags)
@@ -1475,10 +1513,10 @@ object SymDenotations {
1475
1513
assert(ctx.phase.changesParents, i " undeclared parent change at ${ctx.phase} for $this, was: $info, now: $info1" )
1476
1514
val privateWithin1 = if (privateWithin != null ) privateWithin else this .privateWithin
1477
1515
val annotations1 = if (annotations != null ) annotations else this .annotations
1478
- val paramss1 = if paramss != null then paramss else this .paramss
1516
+ val rawParamss1 = if rawParamss != null then rawParamss else this .rawParamss
1479
1517
val d = ctx.SymDenotation (symbol, owner, name, initFlags1, info1, privateWithin1)
1480
1518
d.annotations = annotations1
1481
- d.paramss = paramss1
1519
+ d.rawParamss = rawParamss1
1482
1520
d.registeredCompanion = registeredCompanion
1483
1521
d
1484
1522
}
0 commit comments