Skip to content

Commit b4dc2d6

Browse files
committed
Make tpd.ClassDef work for polymorphic parent classes.
The handling of the first parent of ClassDef was broken if that parent had type parameters. This was exposed by following commites which use ClassDef more intensively than before in creating anonymous classes representing closures.
1 parent 199c661 commit b4dc2d6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
209209
ta.assignType(untpd.TypeDef(sym.name, TypeTree(sym.info)), sym)
210210

211211
def ClassDef(cls: ClassSymbol, constr: DefDef, body: List[Tree], superArgs: List[Tree] = Nil)(implicit ctx: Context): TypeDef = {
212-
val firstParent :: otherParents = cls.info.parents
212+
val firstParentRef :: otherParentRefs = cls.info.parents
213+
val firstParent = cls.typeRef.baseTypeWithArgs(firstParentRef.symbol)
213214
val superRef =
214215
if (cls is Trait) TypeTree(firstParent)
215216
else {
@@ -224,7 +225,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
224225
val constr = firstParent.decl(nme.CONSTRUCTOR).suchThat(constr => isApplicable(constr.info))
225226
New(firstParent, constr.symbol.asTerm, superArgs)
226227
}
227-
val parents = superRef :: otherParents.map(TypeTree(_))
228+
val parents = superRef :: otherParentRefs.map(TypeTree(_))
228229

229230
val selfType =
230231
if (cls.classInfo.selfInfo ne NoType) ValDef(ctx.newSelfSym(cls))

0 commit comments

Comments
 (0)