@@ -1504,7 +1504,6 @@ class Namer { typer: Typer =>
15041504 if ptype.typeParams.isEmpty
15051505 // && !ptype.dealias.typeSymbol.primaryConstructor.info.finalResultType.isInstanceOf[RefinedType]
15061506 && ! ptype.dealias.typeSymbol.is(Dependent )
1507- || ctx.erasedTypes
15081507 then
15091508 ptype
15101509 else
@@ -1613,46 +1612,12 @@ class Namer { typer: Typer =>
16131612 /** The refinements coming from all parent class constructor applications */
16141613 val parentRefinements = mutable.LinkedHashMap [Name , Type ]()
16151614
1616- /** Split refinements off parent type and add them to `parentRefinements` */
1617- def separateRefinements (tp : Type ): Type = tp match
1618- case RefinedType (tp1, rname, rinfo) =>
1619- try separateRefinements(tp1)
1620- finally
1621- parentRefinements(rname) = parentRefinements.get(rname) match
1622- case Some (tp) => tp & rinfo
1623- case None => rinfo
1624- case tp => tp
1625-
1626- /** Add all parent refinements to the result type of the `info` of
1627- * the class constructor. Parent refinements refer to parameter accessors
1628- * in the current class. These have to be mapped to the paramRefs of the
1629- * constructor info.
1630- * @param info The (remaining part) of the constructor info
1631- * @param nameToParamRef The map from parameter names to paramRefs of
1632- * previously encountered parts of `info`.
1633- */
1634- def integrateParentRefinements (info : Type , nameToParamRef : Map [Name , Type ]): Type = info match
1635- case info : MethodOrPoly =>
1636- info.derivedLambdaType(resType =
1637- integrateParentRefinements(info.resType,
1638- nameToParamRef ++ info.paramNames.zip(info.paramRefs)))
1639- case _ =>
1640- val mapParams = new TypeMap :
1641- def apply (t : Type ) = t match
1642- case t : TermRef if t.symbol.is(ParamAccessor ) && t.symbol.owner == cls =>
1643- nameToParamRef(t.name)
1644- case _ =>
1645- mapOver(t)
1646- parentRefinements.foldLeft(info): (info, refinement) =>
1647- val (rname, rinfo) = refinement
1648- RefinedType (info, rname, mapParams(rinfo))
1649-
16501615 val parentTypes =
16511616 defn.adjustForTuple(cls, cls.typeParams,
16521617 defn.adjustForBoxedUnit(cls,
16531618 addUsingTraits(
16541619 ensureFirstIsClass(cls, parents.map(checkedParentType(_)))
1655- ))).map(separateRefinements)
1620+ ))).map(_. separateRefinements(parentRefinements) )
16561621
16571622 typr.println(i " completing $denot, parents = $parents%, %, stripped parent types = $parentTypes%, % " )
16581623 typr.println(i " constr type = ${cls.primaryConstructor.infoOrCompleter}, refinements = ${parentRefinements.toList}" )
@@ -1671,8 +1636,7 @@ class Namer { typer: Typer =>
16711636 tempInfo = null // The temporary info can now be garbage-collected
16721637
16731638 if parentRefinements.nonEmpty then
1674- val constr = cls.primaryConstructor
1675- constr.info = integrateParentRefinements(constr.info, Map ())
1639+ integrateParentRefinements(cls.primaryConstructor, parentRefinements)
16761640 cls.setFlag(Dependent )
16771641 Checking .checkWellFormed(cls)
16781642 if (isDerivedValueClass(cls)) cls.setFlag(Final )
0 commit comments