@@ -939,7 +939,8 @@ class Definitions {
939939 def scalaClassName (ref : Type )(implicit ctx : Context ): TypeName = scalaClassName(ref.classSymbol)
940940
941941 private def isVarArityClass (cls : Symbol , prefix : String ) =
942- scalaClassName(cls).testSimple(name =>
942+ cls.isClass && cls.owner.eq(ScalaPackageClass ) &&
943+ cls.name.testSimple(name =>
943944 name.startsWith(prefix) &&
944945 name.length > prefix.length &&
945946 name.drop(prefix.length).forall(_.isDigit))
@@ -1159,6 +1160,14 @@ class Definitions {
11591160 def isAssuredNoInits (sym : Symbol ) =
11601161 (sym `eq` SomeClass ) || isTupleClass(sym)
11611162
1163+ /** If `cls` is Tuple1..Tuple22, add the corresponding *: type as last parent to `parents` */
1164+ def adjustForTuple (cls : ClassSymbol , tparams : List [TypeSymbol ], parents : List [Type ]): List [Type ] = {
1165+ def syntheticParent (tparams : List [TypeSymbol ]): Type =
1166+ if (tparams.isEmpty) TupleTypeRef
1167+ else (tparams :\ (UnitType : Type )) ((tparam, tail) => PairType .appliedTo(tparam.typeRef, tail))
1168+ if (isTupleClass(cls) || cls == UnitClass ) parents :+ syntheticParent(tparams) else parents
1169+ }
1170+
11621171 // ----- primitive value class machinery ------------------------------------------
11631172
11641173 /** This class would also be obviated by the implicit function type design */
@@ -1260,27 +1269,6 @@ class Definitions {
12601269
12611270 private [this ] var isInitialized = false
12621271
1263- /** Add a `Tuple` as a parent to `Unit`.
1264- * Add the right `*:` instance as a parent to Tuple1..Tuple22
1265- */
1266- def fixTupleCompleter (cls : ClassSymbol ): Unit = cls.infoOrCompleter match {
1267- case completer : LazyType =>
1268- cls.info = new LazyType {
1269- def syntheticParent (tparams : List [TypeSymbol ]): Type =
1270- if (tparams.isEmpty) TupleTypeRef
1271- else (tparams :\ (UnitType : Type )) ((tparam, tail) => PairType .appliedTo(tparam.typeRef, tail))
1272- override def complete (denot : SymDenotation )(implicit ctx : Context ) = {
1273- completer.complete(denot)
1274- denot.info match {
1275- case info : ClassInfo =>
1276- denot.info = info.derivedClassInfo(
1277- classParents = info.classParents :+ syntheticParent(cls.typeParams))
1278- }
1279- }
1280- }
1281- case _ =>
1282- }
1283-
12841272 def init ()(implicit ctx : Context ) = {
12851273 this .ctx = ctx
12861274 if (! isInitialized) {
@@ -1298,10 +1286,6 @@ class Definitions {
12981286 // force initialization of every symbol that is synthesized or hijacked by the compiler
12991287 val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses ()
13001288
1301- fixTupleCompleter(UnitClass )
1302- for (i <- 1 to MaxTupleArity )
1303- fixTupleCompleter(TupleType (i).symbol.asClass)
1304-
13051289 isInitialized = true
13061290 }
13071291 }
0 commit comments