@@ -93,18 +93,16 @@ object RefChecks {
93
93
/** Check that self type of this class conforms to self types of parents.
94
94
* and required classes.
95
95
*/
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 {
97
97
case cinfo : ClassInfo =>
98
98
def checkSelfConforms (other : ClassSymbol , category : String , relation : String ) = {
99
99
val otherSelf = other.givenSelfType.asSeenFrom(cls.thisType, other.classSymbol)
100
100
if (otherSelf.exists && ! (cinfo.selfType <:< otherSelf))
101
101
ctx.error(DoesNotConformToSelfType (category, cinfo.selfType, cls, otherSelf, relation, other.classSymbol),
102
102
cls.pos)
103
103
}
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" )
108
106
for (reqd <- cinfo.cls.givenSelfType.classSymbols)
109
107
checkSelfConforms(reqd, " missing requirement" , " required" )
110
108
case _ =>
@@ -119,7 +117,7 @@ object RefChecks {
119
117
parent.tpe.typeConstructor match {
120
118
case TypeRef (ref : TermRef , _) =>
121
119
val paramRefs = ref.namedPartsWith(ntp => ntp.symbol.enclosingClass == cls)
122
- if (paramRefs.nonEmpty && cls.is( Trait ) )
120
+ if (paramRefs.nonEmpty)
123
121
ctx.error(" trait parameters cannot be used as parent prefixes" , parent.pos)
124
122
case _ =>
125
123
}
@@ -976,7 +974,8 @@ class RefChecks extends MiniPhase { thisPhase =>
976
974
override def transformTemplate (tree : Template )(implicit ctx : Context ) = try {
977
975
val cls = ctx.owner
978
976
checkOverloadedRestrictions(cls)
979
- checkParents(cls, tree)
977
+ checkParents(cls)
978
+ if (cls.is(Trait )) tree.parents.foreach(checkParentPrefix(cls, _))
980
979
checkCompanionNameClashes(cls)
981
980
checkAllOverrides(cls)
982
981
tree
0 commit comments