@@ -376,17 +376,55 @@ object SymDenotations {
376376 /** If this is a method, the parameter symbols, by section.
377377 * Both type and value parameters are included. Empty sections are skipped.
378378 */
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 =
381381 myParamss = pss
382382
383383 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)
385385 .filterConserve(! _.isEmpty)
386386
387387 final def setParamssFromDefs (tparams : List [TypeDef [? ]], vparamss : List [List [ValDef [? ]]])(using Context ): Unit =
388388 setParamss(tparams.map(_.symbol), vparamss.map(_.map(_.symbol)))
389389
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+
390428 /** The denotation is completed: info is not a lazy type and attributes have defined values */
391429 final def isCompleted : Boolean = ! myInfo.isInstanceOf [LazyType ]
392430
@@ -1466,7 +1504,7 @@ object SymDenotations {
14661504 info : Type = null ,
14671505 privateWithin : Symbol = null ,
14681506 annotations : List [Annotation ] = null ,
1469- paramss : List [List [Symbol ]] = null )(
1507+ rawParamss : List [List [Symbol ]] = null )(
14701508 using ctx : Context ): SymDenotation = {
14711509 // simulate default parameters, while also passing implicit context ctx to the default values
14721510 val initFlags1 = (if (initFlags != UndefinedFlags ) initFlags else this .flags)
@@ -1475,10 +1513,10 @@ object SymDenotations {
14751513 assert(ctx.phase.changesParents, i " undeclared parent change at ${ctx.phase} for $this, was: $info, now: $info1" )
14761514 val privateWithin1 = if (privateWithin != null ) privateWithin else this .privateWithin
14771515 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
14791517 val d = ctx.SymDenotation (symbol, owner, name, initFlags1, info1, privateWithin1)
14801518 d.annotations = annotations1
1481- d.paramss = paramss1
1519+ d.rawParamss = rawParamss1
14821520 d.registeredCompanion = registeredCompanion
14831521 d
14841522 }
0 commit comments