Skip to content

Commit 35083fd

Browse files
committed
Address review
1 parent 87f1d9c commit 35083fd

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,16 @@ object RefChecks {
9393
/** Check that self type of this class conforms to self types of parents.
9494
* and required classes.
9595
*/
96-
private def checkParents(cls: Symbol, tmpl: Template)(implicit ctx: Context): Unit = cls.info match {
96+
private def checkParents(cls: Symbol)(implicit ctx: Context): Unit = cls.info match {
9797
case cinfo: ClassInfo =>
9898
def checkSelfConforms(other: ClassSymbol, category: String, relation: String) = {
9999
val otherSelf = other.givenSelfType.asSeenFrom(cls.thisType, other.classSymbol)
100100
if (otherSelf.exists && !(cinfo.selfType <:< otherSelf))
101101
ctx.error(DoesNotConformToSelfType(category, cinfo.selfType, cls, otherSelf, relation, other.classSymbol),
102102
cls.pos)
103103
}
104-
for (parent <- tmpl.parents) {
105-
checkSelfConforms(parent.tpe.classSymbol.asClass, "illegal inheritance", "parent")
106-
checkParentPrefix(cls, parent)
107-
}
104+
for (parent <- cinfo.classParents)
105+
checkSelfConforms(parent.classSymbol.asClass, "illegal inheritance", "parent")
108106
for (reqd <- cinfo.cls.givenSelfType.classSymbols)
109107
checkSelfConforms(reqd, "missing requirement", "required")
110108
case _ =>
@@ -119,7 +117,7 @@ object RefChecks {
119117
parent.tpe.typeConstructor match {
120118
case TypeRef(ref: TermRef, _) =>
121119
val paramRefs = ref.namedPartsWith(ntp => ntp.symbol.enclosingClass == cls)
122-
if (paramRefs.nonEmpty && cls.is(Trait))
120+
if (paramRefs.nonEmpty)
123121
ctx.error("trait parameters cannot be used as parent prefixes", parent.pos)
124122
case _ =>
125123
}
@@ -976,7 +974,8 @@ class RefChecks extends MiniPhase { thisPhase =>
976974
override def transformTemplate(tree: Template)(implicit ctx: Context) = try {
977975
val cls = ctx.owner
978976
checkOverloadedRestrictions(cls)
979-
checkParents(cls, tree)
977+
checkParents(cls)
978+
if (cls.is(Trait)) tree.parents.foreach(checkParentPrefix(cls, _))
980979
checkCompanionNameClashes(cls)
981980
checkAllOverrides(cls)
982981
tree

0 commit comments

Comments
 (0)