@@ -1407,32 +1407,13 @@ object SymDenotations {
1407
1407
baseData._2
1408
1408
1409
1409
def computeBaseData (implicit onBehalf : BaseData , ctx : Context ): (List [ClassSymbol ], BaseClassSet ) = {
1410
- val seen = new BaseClassSetBuilder
1411
- def addBaseClasses (bcs : List [ClassSymbol ], to : List [ClassSymbol ])
1412
- : List [ClassSymbol ] = bcs match {
1413
- case bc :: bcs1 =>
1414
- val bcs1added = addBaseClasses(bcs1, to)
1415
- if (seen contains bc) bcs1added
1416
- else {
1417
- seen.add(bc)
1418
- bc :: bcs1added
1419
- }
1420
- case nil =>
1421
- to
1422
- }
1423
- def addParentBaseClasses (ps : List [TypeRef ], to : List [ClassSymbol ]): List [ClassSymbol ] = ps match {
1424
- case p :: ps1 =>
1425
- addParentBaseClasses(ps1,
1426
- addBaseClasses(p.symbol.asClass.baseClasses, to))
1427
- case nil =>
1428
- to
1429
- }
1430
1410
def emptyParentsExpected =
1431
1411
is(Package ) || (symbol == defn.AnyClass ) || ctx.erasedTypes && (symbol == defn.ObjectClass )
1432
1412
if (classParents.isEmpty && ! emptyParentsExpected)
1433
1413
onBehalf.signalProvisional()
1434
- (classSymbol :: addParentBaseClasses(classParents, Nil ),
1435
- seen.result)
1414
+ val builder = new BaseDataBuilder
1415
+ for (p <- classParents) builder.addAll(p.symbol.asClass.baseClasses)
1416
+ (classSymbol :: builder.baseClasses, builder.baseClassSet)
1436
1417
}
1437
1418
1438
1419
final override def derivesFrom (base : Symbol )(implicit ctx : Context ): Boolean =
@@ -2096,7 +2077,9 @@ object SymDenotations {
2096
2077
def contains (sym : Symbol ): Boolean = contains(sym, classIds.length)
2097
2078
}
2098
2079
2099
- private class BaseClassSetBuilder {
2080
+ /** A class to combine base data from parent types */
2081
+ class BaseDataBuilder {
2082
+ private var classes : List [ClassSymbol ] = Nil
2100
2083
private var classIds = new Array [Int ](32 )
2101
2084
private var length = 0
2102
2085
@@ -2106,19 +2089,34 @@ object SymDenotations {
2106
2089
classIds = classIds1
2107
2090
}
2108
2091
2109
- def contains (sym : Symbol ): Boolean =
2092
+ private def contains (sym : Symbol ): Boolean =
2110
2093
new BaseClassSet (classIds).contains(sym, length)
2111
2094
2112
- def add (sym : Symbol ): Unit = {
2095
+ private def add (sym : Symbol ): Unit = {
2113
2096
if (length == classIds.length) resize(length * 2 )
2114
2097
classIds(length) = sym.id
2115
2098
length += 1
2116
2099
}
2117
2100
2118
- def result = {
2101
+ def addAll (bcs : List [ClassSymbol ]): this .type = {
2102
+ bcs match {
2103
+ case bc :: bcs1 =>
2104
+ addAll(bcs1)
2105
+ if (! contains(bc)) {
2106
+ add(bc)
2107
+ classes = bc :: classes
2108
+ }
2109
+ case nil =>
2110
+ }
2111
+ this
2112
+ }
2113
+
2114
+ def baseClassSet = {
2119
2115
if (length != classIds.length) resize(length)
2120
2116
new BaseClassSet (classIds)
2121
2117
}
2118
+
2119
+ def baseClasses : List [ClassSymbol ] = classes
2122
2120
}
2123
2121
2124
2122
@ sharable private var indent = 0 // for completions printing
0 commit comments