Skip to content

Commit 837afec

Browse files
committed
Better fix: Fix parents of tuple classes
We inserted the :* class not in the correct place, so the linearizations of Tuple1..Tuple22 were messed up.
1 parent c0db02c commit 837afec

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,11 +1620,11 @@ class Definitions {
16201620

16211621
/** If `cls` is Tuple1..Tuple22, add the corresponding *: type as last parent to `parents` */
16221622
def adjustForTuple(cls: ClassSymbol, tparams: List[TypeSymbol], parents: List[Type]): List[Type] = {
1623-
def syntheticParent(tparams: List[TypeSymbol]): Type =
1624-
if (tparams.isEmpty) TupleTypeRef
1625-
else TypeOps.nestedPairs(tparams.map(_.typeRef))
1626-
if (isTupleClass(cls)) parents :+ syntheticParent(tparams)
1627-
else parents
1623+
if !isTupleClass(cls) then parents
1624+
else if tparams.isEmpty then parents :+ TupleTypeRef
1625+
else
1626+
assert(parents.head.typeSymbol == ObjectClass)
1627+
TypeOps.nestedPairs(tparams.map(_.typeRef)) :: parents.tail
16281628
}
16291629

16301630
/** If it is BoxedUnit, remove `java.io.Serializable` from `parents`. */

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,7 @@ object TypeOps:
349349
val doms = dominators(commonBaseClasses, Nil)
350350
def baseTp(cls: ClassSymbol): Type =
351351
tp.baseType(cls).mapReduceOr(identity)(mergeRefinedOrApplied)
352-
def meet(tp1: Type, tp2: Type) =
353-
if !tp1.exists then tp2
354-
else if !tp2.exists then tp1
355-
else AndType(tp1, tp2)
356-
doms.map(baseTp).reduceLeft(meet)
352+
doms.map(baseTp).reduceLeft(AndType.apply)
357353
}
358354

359355
tp match {

0 commit comments

Comments
 (0)