@@ -328,21 +328,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
328
328
superArgs : List [Tree ] = Nil , adaptVarargs : Boolean = false )(using Context ): TypeDef =
329
329
val firstParent :: otherParents = cls.info.parents: @ unchecked
330
330
331
- def isApplicable (constr : Symbol ): Boolean =
332
- def recur (ctpe : Type ): Boolean = ctpe match
333
- case ctpe : PolyType =>
334
- recur(ctpe.instantiate(firstParent.argTypes))
335
- case ctpe : MethodType =>
336
- var paramInfos = ctpe.paramInfos
337
- if adaptVarargs && paramInfos.length == superArgs.length + 1
338
- && atPhaseNoLater(Phases .elimRepeatedPhase)(constr.info.isVarArgsMethod)
339
- then // accept missing argument for varargs parameter
340
- paramInfos = paramInfos.init
341
- superArgs.corresponds(paramInfos)(_.tpe <:< _)
342
- case _ =>
343
- false
344
- recur(constr.info)
345
-
346
331
def adaptedSuperArgs (ctpe : Type ): List [Tree ] = ctpe match
347
332
case ctpe : PolyType =>
348
333
adaptedSuperArgs(ctpe.instantiate(firstParent.argTypes))
@@ -357,8 +342,11 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
357
342
val superRef =
358
343
if cls.is(Trait ) then TypeTree (firstParent)
359
344
else
360
- val constr = firstParent.decl(nme.CONSTRUCTOR ).suchThat(isApplicable)
361
- New (firstParent, constr.symbol.asTerm, adaptedSuperArgs(constr.info))
345
+ val parentConstr = firstParent.applicableConstructors(superArgs.tpes, adaptVarargs) match
346
+ case Nil => assert(false , i " no applicable parent constructor of $firstParent for supercall arguments $superArgs" )
347
+ case constr :: Nil => constr
348
+ case _ => assert(false , i " multiple applicable parent constructors of $firstParent for supercall arguments $superArgs" )
349
+ New (firstParent, parentConstr.asTerm, adaptedSuperArgs(parentConstr.info))
362
350
363
351
ClassDefWithParents (cls, constr, superRef :: otherParents.map(TypeTree (_)), body)
364
352
end ClassDef
0 commit comments