Skip to content

Commit fe73b0b

Browse files
committed
Apply changes of code review
1 parent 24ebd19 commit fe73b0b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -786,32 +786,29 @@ object RefChecks {
786786
//
787787
// In particular, it checks that there are no two base classes with
788788
// different type instantiations.
789-
//
790-
// ported from Scala 2:
791-
// https://github.com/scala/scala/blob/9bb659e62a9239c01aec14c171f8598bb1a576fe/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala#L834-L883
792789
def validateBaseTypes(): Unit = {
793790
val tpe = clazz.thisType // in Scala 2 this was clazz.tpe
794791
val seenParents = mutable.HashSet[Type]()
795792
val baseClasses: List[ClassSymbol] = clazz.info.baseClasses
796793

797794
// tracks types that we have seen for a particular base class in baseClasses
798-
val seenTypes = mutable.Map.empty[Symbol, List[Type]]
795+
val seenTypes = MutableSymbolMap[List[Type]](baseClasses.size)
799796

800797
// validate all base types of a class in reverse linear order.
801798
def register(tp: Type): Unit = {
802-
val baseClass = tp.typeSymbol
799+
val baseClass = tp.classSymbol
803800
if (baseClasses contains baseClass) {
804801
val alreadySeen = seenTypes.getOrElse(baseClass, Nil)
805-
if (alreadySeen.forall { tp1 => !(tp1 <:< tp) })
806-
seenTypes.update(baseClass, tp :: alreadySeen.filter { tp1 => !(tp <:< tp1) })
802+
if (!alreadySeen.exists(_ <:< tp))
803+
seenTypes.update(baseClass, tp :: alreadySeen.filterNot(tp <:< _))
807804
}
808805
val remaining = tp.parents filterNot seenParents
809806
seenParents ++= remaining
810807
remaining foreach register
811808
}
812809
register(tpe)
813810

814-
seenTypes.foreach {
811+
seenTypes.iterator.foreach {
815812
case (cls, Nil) =>
816813
assert(false) // this case should not be reachable
817814
case (cls, _ :: Nil) =>

0 commit comments

Comments
 (0)