diff --git a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Apply.scala b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Apply.scala index a874330e3a0e..2bcde1ac6992 100644 --- a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Apply.scala +++ b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Apply.scala @@ -13,7 +13,7 @@ class Apply { def setup(): Unit = { val size = sizeAndIndex.split(' ')(0).toInt index = sizeAndIndex.split(' ')(1).toInt - tuple = "elem" *: () + tuple = "elem" *: Tuple() for (i <- 1 until size) tuple = "elem" *: tuple diff --git a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Concat.scala b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Concat.scala index 70e5f84d0bb0..4f8345909fe0 100644 --- a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Concat.scala +++ b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Concat.scala @@ -11,7 +11,7 @@ class Concat { var tuple2: Tuple = _ def tupleOfSize(n: Int): Tuple = { - var t: Tuple = () + var t: Tuple = Tuple() for (i <- 1 to n) t = "elem" *: t t diff --git a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Cons.scala b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Cons.scala index b2a98014728f..e7f91bfc5c18 100644 --- a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Cons.scala +++ b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Cons.scala @@ -12,7 +12,7 @@ class Cons { @Setup def setup(): Unit = { - tuple = () + tuple = Tuple() for (i <- 1 to size) tuple = "elem" *: tuple diff --git a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Conversions.scala b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Conversions.scala index 7322ac220156..e44c8a3072b4 100644 --- a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Conversions.scala +++ b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Conversions.scala @@ -12,7 +12,7 @@ class Conversions { @Setup def setup(): Unit = { - tuple = () + tuple = Tuple() for (i <- 1 to size) tuple = "elem" *: tuple diff --git a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Map.scala b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Map.scala index 317de969736e..41418e2bf48b 100644 --- a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Map.scala +++ b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Map.scala @@ -11,7 +11,7 @@ class Map { @Setup def setup(): Unit = { - tuple = () + tuple = Tuple() for (i <- 1 to size) tuple = "elem" *: tuple diff --git a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Tail.scala b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Tail.scala index 88acf9f174ee..4ce39c464bab 100644 --- a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Tail.scala +++ b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Tail.scala @@ -11,7 +11,7 @@ class Tail { @Setup def setup(): Unit = { - tuple = "elem" *: () + tuple = "elem" *: Tuple() for (i <- 1 until size) tuple = "elem" *: tuple diff --git a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/TupleOps.scala b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/TupleOps.scala index 1acec8691165..fa6fb63e73ad 100644 --- a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/TupleOps.scala +++ b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/TupleOps.scala @@ -11,11 +11,11 @@ class TupleOps { @Setup def setup(): Unit = { - tuple1 = () + tuple1 = Tuple() for (i <- 1 until 15) tuple1 = s"elem$i" *: tuple1 - tuple2 = () + tuple2 = Tuple() for (i <- 1 until 10) tuple2 = s"elem$i" *: tuple2 @@ -25,23 +25,23 @@ class TupleOps { def tupleFlatMap(tuple: Tuple, f: [A] => A => Tuple): Tuple = { def tailRecFlatMap(t: Tuple, acc: Tuple): Tuple = t match { - case () => acc + case Tuple() => acc case x *: rest => tailRecFlatMap(rest, acc ++ f(x)) } - tailRecFlatMap(tuple, ()) + tailRecFlatMap(tuple, Tuple()) } def tupleReverse(tuple: Tuple): Tuple = { def tailRecReverse(t: Tuple, acc: Tuple): Tuple = t match { - case () => acc + case Tuple() => acc case x *: rest => tailRecReverse(rest, x *: acc) } - tailRecReverse(tuple, ()) + tailRecReverse(tuple, Tuple()) } def tupleMerge(tuple1: Tuple, tuple2: Tuple): Tuple = (tuple1, tuple2) match { - case (_, ()) => tuple1 - case ((), _) => tuple2 + case (_, Tuple()) => tuple1 + case (Tuple(), _) => tuple2 case (x *: xs, y *: ys) => if (x.asInstanceOf[Int] <= y.asInstanceOf[Int]) x *: tupleMerge(xs, tuple2) else y *: tupleMerge(tuple1, ys) diff --git a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Zip.scala b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Zip.scala index d92e8666102b..1ad79ab42079 100644 --- a/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Zip.scala +++ b/bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Zip.scala @@ -13,8 +13,8 @@ class Zip { @Setup def setup(): Unit = { - tuple1 = () - tuple2 = () + tuple1 = Tuple() + tuple2 = Tuple() for (i <- 1 to size) { tuple1 = "el" *: tuple1 diff --git a/bench-run/src/main/scala/tuples/Drop.scala b/bench-run/src/main/scala/tuples/Drop.scala index bfeab387ca09..f5fcfcdd803c 100644 --- a/bench-run/src/main/scala/tuples/Drop.scala +++ b/bench-run/src/main/scala/tuples/Drop.scala @@ -12,7 +12,7 @@ class Drop { @Setup def setup(): Unit = { - tuple = () + tuple = Tuple() half = size / 2 for (i <- 1 to size) diff --git a/bench-run/src/main/scala/tuples/Split.scala b/bench-run/src/main/scala/tuples/Split.scala index a63e061f0bc6..b3b182ec87a7 100644 --- a/bench-run/src/main/scala/tuples/Split.scala +++ b/bench-run/src/main/scala/tuples/Split.scala @@ -12,7 +12,7 @@ class Split { @Setup def setup(): Unit = { - tuple = () + tuple = Tuple() half = size / 2 for (i <- 1 to size) diff --git a/bench-run/src/main/scala/tuples/Take.scala b/bench-run/src/main/scala/tuples/Take.scala index 1d81201aed82..12205e21d71c 100644 --- a/bench-run/src/main/scala/tuples/Take.scala +++ b/bench-run/src/main/scala/tuples/Take.scala @@ -12,7 +12,7 @@ class Take { @Setup def setup(): Unit = { - tuple = () + tuple = Tuple() half = size / 2 for (i <- 1 to size) diff --git a/community-build/community-projects/scodec b/community-build/community-projects/scodec index b26aef8d1c92..154d11c4cf94 160000 --- a/community-build/community-projects/scodec +++ b/community-build/community-projects/scodec @@ -1 +1 @@ -Subproject commit b26aef8d1c92bf1a75349065a087c53a4536c739 +Subproject commit 154d11c4cf9494c7ef838411d20eb0d443a0a4e6 diff --git a/community-build/community-projects/shapeless b/community-build/community-projects/shapeless index 44752eff2865..5435ceb5993e 160000 --- a/community-build/community-projects/shapeless +++ b/community-build/community-projects/shapeless @@ -1 +1 @@ -Subproject commit 44752eff286570e4cfc2a29f47557d2f09ef8489 +Subproject commit 5435ceb5993e4cbfff5ffd167d9ede56232008f7 diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 6ecb02a87e74..c23f81fb465a 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -1337,7 +1337,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { /** Creates the nested pairs type tree repesentation of the type trees in `ts` */ def nestedPairsTypeTree(ts: List[Tree])(implicit ctx: Context): Tree = - ts.foldRight[Tree](TypeTree(defn.UnitType))((x, acc) => AppliedTypeTree(TypeTree(defn.PairClass.typeRef), x :: acc :: Nil)) + ts.foldRight[Tree](TypeTree(defn.EmptyTupleModule.termRef))((x, acc) => AppliedTypeTree(TypeTree(defn.PairClass.typeRef), x :: acc :: Nil)) /** Replaces all positions in `tree` with zero-extent positions */ private def focusPositions(tree: Tree)(implicit ctx: Context): Tree = { diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 6dba2ed925c4..ec7fee0fb780 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -749,11 +749,12 @@ class Definitions { @tu lazy val TupleTypeRef: TypeRef = ctx.requiredClassRef("scala.Tuple") def TupleClass(implicit ctx: Context): ClassSymbol = TupleTypeRef.symbol.asClass @tu lazy val Tuple_cons: Symbol = TupleClass.requiredMethod("*:") + @tu lazy val EmptyTupleModule: Symbol = ctx.requiredModule("scala.EmptyTuple") @tu lazy val NonEmptyTupleTypeRef: TypeRef = ctx.requiredClassRef("scala.NonEmptyTuple") def NonEmptyTupleClass(implicit ctx: Context): ClassSymbol = NonEmptyTupleTypeRef.symbol.asClass lazy val NonEmptyTuple_tail: Symbol = NonEmptyTupleClass.requiredMethod("tail") - @tu lazy val PairClass: ClassSymbol = ctx.requiredClass("scala.*:") + @tu lazy val TupleXXLClass: ClassSymbol = ctx.requiredClass("scala.runtime.TupleXXL") def TupleXXLModule(implicit ctx: Context): Symbol = TupleXXLClass.companionModule @@ -770,6 +771,9 @@ class Definitions { lazy val RuntimeTuple_concat: Symbol = RuntimeTupleModule.requiredMethod("concat") lazy val RuntimeTuple_toArray: Symbol = RuntimeTupleModule.requiredMethod("toArray") lazy val RuntimeTuple_productToArray: Symbol = RuntimeTupleModule.requiredMethod("productToArray") + lazy val RuntimeTuple_isInstanceOfTuple: Symbol = RuntimeTupleModule.requiredMethod("isInstanceOfTuple") + lazy val RuntimeTuple_isInstanceOfEmptyTuple: Symbol = RuntimeTupleModule.requiredMethod("isInstanceOfEmptyTuple") + lazy val RuntimeTuple_isInstanceOfNonEmptyTuple: Symbol = RuntimeTupleModule.requiredMethod("isInstanceOfNonEmptyTuple") @tu lazy val TupledFunctionTypeRef: TypeRef = ctx.requiredClassRef("scala.TupledFunction") def TupledFunctionClass(implicit ctx: Context): ClassSymbol = TupledFunctionTypeRef.symbol.asClass @@ -1185,11 +1189,11 @@ class Definitions { } def tupleTypes(tp: Type, bound: Int = Int.MaxValue)(implicit ctx: Context): Option[List[Type]] = { - @tailrec def rec(tp: Type, acc: List[Type], bound: Int): Option[List[Type]] = tp.normalized match { + @tailrec def rec(tp: Type, acc: List[Type], bound: Int): Option[List[Type]] = tp.normalized.dealias match { case _ if bound < 0 => Some(acc.reverse) case tp: AppliedType if defn.PairClass == tp.classSymbol => rec(tp.args(1), tp.args.head :: acc, bound - 1) case tp: AppliedType if defn.isTupleClass(tp.tycon.classSymbol) => Some(acc.reverse ::: tp.args) - case tp if tp.classSymbol == defn.UnitClass => Some(acc.reverse) + case tp: TermRef if tp.symbol == defn.EmptyTupleModule => Some(acc.reverse) case _ => None } rec(tp.stripTypeVar, Nil, bound) @@ -1300,7 +1304,7 @@ class Definitions { def syntheticParent(tparams: List[TypeSymbol]): Type = if (tparams.isEmpty) TupleTypeRef else TypeOps.nestedPairs(tparams.map(_.typeRef)) - if (isTupleClass(cls) || cls == UnitClass) parents :+ syntheticParent(tparams) + if (isTupleClass(cls)) parents :+ syntheticParent(tparams) else parents } @@ -1397,7 +1401,7 @@ class Definitions { .updated(AnyClass, ObjectClass) .updated(AnyValClass, ObjectClass) .updated(SingletonClass, ObjectClass) - .updated(TupleClass, ObjectClass) + .updated(TupleClass, ProductClass) .updated(NonEmptyTupleClass, ProductClass) // ----- Initialization --------------------------------------------------- diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index 936016a44312..4f27c7883685 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -729,6 +729,6 @@ object TypeOps: } def nestedPairs(ts: List[Type])(using Context): Type = - ts.foldRight(defn.UnitType: Type)(defn.PairClass.typeRef.appliedTo(_, _)) + ts.foldRight(defn.EmptyTupleModule.termRef: Type)(defn.PairClass.typeRef.appliedTo(_, _)) end TypeOps diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala index 4f095fa12baa..b4f566d2c7c7 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala @@ -2005,7 +2005,10 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend def Definitions_NothingType: Type = defn.NothingType def Definitions_NullType: Type = defn.NullType def Definitions_StringType: Type = defn.StringType - + def Definitions_TupleType: Type = defn.TupleTypeRef + def Definitions_EmptyTupleType: Type = defn.EmptyTupleModule.termRef + def Definitions_NonEmptyTupleType: Type = defn.NonEmptyTupleClass.typeRef + def Definitions_TupleConsType: Type = defn.PairClass.typeRef /////////////// // IMPLICITS // diff --git a/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala b/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala index 06fe98a0cc51..b379b5dd5ce2 100644 --- a/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala +++ b/compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala @@ -69,8 +69,8 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { val size = tpes.size assert(size > 0) if (size == 1) - // () - Literal(Constant(())) + // scala.EmptyTuple + ref(defn.EmptyTupleModule.termRef) else if (size <= 5) // val t = tup.asInstanceOf[TupleN[...]] // TupleN-1(t._2, ..., t._n) @@ -197,8 +197,8 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer { private def knownTupleFromIterator(size: Int, it: Tree)(implicit ctx: Context): Tree = if (size == 0) - // Unit for empty tuple - Literal(Constant(())) // TODO should this code be here? Or assert(size > specializedSize) + // EmptyTuple for empty tuple + ref(defn.EmptyTupleModule.termRef) // TODO should this code be here? Or assert(size > specializedSize) else if (size <= MaxTupleArity) { // TupleN(it.next(), ..., it.next()) diff --git a/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala b/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala index 6efc4d8d70d0..ebb1a20c8430 100644 --- a/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala +++ b/compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala @@ -305,11 +305,17 @@ object TypeTestsCasts { * * expr.isInstanceOf[A | B] ~~> expr.isInstanceOf[A] | expr.isInstanceOf[B] * expr.isInstanceOf[A & B] ~~> expr.isInstanceOf[A] & expr.isInstanceOf[B] + * expr.isInstanceOf[Tuple] ~~> scala.runtime.Tuple.isInstanceOfTuple(expr) + * expr.isInstanceOf[EmptyTuple] ~~> scala.runtime.Tuple.isInstanceOfEmptyTuple(expr) + * expr.isInstanceOf[NonEmptyTuple] ~~> scala.runtime.Tuple.isInstanceOfNonEmptyTuple(expr) + * expr.isInstanceOf[*:[_, _]] ~~> scala.runtime.Tuple.isInstanceOfNonEmptyTuple(expr) * * The transform happens before erasure of `testType`, thus cannot be merged * with `transformIsInstanceOf`, which depends on erased type of `testType`. */ def transformTypeTest(expr: Tree, testType: Type, flagUnrelated: Boolean): Tree = testType.dealias match { + case tref: TermRef if tref.symbol == defn.EmptyTupleModule => + ref(defn.RuntimeTuple_isInstanceOfEmptyTuple).appliedTo(expr) case _: SingletonType => expr.isInstance(testType).withSpan(tree.span) case OrType(tp1, tp2) => @@ -330,6 +336,12 @@ object TypeTestsCasts { derivedTree(e, defn.Any_isInstanceOf, e.tpe) .and(isArrayTest(e)) } + case tref: TypeRef if tref.symbol == defn.TupleClass => + ref(defn.RuntimeTuple_isInstanceOfTuple).appliedTo(expr) + case tref: TypeRef if tref.symbol == defn.NonEmptyTupleClass => + ref(defn.RuntimeTuple_isInstanceOfNonEmptyTuple).appliedTo(expr) + case AppliedType(tref: TypeRef, _) if tref.symbol == defn.PairClass => + ref(defn.RuntimeTuple_isInstanceOfNonEmptyTuple).appliedTo(expr) case _ => transformIsInstanceOf(expr, erasure(testType), flagUnrelated) } diff --git a/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala b/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala index 8b1a74ae63f1..83648154af2c 100644 --- a/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/TypeUtils.scala @@ -31,27 +31,31 @@ object TypeUtils { case ps => ps.reduceLeft(AndType(_, _)) } - /** The arity of this tuple type, which can be made up of Unit, TupleX and `*:` pairs, + /** The arity of this tuple type, which can be made up of EmptyTuple, TupleX and `*:` pairs, * or -1 if this is not a tuple type. */ def tupleArity(implicit ctx: Context): Int = self match { case AppliedType(tycon, _ :: tl :: Nil) if tycon.isRef(defn.PairClass) => val arity = tl.tupleArity if (arity < 0) arity else arity + 1 - case tp1 => - if (tp1.isRef(defn.UnitClass)) 0 - else if (defn.isTupleClass(tp1.classSymbol)) tp1.dealias.argInfos.length - else -1 + case self: TermRef if self.symbol == defn.EmptyTupleModule => + 0 + case self if defn.isTupleClass(self.classSymbol) => + self.dealias.argInfos.length + case _ => + -1 } - /** The element types of this tuple type, which can be made up of Unit, TupleX and `*:` pairs */ + /** The element types of this tuple type, which can be made up of EmptyTuple, TupleX and `*:` pairs */ def tupleElementTypes(implicit ctx: Context): List[Type] = self match { case AppliedType(tycon, hd :: tl :: Nil) if tycon.isRef(defn.PairClass) => hd :: tl.tupleElementTypes - case tp1 => - if (tp1.isRef(defn.UnitClass)) Nil - else if (defn.isTupleClass(tp1.classSymbol)) tp1.dealias.argInfos - else throw new AssertionError("not a tuple") + case self: TermRef if self.symbol == defn.EmptyTupleModule => + Nil + case self if defn.isTupleClass(self.classSymbol) => + self.dealias.argInfos + case _ => + throw new AssertionError("not a tuple") } /** The `*:` equivalent of an instance of a Tuple class */ diff --git a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala index 4619bd980533..58ef38076324 100644 --- a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala +++ b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala @@ -432,7 +432,9 @@ trait QuotesAndSplices { } } - val splicePat = typed(untpd.Tuple(splices.map(x => untpd.TypedSplice(replaceBindingsInTree.transform(x)))).withSpan(quoted.span), patType) + val splicePat = + if splices.isEmpty then ref(defn.EmptyTupleModule.termRef) + else typed(untpd.Tuple(splices.map(x => untpd.TypedSplice(replaceBindingsInTree.transform(x)))).withSpan(quoted.span), patType) val unapplySym = if (tree.quoted.isTerm) defn.InternalQuotedExpr_unapply else defn.InternalQuotedType_unapply val quoteClass = if (tree.quoted.isTerm) defn.QuotedExprClass else defn.QuotedTypeClass diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index b89d878e03c1..bd74dab9818b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2309,7 +2309,7 @@ class Typer extends Namer else List.fill(arity)(defn.AnyType) val elems = tree.trees.lazyZip(pts).map(typed(_, _)) if (ctx.mode.is(Mode.Type)) - elems.foldRight(TypeTree(defn.UnitType): Tree)((elemTpt, elemTpts) => + elems.foldRight(TypeTree(defn.EmptyTupleModule.termRef): Tree)((elemTpt, elemTpts) => AppliedTypeTree(TypeTree(defn.PairClass.typeRef), List(elemTpt, elemTpts))) .withSpan(tree.span) else { diff --git a/library/src-bootstrapped/scala/Tuple.scala b/library/src-bootstrapped/scala/Tuple.scala index e01f46df318a..4219fc87ae83 100644 --- a/library/src-bootstrapped/scala/Tuple.scala +++ b/library/src-bootstrapped/scala/Tuple.scala @@ -4,7 +4,7 @@ import compiletime._ import internal._ /** Tuple of arbitrary arity */ -sealed trait Tuple extends Any { +sealed trait Tuple extends Product { import Tuple._ /** Create a copy this tuple as an Array */ @@ -35,7 +35,7 @@ sealed trait Tuple extends Any { * `((a1, b1), ..., (an, bn))`. If the two tuples have different sizes, * the extra elements of the larger tuple will be disregarded. * The result is typed as `((A1, B1), ..., (An, Bn))` if at least one of the - * tuple types has a `Unit` tail. Otherwise the result type is + * tuple types has a `EmptyTuple` tail. Otherwise the result type is * `(A1, B1) *: ... *: (Ai, Bi) *: Tuple` */ inline def zip[This >: this.type <: Tuple, T2 <: Tuple](t2: T2): Zip[This, T2] = @@ -84,7 +84,7 @@ object Tuple { /** Type of the concatenation of two tuples */ type Concat[X <: Tuple, +Y <: Tuple] <: Tuple = X match { - case Unit => Y + case EmptyTuple => Y case x1 *: xs1 => x1 *: Concat[xs1, Y] } @@ -99,32 +99,32 @@ object Tuple { /** Literal constant Int size of a tuple */ type Size[X <: Tuple] <: Int = X match { - case Unit => 0 + case EmptyTuple => 0 case x *: xs => S[Size[xs]] } /** Converts a tuple `(T1, ..., Tn)` to `(F[T1], ..., F[Tn])` */ type Map[Tup <: Tuple, F[_]] <: Tuple = Tup match { - case Unit => Unit + case EmptyTuple => EmptyTuple case h *: t => F[h] *: Map[t, F] } /** Given two tuples, `A1 *: ... *: An * At` and `B1 *: ... *: Bn *: Bt` - * where at least one of `At` or `Bt` is `Unit` or `Tuple`, + * where at least one of `At` or `Bt` is `EmptyTuple` or `Tuple`, * returns the tuple type `(A1, B1) *: ... *: (An, Bn) *: Ct` - * where `Ct` is `Unit` if `At` or `Bt` is `Unit`, otherwise `Ct` is `Tuple`. + * where `Ct` is `EmptyTuple` if `At` or `Bt` is `EmptyTuple`, otherwise `Ct` is `Tuple`. */ type Zip[T1 <: Tuple, T2 <: Tuple] <: Tuple = (T1, T2) match { case (h1 *: t1, h2 *: t2) => (h1, h2) *: Zip[t1, t2] - case (Unit, _) => Unit - case (_, Unit) => Unit + case (EmptyTuple, _) => EmptyTuple + case (_, EmptyTuple) => EmptyTuple case _ => Tuple } /** Converts a tuple `(F[T1], ..., F[Tn])` to `(T1, ... Tn)` */ type InverseMap[X <: Tuple, F[_]] <: Tuple = X match { case F[x] *: t => x *: InverseMap[t, F] - case Unit => Unit + case EmptyTuple => EmptyTuple } /** Implicit evidence. IsMappedBy[F][X] is present in the implicit scope iff @@ -136,9 +136,9 @@ object Tuple { /** Transforms a tuple `(T1, ..., Tn)` into `(T1, ..., Ti)`. */ type Take[T <: Tuple, N <: Int] <: Tuple = N match { - case 0 => Unit + case 0 => EmptyTuple case S[n1] => T match { - case Unit => Unit + case EmptyTuple => EmptyTuple case x *: xs => x *: Take[xs, n1] } } @@ -147,7 +147,7 @@ object Tuple { type Drop[T <: Tuple, N <: Int] <: Tuple = N match { case 0 => T case S[n1] => T match { - case Unit => Unit + case EmptyTuple => EmptyTuple case x *: xs => Drop[xs, n1] } } @@ -157,6 +157,15 @@ object Tuple { */ type Split[T <: Tuple, N <: Int] = (Take[T, N], Drop[T, N]) + /** Empty tuple */ + def apply(): EmptyTuple = EmptyTuple + + /** Tuple with one element */ + def apply[T](x: T): T *: EmptyTuple = Tuple1(x) + + /** Matches an empty tuple. */ + def unapply(x: EmptyTuple): true = true + /** Convert an array into a tuple of unknown arity and types */ def fromArray[T](xs: Array[T]): Tuple = { val xs2 = xs match { @@ -185,8 +194,17 @@ object Tuple { Tuple.fromArray(p.productIterator.toArray).asInstanceOf[m.MirroredElemTypes] // TODO use toIArray of Object to avoid double/triple array copy } +/** A tuple of 0 elements */ +type EmptyTuple = EmptyTuple.type + +/** A tuple of 0 elements; the canonical representation of a [[scala.Product0]]. */ +object EmptyTuple extends Tuple with Product0 { + def canEqual(that: Any): Boolean = this == that + override def toString(): String = "()" +} + /** Tuple of arbitrary non-zero arity */ -sealed trait NonEmptyTuple extends Tuple with Product { +sealed trait NonEmptyTuple extends Tuple { import Tuple._ /** Get the i-th element of this tuple. diff --git a/library/src-bootstrapped/scala/deriving.scala b/library/src-bootstrapped/scala/deriving.scala index 0e53fe037d8b..827285123d95 100644 --- a/library/src-bootstrapped/scala/deriving.scala +++ b/library/src-bootstrapped/scala/deriving.scala @@ -34,8 +34,8 @@ object deriving { trait Singleton extends Product { type MirroredMonoType = this.type type MirroredType = this.type - type MirroredElemTypes = Unit - type MirroredElemLabels = Unit + type MirroredElemTypes = EmptyTuple + type MirroredElemLabels = EmptyTuple def fromProduct(p: scala.Product) = this } @@ -43,8 +43,8 @@ object deriving { class SingletonProxy(val value: AnyRef) extends Product { type MirroredMonoType = value.type type MirroredType = value.type - type MirroredElemTypes = Unit - type MirroredElemLabels = Unit + type MirroredElemTypes = EmptyTuple + type MirroredElemLabels = EmptyTuple def fromProduct(p: scala.Product) = value } diff --git a/library/src/scala/internal/TupledFunction.scala b/library/src-bootstrapped/scala/internal/TupledFunction.scala similarity index 98% rename from library/src/scala/internal/TupledFunction.scala rename to library/src-bootstrapped/scala/internal/TupledFunction.scala index c31a6afd72d9..6c8a85d9586a 100644 --- a/library/src/scala/internal/TupledFunction.scala +++ b/library/src-bootstrapped/scala/internal/TupledFunction.scala @@ -6,8 +6,8 @@ import scala.runtime.TupleXXL object TupledFunction { def tupledFunction0[F, G]: TupledFunction[F, G] = scala.TupledFunction[F, G]( - tupledImpl = (f: F) => ((args: Unit) => f.asInstanceOf[() => Any].apply()).asInstanceOf[G], - untupledImpl = (g: G) => (() => g.asInstanceOf[Unit => Any].apply(())).asInstanceOf[F] + tupledImpl = (f: F) => ((args: EmptyTuple) => f.asInstanceOf[() => Any].apply()).asInstanceOf[G], + untupledImpl = (g: G) => (() => g.asInstanceOf[EmptyTuple => Any].apply(Tuple())).asInstanceOf[F] ) def tupledFunction1[F, G]: TupledFunction[F, G] = scala.TupledFunction[F, G]( diff --git a/library/src-bootstrapped/scala/quoted/Expr.scala b/library/src-bootstrapped/scala/quoted/Expr.scala index 1cf721bd9814..e40d45566c91 100644 --- a/library/src-bootstrapped/scala/quoted/Expr.scala +++ b/library/src-bootstrapped/scala/quoted/Expr.scala @@ -38,7 +38,7 @@ class Expr[+T] private[scala] { * ``` */ final def matches(that: Expr[Any])(using qctx: QuoteContext): Boolean = - !scala.internal.quoted.Expr.unapply[Unit, Unit](this)(using that, false, qctx).isEmpty + !scala.internal.quoted.Expr.unapply[EmptyTuple, EmptyTuple](this)(using that, false, qctx).isEmpty /** Checked cast to a `quoted.Expr[U]` */ def cast[U](using tp: scala.quoted.Type[U])(using qctx: QuoteContext): scala.quoted.Expr[U] = @@ -131,7 +131,7 @@ object Expr { def ofTuple(seq: Seq[Expr[Any]])(using qctx: QuoteContext): Expr[Tuple] = { seq match { case Seq() => - unitExpr + '{ Tuple() } case Seq('{ $x1: $t1 }) => '{ Tuple1($x1) } case Seq('{ $x1: $t1 }, '{ $x2: $t2 }) => diff --git a/library/src-bootstrapped/scala/runtime/Tuple.scala b/library/src-bootstrapped/scala/runtime/Tuple.scala index 895de0adcace..387539f77390 100644 --- a/library/src-bootstrapped/scala/runtime/Tuple.scala +++ b/library/src-bootstrapped/scala/runtime/Tuple.scala @@ -5,15 +5,15 @@ object Tuple { inline val MaxSpecialized = 22 def toArray(self: Tuple): Array[Object] = (self: Any) match { + case EmptyTuple => Array.emptyObjectArray case self: TupleXXL => self.toArray case self: Product => productToArray(self) - case self: Unit => Array.emptyObjectArray } def toIArray(self: Tuple): IArray[Object] = (self: Any) match { + case EmptyTuple => Array.emptyObjectArray.asInstanceOf[IArray[Object]] case self: TupleXXL => self.elems case self: Product => productToArray(self).asInstanceOf[IArray[Object]] - case self: Unit => Array.emptyObjectArray.asInstanceOf[IArray[Object]] } def productToArray(self: Product): Array[Object] = { @@ -27,7 +27,7 @@ object Tuple { } def fromArray(xs: Array[Object]): Tuple = xs.length match { - case 0 => () + case 0 => EmptyTuple case 1 => Tuple1(xs(0)) case 2 => Tuple2(xs(0), xs(1)) case 3 => Tuple3(xs(0), xs(1), xs(2)) @@ -178,7 +178,7 @@ object Tuple { // Cons for Tuple1 to Tuple22 private def specialCaseCons(x: Any, self: Tuple): Tuple = { (self: Any) match { - case self: Unit => + case EmptyTuple => Tuple1(x) case self: Tuple1[_] => Tuple2(x, self._1) @@ -267,7 +267,7 @@ object Tuple { case xxl: TupleXXL => System.arraycopy(xxl.elems, 0, array, offset, size) case _ => - tuple.asInstanceOf[Product].productIterator.asInstanceOf[Iterator[Object]] + tuple.productIterator.asInstanceOf[Iterator[Object]] .copyToArray(array, offset, size) } @@ -278,7 +278,7 @@ object Tuple { } def size(self: Tuple): Int = (self: Any) match { - case self: Unit => 0 + case EmptyTuple => 0 case self: Product => self.productArity } @@ -286,7 +286,7 @@ object Tuple { private def specialCaseTail(self: Tuple): Tuple = { (self: Any) match { case self: Tuple1[_] => - () + EmptyTuple case self: Tuple2[_, _] => Tuple1(self._2) case self: Tuple3[_, _, _] => @@ -354,12 +354,8 @@ object Tuple { case _ => specialCaseTail(self) } - def apply(self: NonEmptyTuple, n: Int): Any = { - (self: Any) match { - // case self: Unit => throw new IndexOutOfBoundsException(n.toString) - case self: Product => self.productElement(n) - } - } + def apply(self: NonEmptyTuple, n: Int): Any = + self.productElement(n) // Benchmarks showed that this is faster than doing (it1 zip it2).copyToArray(...) private def zipIterators(it1: Iterator[Any], it2: Iterator[Any], size: Int): IArray[Object] = { @@ -376,19 +372,19 @@ object Tuple { val t1Size: Int = t1.size val t2Size: Int = t2.size val size = Math.min(t1Size, t2Size) - if size == 0 then () + if size == 0 then EmptyTuple else Tuple.fromIArray( zipIterators( - t1.asInstanceOf[Product].productIterator, - t2.asInstanceOf[Product].productIterator, + t1.productIterator, + t2.productIterator, size ) ) } - def map[F[_]](self: Tuple, f: [t] => t => F[t]): Tuple = (self: Any) match { - case self: Unit => () - case _ => fromIArray(self.asInstanceOf[Product].productIterator.map(f(_).asInstanceOf[Object]).toArray.asInstanceOf[IArray[Object]]) // TODO use toIArray + def map[F[_]](self: Tuple, f: [t] => t => F[t]): Tuple = self match { + case EmptyTuple => self + case _ => fromIArray(self.productIterator.map(f(_).asInstanceOf[Object]).toArray.asInstanceOf[IArray[Object]]) // TODO use toIArray } def take(self: Tuple, n: Int): Tuple = { @@ -396,14 +392,14 @@ object Tuple { val selfSize: Int = self.size val actualN = Math.min(n, selfSize) - if (actualN == 0) () + if (actualN == 0) EmptyTuple else { val arr = (self: Any) match { case xxl: TupleXXL => xxl.elems.asInstanceOf[Array[Object]].take(actualN) case _ => val arr = new Array[Object](actualN) - self.asInstanceOf[Product].productIterator.asInstanceOf[Iterator[Object]] + self.productIterator.asInstanceOf[Iterator[Object]] .copyToArray(arr, 0, actualN) arr } @@ -418,14 +414,14 @@ object Tuple { val actualN = Math.min(n, size) val rem = size - actualN - if (rem == 0) () + if (rem == 0) EmptyTuple else { val arr = (self: Any) match { case xxl: TupleXXL => xxl.elems.asInstanceOf[Array[Object]].drop(actualN) case _ => val arr = new Array[Object](rem) - self.asInstanceOf[Product].productIterator.asInstanceOf[Iterator[Object]] + self.productIterator.asInstanceOf[Iterator[Object]] .drop(actualN).copyToArray(arr, 0, rem) arr } @@ -439,13 +435,13 @@ object Tuple { val size = self.size val actualN = Math.min(n, size) val (arr1, arr2) = (self: Any) match { - case () => (Array.empty[Object], Array.empty[Object]) + case EmptyTuple => (Array.empty[Object], Array.empty[Object]) case xxl: TupleXXL => xxl.elems.asInstanceOf[Array[Object]].splitAt(actualN) case _ => val arr1 = new Array[Object](actualN) val arr2 = new Array[Object](size - actualN) - val it = self.asInstanceOf[Product].productIterator.asInstanceOf[Iterator[Object]] + val it = self.productIterator.asInstanceOf[Iterator[Object]] it.copyToArray(arr1, 0, actualN) it.copyToArray(arr2, 0, size - actualN) (arr1, arr2) @@ -458,9 +454,72 @@ object Tuple { } def consIterator(head: Any, tail: Tuple): Iterator[Any] = - Iterator.single(head) ++ tail.asInstanceOf[Product].productIterator + Iterator.single(head) ++ tail.productIterator def concatIterator(tup1: Tuple, tup2: Tuple): Iterator[Any] = - tup1.asInstanceOf[Product].productIterator ++ tup2.asInstanceOf[Product].productIterator + tup1.productIterator ++ tup2.productIterator + + def isInstanceOfTuple(x: Any): Boolean = + x match + case x: Product => + x.productArity match + case 0 => x == EmptyTuple + case 1 => x.isInstanceOf[Tuple1[_]] + case 2 => x.isInstanceOf[Tuple2[_, _]] + case 3 => x.isInstanceOf[Tuple3[_, _, _]] + case 4 => x.isInstanceOf[Tuple4[_, _, _, _]] + case 5 => x.isInstanceOf[Tuple5[_, _, _, _, _]] + case 6 => x.isInstanceOf[Tuple6[_, _, _, _, _, _]] + case 7 => x.isInstanceOf[Tuple7[_, _, _, _, _, _, _]] + case 8 => x.isInstanceOf[Tuple8[_, _, _, _, _, _, _, _]] + case 9 => x.isInstanceOf[Tuple9[_, _, _, _, _, _, _, _, _]] + case 10 => x.isInstanceOf[Tuple10[_, _, _, _, _, _, _, _, _, _]] + case 11 => x.isInstanceOf[Tuple11[_, _, _, _, _, _, _, _, _, _, _]] + case 12 => x.isInstanceOf[Tuple12[_, _, _, _, _, _, _, _, _, _, _, _]] + case 13 => x.isInstanceOf[Tuple13[_, _, _, _, _, _, _, _, _, _, _, _, _]] + case 14 => x.isInstanceOf[Tuple14[_, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 15 => x.isInstanceOf[Tuple15[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 16 => x.isInstanceOf[Tuple16[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 17 => x.isInstanceOf[Tuple17[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 18 => x.isInstanceOf[Tuple18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 19 => x.isInstanceOf[Tuple19[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 20 => x.isInstanceOf[Tuple20[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 21 => x.isInstanceOf[Tuple21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 22 => x.isInstanceOf[Tuple22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case _ => x.isInstanceOf[TupleXXL] + case _ => + false + + def isInstanceOfEmptyTuple(x: Any): Boolean = x == EmptyTuple + + def isInstanceOfNonEmptyTuple(x: Any): Boolean = + x match + case x: Product => + x.productArity match + case 1 => x.isInstanceOf[Tuple1[_]] + case 2 => x.isInstanceOf[Tuple2[_, _]] + case 3 => x.isInstanceOf[Tuple3[_, _, _]] + case 4 => x.isInstanceOf[Tuple4[_, _, _, _]] + case 5 => x.isInstanceOf[Tuple5[_, _, _, _, _]] + case 6 => x.isInstanceOf[Tuple6[_, _, _, _, _, _]] + case 7 => x.isInstanceOf[Tuple7[_, _, _, _, _, _, _]] + case 8 => x.isInstanceOf[Tuple8[_, _, _, _, _, _, _, _]] + case 9 => x.isInstanceOf[Tuple9[_, _, _, _, _, _, _, _, _]] + case 10 => x.isInstanceOf[Tuple10[_, _, _, _, _, _, _, _, _, _]] + case 11 => x.isInstanceOf[Tuple11[_, _, _, _, _, _, _, _, _, _, _]] + case 12 => x.isInstanceOf[Tuple12[_, _, _, _, _, _, _, _, _, _, _, _]] + case 13 => x.isInstanceOf[Tuple13[_, _, _, _, _, _, _, _, _, _, _, _, _]] + case 14 => x.isInstanceOf[Tuple14[_, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 15 => x.isInstanceOf[Tuple15[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 16 => x.isInstanceOf[Tuple16[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 17 => x.isInstanceOf[Tuple17[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 18 => x.isInstanceOf[Tuple18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 19 => x.isInstanceOf[Tuple19[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 20 => x.isInstanceOf[Tuple20[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 21 => x.isInstanceOf[Tuple21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case 22 => x.isInstanceOf[Tuple22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] + case _ => x.isInstanceOf[TupleXXL] + case _ => + false } diff --git a/library/src-non-bootstrapped/scala/Tuple.scala b/library/src-non-bootstrapped/scala/Tuple.scala index e1a24ab83849..899019479dc2 100644 --- a/library/src-non-bootstrapped/scala/Tuple.scala +++ b/library/src-non-bootstrapped/scala/Tuple.scala @@ -159,6 +159,9 @@ object Tuple { */ type Split[T <: Tuple, N <: Int] = (Take[T, N], Drop[T, N]) + /** Empty tuple */ + def apply(): Unit = () + /** Convert an array into a tuple of unknown arity and types */ def fromArray[T](xs: Array[T]): Tuple = { val xs2 = xs match { @@ -187,6 +190,8 @@ object Tuple { Tuple.fromArray(p.productIterator.toArray).asInstanceOf[m.MirroredElemTypes] // TODO use toIArray of Object to avoid double/triple array copy } +def EmptyTuple: Unit = () + /** Tuple of arbitrary non-zero arity */ sealed trait NonEmptyTuple extends Tuple with Product { import Tuple._ diff --git a/library/src/scala/internal/quoted/Matcher.scala b/library/src/scala/internal/quoted/Matcher.scala index 4f9ecad58973..957e47c62907 100644 --- a/library/src/scala/internal/quoted/Matcher.scala +++ b/library/src/scala/internal/quoted/Matcher.scala @@ -475,7 +475,7 @@ object Matcher { private object Matching { def notMatched: Matching = None - val matched: Matching = Some(()) + val matched: Matching = Some(Tuple()) def matched(x: Any): Matching = Some(Tuple1(x)) def (self: Matching) asOptionOfTuple: Option[Tuple] = self diff --git a/library/src/scala/tasty/Reflection.scala b/library/src/scala/tasty/Reflection.scala index 8975b3c265d1..25a498ce779a 100644 --- a/library/src/scala/tasty/Reflection.scala +++ b/library/src/scala/tasty/Reflection.scala @@ -2574,6 +2574,18 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => /** The type for `scala.String`. */ def StringType: Type = internal.Definitions_StringType + + /** The type for `scala.Tuple`. */ + def TupleType: Type = internal.Definitions_TupleType + + /** The type for `scala.EmptyTuple`. */ + def EmptyTupleType: Type = internal.Definitions_EmptyTupleType + + /** The type for `scala.NonEmptyTuple`. */ + def NonEmptyTupleType: Type = internal.Definitions_NonEmptyTupleType + + /** The type for `scala.*:`. */ + def TupleConsType: Type = internal.Definitions_TupleConsType } diff --git a/library/src/scala/tasty/reflect/CompilerInterface.scala b/library/src/scala/tasty/reflect/CompilerInterface.scala index e946bdba0248..ed901586ce81 100644 --- a/library/src/scala/tasty/reflect/CompilerInterface.scala +++ b/library/src/scala/tasty/reflect/CompilerInterface.scala @@ -1523,23 +1523,65 @@ trait CompilerInterface { /** Symbol of scala.internal.CompileTime.fromAbove */ def Definitions_InternalQuotedMatcher_fromAboveAnnot: Symbol + /** The type of primitive type `Unit`. */ def Definitions_UnitType: Type + + /** The type of primitive type `Byte`. */ def Definitions_ByteType: Type + + /** The type of primitive type `Short`. */ def Definitions_ShortType: Type + + /** The type of primitive type `Char`. */ def Definitions_CharType: Type + + /** The type of primitive type `Int`. */ def Definitions_IntType: Type + + /** The type of primitive type `Long`. */ def Definitions_LongType: Type + + /** The type of primitive type `Float`. */ def Definitions_FloatType: Type + + /** The type of primitive type `Double`. */ def Definitions_DoubleType: Type + + /** The type of primitive type `Boolean`. */ def Definitions_BooleanType: Type + + /** The type of core type `Any`. */ def Definitions_AnyType: Type + + /** The type of core type `AnyVal`. */ def Definitions_AnyValType: Type + + /** The type of core type `AnyRef`. */ def Definitions_AnyRefType: Type + + /** The type of core type `Object`. */ def Definitions_ObjectType: Type + + /** The type of core type `Nothing`. */ def Definitions_NothingType: Type + + /** The type of core type `Null`. */ def Definitions_NullType: Type + + /** The type for `scala.String`. */ def Definitions_StringType: Type + /** The type for `scala.Tuple`. */ + def Definitions_TupleType: Type + + /** The type for `scala.EmptyTuple`. */ + def Definitions_EmptyTupleType: Type + + /** The type for `scala.NonEmptyTuple`. */ + def Definitions_NonEmptyTupleType: Type + + /** The type for `scala.*:`. */ + def Definitions_TupleConsType: Type /////////////// // IMPLICITS // diff --git a/tests/neg-custom-args/typeclass-derivation2.scala b/tests/neg-custom-args/typeclass-derivation2.scala index 8c07bf883839..47c034610a76 100644 --- a/tests/neg-custom-args/typeclass-derivation2.scala +++ b/tests/neg-custom-args/typeclass-derivation2.scala @@ -132,7 +132,7 @@ object Lst { type Shape[T] = Shape.Cases[( Shape.Case[Cons[T], (T, Lst[T])], - Shape.Case[Nil.type, Unit] + Shape.Case[Nil.type, EmptyTuple] )] val genericClass = new GenericClass("Cons\000hd\000tl\001Nil") @@ -185,8 +185,8 @@ object Either { import TypeLevel._ type Shape[L, R] = Shape.Cases[( - Shape.Case[Left[L], L *: Unit], - Shape.Case[Right[R], R *: Unit] + Shape.Case[Left[L], L *: EmptyTuple], + Shape.Case[Right[R], R *: EmptyTuple] )] val genericClass = new GenericClass("Left\000x\001Right\000x") @@ -221,7 +221,7 @@ object Show { val formal = elems.elementLabel(n) val actual = tryShow[elem](elems(n).asInstanceOf) s"$formal = $actual" :: showElems[elems1](elems, n + 1) - case _: Unit => + case _: EmptyTuple => Nil } @@ -243,7 +243,7 @@ object Show { case _ => error("invalid call to showCases: one of Alts is not a subtype of T") } - case _: Unit => + case _: EmptyTuple => throw new MatchError(x) } diff --git a/tests/neg-strict/unchecked-patterns.scala b/tests/neg-strict/unchecked-patterns.scala index 1adcac67e420..8cf797e88029 100644 --- a/tests/neg-strict/unchecked-patterns.scala +++ b/tests/neg-strict/unchecked-patterns.scala @@ -5,7 +5,7 @@ object Test { val x :: xs = List(1, 2, 3) // error val (1, c) = (1, 2) // error - val 1 *: cs = 1 *: () // error + val 1 *: cs = 1 *: Tuple() // error val (_: Int | _: Any) = ??? : Any // error diff --git a/tests/neg/i7459.scala b/tests/neg/i7459.scala index 05dbaaceba35..88befb163c63 100644 --- a/tests/neg/i7459.scala +++ b/tests/neg/i7459.scala @@ -13,7 +13,7 @@ inline def summon[T](using t:T): T = t match { } inline def summonAll[T <: Tuple]: List[Eq[_]] = inline erasedValue[T] match { - case _: Unit => Nil + case _: EmptyTuple => Nil case _: (t *: ts) => summon[Eq[t]] :: summonAll[ts] // error } diff --git a/tests/pos-custom-args/matchtype.scala b/tests/pos-custom-args/matchtype.scala index 858b2cb267d4..16f284d3b434 100644 --- a/tests/pos-custom-args/matchtype.scala +++ b/tests/pos-custom-args/matchtype.scala @@ -59,8 +59,8 @@ object Test { erased val z5: (String, Int) = erasedValue[Concat[Unit, (String, Int)]] erased val y6: Concat[(Boolean, Boolean), (String, Int)] = erasedValue[Boolean *: Boolean *: (String, Int)] erased val z6: Boolean *: Boolean *: (String, Int) = erasedValue[Concat[(Boolean, Boolean), (String, Int)]] - erased val y7: (Boolean, Boolean, String, Int) = erasedValue[Concat[(Boolean, Boolean), String *: Int *: Unit]] - erased val z7: Concat[(Boolean, Boolean), String *: Int *: Unit] = erasedValue[(Boolean, Boolean, String, Int)] + erased val y7: (Boolean, Boolean, String, Int) = erasedValue[Concat[(Boolean, Boolean), String *: Int *: EmptyTuple]] + erased val z7: Concat[(Boolean, Boolean), String *: Int *: EmptyTuple] = erasedValue[(Boolean, Boolean, String, Int)] def index[Xs <: NonEmptyTuple](xs: Xs, n: Int): Elem[Xs, n.type] = xs(n).asInstanceOf diff --git a/tests/pos-special/fatal-warnings/tuple-exaustivity.scala b/tests/pos-special/fatal-warnings/tuple-exaustivity.scala new file mode 100644 index 000000000000..dd5aec2436f1 --- /dev/null +++ b/tests/pos-special/fatal-warnings/tuple-exaustivity.scala @@ -0,0 +1,4 @@ +def test(t: Tuple) = + t match + case Tuple() => + case head *: tail => diff --git a/tests/pos-special/typeclass-scaling.scala b/tests/pos-special/typeclass-scaling.scala index 1c3c9fe33075..1c9c38dc0534 100644 --- a/tests/pos-special/typeclass-scaling.scala +++ b/tests/pos-special/typeclass-scaling.scala @@ -225,7 +225,7 @@ object typeclasses { case _: (elem *: elems1) => tryEql[elem](productElement[elem](x, n), productElement[elem](y, n)) && eqlElems[elems1](n + 1)(x, y) - case _: Unit => + case _: EmptyTuple => true } @@ -240,7 +240,7 @@ object typeclasses { case m: Mirror.ProductOf[`alt`] => eqlElems[m.MirroredElemTypes](0)(x, y) } else eqlCases[alts1](n + 1)(x, y, ord) - case _: Unit => + case _: EmptyTuple => false } @@ -280,7 +280,7 @@ object typeclasses { case _: (elem *: elems1) => tryPickle[elem](buf, productElement[elem](x, n)) pickleElems[elems1](n + 1)(buf, x) - case _: Unit => + case _: EmptyTuple => } inline def pickleCases[Alts <: Tuple](n: Int)(buf: mutable.ListBuffer[Int], x: Any, ord: Int): Unit = @@ -291,7 +291,7 @@ object typeclasses { case m: Mirror.ProductOf[`alt`] => pickleElems[m.MirroredElemTypes](0)(buf, x) } else pickleCases[alts1](n + 1)(buf, x, ord) - case _: Unit => + case _: EmptyTuple => } inline def tryUnpickle[T](buf: mutable.ListBuffer[Int]): T = summonInline[Pickler[T]].unpickle(buf) @@ -301,7 +301,7 @@ object typeclasses { case _: (elem *: elems1) => elems(n) = tryUnpickle[elem](buf).asInstanceOf[AnyRef] unpickleElems[elems1](n + 1)(buf, elems) - case _: Unit => + case _: EmptyTuple => } inline def unpickleCase[T, Elems <: Tuple](buf: mutable.ListBuffer[Int], m: Mirror.ProductOf[T]): T = { @@ -324,7 +324,7 @@ object typeclasses { unpickleCase[`alt` & T, m.MirroredElemTypes](buf, m) } else unpickleCases[T, alts1](n + 1)(buf, ord) - case _: Unit => + case _: EmptyTuple => throw new IndexOutOfBoundsException(s"unexpected ordinal number: $ord") } diff --git a/tests/pos/8313.scala b/tests/pos/8313.scala index a82fcefff4bc..b853c5caa5df 100644 --- a/tests/pos/8313.scala +++ b/tests/pos/8313.scala @@ -1,9 +1,9 @@ object Test { type DU[A <: Tuple] <: Tuple = A match { - case Unit => Unit + case EmptyTuple => EmptyTuple case Unit *: tl => DU[tl] case hd *: tl => hd *: DU[tl] } - (1, 2): DU[Int *: Int *: Unit] + (1, 2): DU[Int *: Int *: EmptyTuple] } diff --git a/tests/pos/automatic-tupling-of-function-parameters.scala b/tests/pos/automatic-tupling-of-function-parameters.scala index 2afc7eaf10e3..e88999cc1558 100644 --- a/tests/pos/automatic-tupling-of-function-parameters.scala +++ b/tests/pos/automatic-tupling-of-function-parameters.scala @@ -5,7 +5,7 @@ object Test { val g2: Tuple2[Int, String] => Int = _ + _.length // FIXME issue #5257 -// val h2: Int *: Int *: Unit => Int = (x, y) => x + y +// val h2: Int *: Int *: EmptyTuple => Int = (x, y) => x + y // val k2: Int *: Tuple1[Int] => Int = (x, y) => x + y type T2 = Tuple2[Int, Int] diff --git a/tests/pos/i5338.scala b/tests/pos/i5338.scala index 9f681ffdaee2..708d92e1efed 100644 --- a/tests/pos/i5338.scala +++ b/tests/pos/i5338.scala @@ -1,6 +1,6 @@ object Test { - val unit = () + val emptyTuple = Tuple() def f[T <: Tuple, X](xs: T, x: X) = - xs ++ x *: unit + xs ++ x *: emptyTuple } diff --git a/tests/pos/i6507.scala b/tests/pos/i6507.scala index a3646d27f301..9d56943c3686 100644 --- a/tests/pos/i6507.scala +++ b/tests/pos/i6507.scala @@ -3,7 +3,7 @@ object Test { inline def s2 = 48 *: s3 - inline def s3 = 49 *: () + inline def s3 = 49 *: Tuple() s1 } diff --git a/tests/pos/i7262.scala b/tests/pos/i7262.scala index d89dbcf64eea..1c815425fcd1 100644 --- a/tests/pos/i7262.scala +++ b/tests/pos/i7262.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { def f[T](t: Type[T])(using QuoteContext) = t match { - case '[ Int *: Unit ] => + case '[ Int *: EmptyTuple ] => } } diff --git a/tests/pos/i7358.scala b/tests/pos/i7358.scala index 37032e60d52b..8aa6cc5d280a 100644 --- a/tests/pos/i7358.scala +++ b/tests/pos/i7358.scala @@ -4,7 +4,7 @@ import scala.quoted._ import scala.compiletime._ transparent inline def summonT[Tp <: Tuple](using QuoteContext): Tuple = inline erasedValue[Tp] match { - case _ : Unit => () + case _ : EmptyTuple => Tuple() case _ : (hd *: tl) => { type H = hd summonFrom { diff --git a/tests/pos/i7851.scala b/tests/pos/i7851.scala index 9f349b75925b..98baaf840253 100644 --- a/tests/pos/i7851.scala +++ b/tests/pos/i7851.scala @@ -6,7 +6,7 @@ case class Wrapped[T: Wrappable](value: T) trait Wrapper[T] { type WrappedT } object Wrapper { type Aux[T <: Tuple, WrappedT0 <: Tuple] = Wrapper[T] { type WrappedT = WrappedT0 } } -given Wrapper[Unit] { type WrappedT = Unit } +given Wrapper[EmptyTuple] { type WrappedT = EmptyTuple } given [T: Wrappable] as Wrapper[T] { type WrappedT = Wrapped[T] } diff --git a/tests/pos/scala-days-2019-slides/metaprogramming-2-tuple.scala b/tests/pos/scala-days-2019-slides/metaprogramming-2-tuple.scala index 68165ecd2be6..cebfd1cf1d91 100644 --- a/tests/pos/scala-days-2019-slides/metaprogramming-2-tuple.scala +++ b/tests/pos/scala-days-2019-slides/metaprogramming-2-tuple.scala @@ -5,9 +5,9 @@ object TupleExample { type B type C - summon[Concat[A *: B *: Unit, C *: Unit] =:= A *: B *: C *: Unit] + summon[Concat[A *: B *: EmptyTuple, C *: EmptyTuple] =:= A *: B *: C *: EmptyTuple] - summon[Concat[A *: B *: Unit, C *: Tuple] =:= A *: B *: C *: Tuple] + summon[Concat[A *: B *: EmptyTuple, C *: Tuple] =:= A *: B *: C *: Tuple] - summon[Concat[A *: B *: Tuple, C *: Unit] <:< A *: B *: Tuple] + summon[Concat[A *: B *: Tuple, C *: EmptyTuple] <:< A *: B *: Tuple] } diff --git a/tests/pos/tuple-isMappedBy.scala b/tests/pos/tuple-isMappedBy.scala index c7e1f2ae3843..f266064619d8 100644 --- a/tests/pos/tuple-isMappedBy.scala +++ b/tests/pos/tuple-isMappedBy.scala @@ -5,23 +5,23 @@ object Test { def test[F[_], T <: Tuple: IsMappedBy[F]]: Unit = () - test[[X] =>> X, Unit] + test[[X] =>> X, EmptyTuple] test[[X] =>> X, (Int, Long)] - test[List, Unit] + test[List, EmptyTuple] test[List, (List[Int], List[Long])] trait A[+X] trait B[-X] trait C[X] - test[A, Unit] + test[A, EmptyTuple] test[A, (A[Int], A[Long])] - test[B, Unit] + test[B, EmptyTuple] test[B, (B[Int], B[Long])] - test[C, Unit] + test[C, EmptyTuple] test[C, (C[Int], C[Long])] } diff --git a/tests/pos/tupled-function-instances.scala b/tests/pos/tupled-function-instances.scala index e7cf2ac85dde..0b233473100c 100644 --- a/tests/pos/tupled-function-instances.scala +++ b/tests/pos/tupled-function-instances.scala @@ -3,7 +3,7 @@ object Test { type T type R - summon[TupledFunction[() => R, Unit => R]] + summon[TupledFunction[() => R, EmptyTuple => R]] summon[TupledFunction[T => R, Tuple1[T] => R]] summon[TupledFunction[(T, T) => R, ((T, T)) => R]] summon[TupledFunction[(T, T, T) => R, ((T, T, T)) => R]] diff --git a/tests/run-custom-args/tuple-cons.scala b/tests/run-custom-args/tuple-cons.scala index 18225a640594..3fd3b819ea12 100644 --- a/tests/run-custom-args/tuple-cons.scala +++ b/tests/run-custom-args/tuple-cons.scala @@ -2,22 +2,22 @@ import dotty._ object Test { def main(args: Array[String]) = { - val t1: *:[Int, *:[Int, Unit]] = (1, 2) + val t1: *:[Int, *:[Int, EmptyTuple]] = (1, 2) - val t2: *:[Int, *:[Int, *:[Int, Unit]]] = 0 *: t1 + val t2: *:[Int, *:[Int, *:[Int, EmptyTuple]]] = 0 *: t1 assert(t2.head == 0) assert(t2.tail.head == 1) assert(t2.tail.tail.head == 2) t2 match { - case e1 *: e2 *: e3 *: () => + case e1 *: e2 *: e3 *: Tuple() => assert(e1 == 0) assert(e2 == 1) assert(e3 == 2) } - val t3: *:[Int, *:[Int, *:[Int, *:[Int, Unit]]]] = -1 *: t2 + val t3: *:[Int, *:[Int, *:[Int, *:[Int, EmptyTuple]]]] = -1 *: t2 assert(t3.head == -1) assert(t3.tail.head == 0) @@ -25,7 +25,7 @@ object Test { assert(t3.tail.tail.tail.head == 2) t3 match { - case e1 *: e2 *: e3 *: e4 *: () => + case e1 *: e2 *: e3 *: e4 *: Tuple() => assert(e1 == -1) assert(e2 == 0) assert(e3 == 1) @@ -35,10 +35,10 @@ object Test { type I = Int // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 - val t20: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,Unit]]]]]]]]]]]]]]]]]]]] = 1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: () + val t20: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,EmptyTuple]]]]]]]]]]]]]]]]]]]] = 1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: Tuple() t20 match { - case e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: () => + case e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: Tuple() => assert(e1 == 1) assert(e2 == 2) assert(e3 == 3) @@ -62,10 +62,10 @@ object Test { } // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 - val t21: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,Unit]]]]]]]]]]]]]]]]]]]]] = 21 *: t20 + val t21: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,EmptyTuple]]]]]]]]]]]]]]]]]]]]] = 21 *: t20 t21 match { - case e21 *: e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: () => + case e21 *: e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: Tuple() => assert(e1 == 1) assert(e2 == 2) assert(e3 == 3) @@ -90,10 +90,10 @@ object Test { } // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 - val t22: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,Unit]]]]]]]]]]]]]]]]]]]]]] = 22 *: t21 + val t22: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,EmptyTuple]]]]]]]]]]]]]]]]]]]]]] = 22 *: t21 t22 match { - case e22 *: e21 *: e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: () => + case e22 *: e21 *: e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: Tuple() => assert(e1 == 1) assert(e2 == 2) assert(e3 == 3) @@ -119,10 +119,10 @@ object Test { } // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 - val t23: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,Unit]]]]]]]]]]]]]]]]]]]]]]] = 23 *: t22 + val t23: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,EmptyTuple]]]]]]]]]]]]]]]]]]]]]]] = 23 *: t22 t23 match { - case e23 *: e22 *: e21 *: e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: () => + case e23 *: e22 *: e21 *: e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: Tuple() => assert(e1 == 1) assert(e2 == 2) assert(e3 == 3) @@ -149,10 +149,10 @@ object Test { } // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 - val t24: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,Unit]]]]]]]]]]]]]]]]]]]]]]]] = 24 *: t23 + val t24: *:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,*:[I,EmptyTuple]]]]]]]]]]]]]]]]]]]]]]]] = 24 *: t23 t24 match { - case e24 *: e23 *: e22 *: e21 *: e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: () => + case e24 *: e23 *: e22 *: e21 *: e1 *: e2 *: e3 *: e4 *: e5 *: e6 *: e7 *: e8 *: e9 *: e10 *: e11 *: e12 *: e13 *: e14 *: e15 *: e16 *: e17 *: e18 *: e19 *: e20 *: Tuple() => assert(e1 == 1) assert(e2 == 2) assert(e3 == 3) diff --git a/tests/run-custom-args/typeclass-derivation2.scala b/tests/run-custom-args/typeclass-derivation2.scala index 772e31d7cdee..59b1863854e2 100644 --- a/tests/run-custom-args/typeclass-derivation2.scala +++ b/tests/run-custom-args/typeclass-derivation2.scala @@ -194,8 +194,8 @@ object Either { import TypeLevel._ type Shape[L, R] = Shape.Cases[( - Shape.Case[Left[L], L *: Unit], - Shape.Case[Right[R], R *: Unit] + Shape.Case[Left[L], L *: EmptyTuple], + Shape.Case[Right[R], R *: EmptyTuple] )] val reflectedClass = new ReflectedClass("Left\000x\001Right\000x") @@ -234,7 +234,7 @@ object Eq { case _: (elem *: elems1) => tryEql[elem](xm(n).asInstanceOf, ym(n).asInstanceOf) && eqlElems[elems1](xm, ym, n + 1) - case _: Unit => + case _: EmptyTuple => true } @@ -251,7 +251,7 @@ object Eq { case _ => error("invalid call to eqlCases: one of Alts is not a subtype of T") } - case _: Unit => + case _: EmptyTuple => false } @@ -293,7 +293,7 @@ object Pickler { case _: (elem *: elems1) => tryPickle[elem](buf, elems(n).asInstanceOf[elem]) pickleElems[elems1](buf, elems, n + 1) - case _: Unit => + case _: EmptyTuple => } inline def pickleCase[T, Elems <: Tuple](r: Reflected[T], buf: mutable.ListBuffer[Int], x: T): Unit = @@ -314,7 +314,7 @@ object Pickler { case _ => error("invalid pickleCases call: one of Alts is not a subtype of T") } - case _: Unit => + case _: EmptyTuple => } inline def tryUnpickle[T](buf: mutable.ListBuffer[Int]): T = summonInline[Pickler[T]].unpickle(buf) @@ -324,7 +324,7 @@ object Pickler { case _: (elem *: elems1) => elems(n) = tryUnpickle[elem](buf).asInstanceOf[AnyRef] unpickleElems[elems1](buf, elems, n + 1) - case _: Unit => + case _: EmptyTuple => } inline def unpickleCase[T, Elems <: Tuple](r: Reflected[T], buf: mutable.ListBuffer[Int], ordinal: Int): T = { @@ -384,7 +384,7 @@ object Show { val formal = elems.elementLabel(n) val actual = tryShow[elem](elems(n).asInstanceOf) s"$formal = $actual" :: showElems[elems1](elems, n + 1) - case _: Unit => + case _: EmptyTuple => Nil } @@ -407,7 +407,7 @@ object Show { case _ => error("invalid call to showCases: one of Alts is not a subtype of T") } - case _: Unit => + case _: EmptyTuple => throw new MatchError(x) } diff --git a/tests/run-custom-args/typeclass-derivation2c.scala b/tests/run-custom-args/typeclass-derivation2c.scala index fa1ae6ec8a4f..1a4b8873679d 100644 --- a/tests/run-custom-args/typeclass-derivation2c.scala +++ b/tests/run-custom-args/typeclass-derivation2c.scala @@ -172,18 +172,18 @@ case class Right[R](elem: R) extends Either[Nothing, R] object Left extends Generic.Product[Left[_]] { def fromProduct(p: Product): Left[_] = Left(productElement[Any](p, 0)) implicit def GenericLeft[L]: Generic.Product[Left[L]] { - type ElemTypes = L *: Unit + type ElemTypes = L *: EmptyTuple type CaseLabel = "Left" - type ElemLabels = "x" *: Unit + type ElemLabels = "x" *: EmptyTuple } = this.asInstanceOf } object Right extends Generic.Product[Right[_]] { def fromProduct(p: Product): Right[_] = Right(productElement[Any](p, 0)) implicit def GenericRight[R]: Generic.Product[Right[R]] { - type ElemTypes = R *: Unit + type ElemTypes = R *: EmptyTuple type CaseLabel = "Right" - type ElemLabels = "x" *: Unit + type ElemLabels = "x" *: EmptyTuple } = this.asInstanceOf } @@ -218,7 +218,7 @@ object Eq { case _: (elem *: elems1) => tryEql[elem](productElement[elem](x, n), productElement[elem](y, n)) && eqlElems[elems1](n + 1)(x, y) - case _: Unit => + case _: EmptyTuple => true } @@ -272,7 +272,7 @@ object Pickler { case _: (elem *: elems1) => tryPickle[elem](buf, productElement[elem](x, n)) pickleElems[elems1](n + 1)(buf, x) - case _: Unit => + case _: EmptyTuple => } inline def pickleProduct[T](g: Generic.Product[T])(buf: mutable.ListBuffer[Int], x: Any): Unit = @@ -295,7 +295,7 @@ object Pickler { case _: (elem *: elems1) => elems(n) = tryUnpickle[elem](buf).asInstanceOf[AnyRef] unpickleElems[elems1](n + 1)(buf, elems) - case _: Unit => + case _: EmptyTuple => } inline def unpickleProduct[T](g: Generic.Product[T])(buf: mutable.ListBuffer[Int]): T = { @@ -362,7 +362,7 @@ object Show { val actual = tryShow(productElement[elem](x, n)) s"$formal = $actual" :: showElems[elems1, labels1](n + 1)(x) } - case _: Unit => + case _: EmptyTuple => Nil } diff --git a/tests/run-deep-subtype/Tuple-apply.scala b/tests/run-deep-subtype/Tuple-apply.scala index 673a4bcf43a4..6c4199061be5 100644 --- a/tests/run-deep-subtype/Tuple-apply.scala +++ b/tests/run-deep-subtype/Tuple-apply.scala @@ -112,59 +112,59 @@ object Test { assert(24 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24).apply(23)) assert(25 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25).apply(24)) - assert(1 == (1 *: ()).apply(0)) - assert(1 == (1 *: 2 *: ()).apply(0)) - assert(1 == (1 *: 2 *: 3 *: ()).apply(0)) - assert(1 == (1 *: 2 *: 3 *: 4 *: ()).apply(0)) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: ()).apply(0)) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: ()).apply(0)) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: ()).apply(0)) + assert(1 == (1 *: Tuple()).apply(0)) + assert(1 == (1 *: 2 *: Tuple()).apply(0)) + assert(1 == (1 *: 2 *: 3 *: Tuple()).apply(0)) + assert(1 == (1 *: 2 *: 3 *: 4 *: Tuple()).apply(0)) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: Tuple()).apply(0)) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: Tuple()).apply(0)) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: Tuple()).apply(0)) // FIXME performance -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: ()).apply(0)) -// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: ()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: Tuple()).apply(0)) +// assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: Tuple()).apply(0)) - assert(1 == (1 *: ()).apply(0)) - assert(2 == (1 *: 2 *: ()).apply(1)) - assert(3 == (1 *: 2 *: 3 *: ()).apply(2)) - assert(4 == (1 *: 2 *: 3 *: 4 *: ()).apply(3)) - assert(5 == (1 *: 2 *: 3 *: 4 *: 5 *: ()).apply(4)) - assert(6 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: ()).apply(5)) - assert(7 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: ()).apply(6)) + assert(1 == (1 *: Tuple()).apply(0)) + assert(2 == (1 *: 2 *: Tuple()).apply(1)) + assert(3 == (1 *: 2 *: 3 *: Tuple()).apply(2)) + assert(4 == (1 *: 2 *: 3 *: 4 *: Tuple()).apply(3)) + assert(5 == (1 *: 2 *: 3 *: 4 *: 5 *: Tuple()).apply(4)) + assert(6 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: Tuple()).apply(5)) + assert(7 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: Tuple()).apply(6)) // FIXME performance -// assert(8 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: ()).apply(7)) -// assert(9 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: ()).apply(8)) -// assert(10 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: ()).apply(9)) -// assert(11 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: ()).apply(10)) -// assert(12 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: ()).apply(11)) -// assert(13 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: ()).apply(12)) -// assert(14 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: ()).apply(13)) -// assert(15 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: ()).apply(14)) -// assert(16 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: ()).apply(15)) -// assert(17 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: ()).apply(16)) -// assert(18 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: ()).apply(17)) -// assert(19 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: ()).apply(18)) -// assert(20 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: ()).apply(19)) -// assert(21 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: ()).apply(20)) -// assert(22 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: ()).apply(21)) -// assert(23 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: ()).apply(22)) -// assert(24 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: ()).apply(23)) -// assert(25 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: ()).apply(24)) +// assert(8 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: Tuple()).apply(7)) +// assert(9 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: Tuple()).apply(8)) +// assert(10 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: Tuple()).apply(9)) +// assert(11 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: Tuple()).apply(10)) +// assert(12 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: Tuple()).apply(11)) +// assert(13 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: Tuple()).apply(12)) +// assert(14 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: Tuple()).apply(13)) +// assert(15 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: Tuple()).apply(14)) +// assert(16 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: Tuple()).apply(15)) +// assert(17 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: Tuple()).apply(16)) +// assert(18 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: Tuple()).apply(17)) +// assert(19 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: Tuple()).apply(18)) +// assert(20 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: Tuple()).apply(19)) +// assert(21 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: Tuple()).apply(20)) +// assert(22 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: Tuple()).apply(21)) +// assert(23 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: Tuple()).apply(22)) +// assert(24 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: Tuple()).apply(23)) +// assert(25 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: Tuple()).apply(24)) } } diff --git a/tests/run-deep-subtype/Tuple-head.scala b/tests/run-deep-subtype/Tuple-head.scala index 04a87e18ac65..019b60a97540 100644 --- a/tests/run-deep-subtype/Tuple-head.scala +++ b/tests/run-deep-subtype/Tuple-head.scala @@ -37,30 +37,30 @@ object Test { assert(1 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24).head) assert(1 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25).head) - assert(1 == (1 *: ()).head) - assert(1 == (1 *: 2 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: ()).head) - assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: ()).head) + assert(1 == (1 *: Tuple()).head) + assert(1 == (1 *: 2 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: Tuple()).head) + assert(1 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: Tuple()).head) } } diff --git a/tests/run-deep-subtype/Tuple-size.scala b/tests/run-deep-subtype/Tuple-size.scala index fd3483fee9d2..27ea46f7f240 100644 --- a/tests/run-deep-subtype/Tuple-size.scala +++ b/tests/run-deep-subtype/Tuple-size.scala @@ -37,30 +37,30 @@ object Test { assert(24 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24).size) assert(25 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25).size) - assert(1 == (1 *: ()).size) - assert(2 == (1 *: 2 *: ()).size) - assert(3 == (1 *: 2 *: 3 *: ()).size) - assert(4 == (1 *: 2 *: 3 *: 4 *: ()).size) - assert(5 == (1 *: 2 *: 3 *: 4 *: 5 *: ()).size) - assert(6 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: ()).size) - assert(7 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: ()).size) - assert(8 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: ()).size) - assert(9 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: ()).size) - assert(10 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: ()).size) - assert(11 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: ()).size) - assert(12 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: ()).size) - assert(13 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: ()).size) - assert(14 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: ()).size) - assert(15 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: ()).size) - assert(16 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: ()).size) - assert(17 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: ()).size) - assert(18 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: ()).size) - assert(19 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: ()).size) - assert(20 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: ()).size) - assert(21 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: ()).size) - assert(22 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: ()).size) - assert(23 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: ()).size) - assert(24 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: ()).size) - assert(25 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: ()).size) + assert(1 == (1 *: Tuple()).size) + assert(2 == (1 *: 2 *: Tuple()).size) + assert(3 == (1 *: 2 *: 3 *: Tuple()).size) + assert(4 == (1 *: 2 *: 3 *: 4 *: Tuple()).size) + assert(5 == (1 *: 2 *: 3 *: 4 *: 5 *: Tuple()).size) + assert(6 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: Tuple()).size) + assert(7 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: Tuple()).size) + assert(8 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: Tuple()).size) + assert(9 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: Tuple()).size) + assert(10 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: Tuple()).size) + assert(11 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: Tuple()).size) + assert(12 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: Tuple()).size) + assert(13 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: Tuple()).size) + assert(14 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: Tuple()).size) + assert(15 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: Tuple()).size) + assert(16 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: Tuple()).size) + assert(17 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: Tuple()).size) + assert(18 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: Tuple()).size) + assert(19 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: Tuple()).size) + assert(20 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: Tuple()).size) + assert(21 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: Tuple()).size) + assert(22 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: Tuple()).size) + assert(23 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: Tuple()).size) + assert(24 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: Tuple()).size) + assert(25 == (1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: Tuple()).size) } } diff --git a/tests/run-deep-subtype/Tuple-tail.scala b/tests/run-deep-subtype/Tuple-tail.scala index d32d7d9567b2..0e843a30d3aa 100644 --- a/tests/run-deep-subtype/Tuple-tail.scala +++ b/tests/run-deep-subtype/Tuple-tail.scala @@ -37,30 +37,30 @@ object Test { println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24).tail) println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25).tail) - println((1 *: ()).tail) - println((1 *: 2 *: ()).tail) - println((1 *: 2 *: 3 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: ()).tail) - println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: ()).tail) + println((1 *: Tuple()).tail) + println((1 *: 2 *: Tuple()).tail) + println((1 *: 2 *: 3 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: Tuple()).tail) + println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: Tuple()).tail) } } diff --git a/tests/run-deep-subtype/Tuple-toArray.scala b/tests/run-deep-subtype/Tuple-toArray.scala index 4f7db2546020..a0f8a2cfbe14 100644 --- a/tests/run-deep-subtype/Tuple-toArray.scala +++ b/tests/run-deep-subtype/Tuple-toArray.scala @@ -13,8 +13,8 @@ object Test { for (i <- 0 to 25) testArray(i, j => j) - printArray(().toArray) - printArray(Tuple1(1).toArray) + printArray(Tuple().toArray) + printArray(Tuple(1).toArray) printArray((1, 2).toArray) printArray((1, 2, 3).toArray) printArray((1, 2, 3, 4).toArray) @@ -40,30 +40,30 @@ object Test { printArray((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24).toArray) printArray((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25).toArray) - printArray((1 *: ()).toArray) - printArray((1 *: 2 *: ()).toArray) - printArray((1 *: 2 *: 3 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: ()).toArray) - printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: ()).toArray) + printArray((1 *: Tuple()).toArray) + printArray((1 *: 2 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: Tuple()).toArray) + printArray((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: Tuple()).toArray) } } diff --git a/tests/run-macros/i7987.check b/tests/run-macros/i7987.check index df64985cdf2c..ebda4662ef1c 100644 --- a/tests/run-macros/i7987.check +++ b/tests/run-macros/i7987.check @@ -7,6 +7,6 @@ scala.deriving.Mirror { type MirroredType >: scala.Some[scala.Int] <: scala.Some[scala.Int] type MirroredLabel >: "Some" <: "Some" } { - type MirroredElemTypes >: scala.*:[scala.Int, scala.Unit] <: scala.*:[scala.Int, scala.Unit] - type MirroredElemLabels >: scala.*:["value", scala.Unit] <: scala.*:["value", scala.Unit] + type MirroredElemTypes >: scala.*:[scala.Int, scala.Tuple$package.EmptyTuple] <: scala.*:[scala.Int, scala.Tuple$package.EmptyTuple] + type MirroredElemLabels >: scala.*:["value", scala.Tuple$package.EmptyTuple] <: scala.*:["value", scala.Tuple$package.EmptyTuple] } diff --git a/tests/run-macros/i8007/Macro_1.scala b/tests/run-macros/i8007/Macro_1.scala index 53cf0bed25b4..585220172e40 100644 --- a/tests/run-macros/i8007/Macro_1.scala +++ b/tests/run-macros/i8007/Macro_1.scala @@ -7,7 +7,7 @@ object Macro1 { def mirrorFields[T](t: Type[T])(using qctx: QuoteContext): List[String] = t match { case '[$field *: $fields] => field.show :: mirrorFields(fields) - case '[Unit] => Nil + case '[EmptyTuple] => Nil } // Demonstrates the use of quoted pattern matching diff --git a/tests/run-macros/i8007/Macro_2.scala b/tests/run-macros/i8007/Macro_2.scala index 586c0f86312a..ee5b0a142324 100644 --- a/tests/run-macros/i8007/Macro_2.scala +++ b/tests/run-macros/i8007/Macro_2.scala @@ -7,7 +7,7 @@ object Macro2 { def mirrorFields[T](t: Type[T])(using qctx: QuoteContext): List[String] = t match { case '[$field *: $fields] => field.show.substring(1, field.show.length-1) :: mirrorFields(fields) - case '[Unit] => Nil + case '[EmptyTuple] => Nil } trait JsonEncoder[T] { diff --git a/tests/run-macros/i8007/Macro_3.scala b/tests/run-macros/i8007/Macro_3.scala index da4353f3073a..7a01837eedca 100644 --- a/tests/run-macros/i8007/Macro_3.scala +++ b/tests/run-macros/i8007/Macro_3.scala @@ -29,7 +29,7 @@ object Eq { case '[String *: $tpes] => '{ summon[Eq[String]] } :: summonAll(tpes) case '[Int *: $tpes] => '{ summon[Eq[Int]] } :: summonAll(tpes) case '[$tpe *: $tpes] => derived(using tpe, qctx) :: summonAll(tpes) - case '[Unit] => Nil + case '[EmptyTuple] => Nil } given derived[T: Type](using qctx: QuoteContext) as Expr[Eq[T]] = { diff --git a/tests/run-macros/refined-selectable-macro/Macro_1.scala b/tests/run-macros/refined-selectable-macro/Macro_1.scala index f52c68a7761f..15b1a7792d63 100644 --- a/tests/run-macros/refined-selectable-macro/Macro_1.scala +++ b/tests/run-macros/refined-selectable-macro/Macro_1.scala @@ -65,7 +65,7 @@ object Macro { } } def rec(tpe: Type, seen: Set[String]): List[(String, Type)] = { - if tpe =:= defn.UnitType then Nil + if tpe =:= defn.EmptyTupleType then Nil else tpe match { // head *: tail case AppliedType(parent, List(head, tail: Type)) if isTupleCons(parent.typeSymbol) => diff --git a/tests/run-macros/refined-selectable-macro/Test_3.scala b/tests/run-macros/refined-selectable-macro/Test_3.scala index fca330ec112e..53a852c81e2b 100644 --- a/tests/run-macros/refined-selectable-macro/Test_3.scala +++ b/tests/run-macros/refined-selectable-macro/Test_3.scala @@ -37,7 +37,7 @@ object Test { val res2 = Record.fromTuple(res) - val emptyTuple = () + val emptyTuple = Tuple() println(Record.fromTuple(emptyTuple)) val xxl: (("field1", Int),("field2", Int),("field3", Int),("field4", Int),("field5", Int),("field6", Int),("field7", Int),("field8", Int),("field9", Int),("field10", Int),("field11", Int),("field12", Int),("field13", Int),("field14", Int),("field15", Int),("field16", Int),("field17", Int),("field18", Int),("field19", Int),("field20", Int),("field21", Int),("field22", Int),("field23", Int),("field24", Int),("field25", Int)) = ("field1" -> 1,"field2" -> 2,"field3" -> 3,"field4" -> 4,"field5" -> 5,"field6" -> 6,"field7" -> 7,"field8" -> 8,"field9" -> 9,"field10" -> 10,"field11" -> 11,"field12" -> 12,"field13" -> 13,"field14" -> 14,"field15" -> 15,"field16" -> 16,"field17" -> 17,"field18" -> 18,"field19" -> 19,"field20" -> 20,"field21" -> 21,"field22" -> 22,"field23" -> 23,"field24" -> 24,"field25" -> 25) diff --git a/tests/run-macros/tasty-simplified/quoted_2.scala b/tests/run-macros/tasty-simplified/quoted_2.scala index 73b1ea4f31cf..dcf100d6e8bb 100644 --- a/tests/run-macros/tasty-simplified/quoted_2.scala +++ b/tests/run-macros/tasty-simplified/quoted_2.scala @@ -18,7 +18,7 @@ object Test { type LiftP[F[_[_]], T[_]] = LiftP0[F, Apply[T]] type LiftP0[F[_[_]], T] <: Tuple = T match { - case Unit => Unit + case EmptyTuple => EmptyTuple case (a *: b) => Unapply[F, Wrap[a]] *: LiftP0[F, b] } diff --git a/tests/run-staging/staged-tuples/StagedTuple.scala b/tests/run-staging/staged-tuples/StagedTuple.scala index 2bd9ec1c5e7c..72a4d7697ad3 100644 --- a/tests/run-staging/staged-tuples/StagedTuple.scala +++ b/tests/run-staging/staged-tuples/StagedTuple.scala @@ -39,7 +39,7 @@ object StagedTuple { if (!specialize) '{scala.runtime.Tuple.fromArray($xs)}.as[T] else xs.bind { xs => val tup: Expr[Any] = size match { - case Some(0) => '{} + case Some(0) => '{Tuple()} case Some(1) => '{Tuple1( $xs(0))} case Some(2) => '{Tuple2( $xs(0), $xs(1))} case Some(3) => '{Tuple3( $xs(0), $xs(1), $xs(2))} @@ -107,7 +107,7 @@ object StagedTuple { else { val res = size match { case Some(1) => - '{} + '{Tuple()} case Some(2) => tup.as[Tuple2[_, _]].bind(t => '{Tuple1($t._2)}) case Some(3) => diff --git a/tests/run-staging/staged-tuples/Test.scala b/tests/run-staging/staged-tuples/Test.scala index 1a699b1f34a7..effd0f4c9d72 100644 --- a/tests/run-staging/staged-tuples/Test.scala +++ b/tests/run-staging/staged-tuples/Test.scala @@ -6,7 +6,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader) - assert(run(fromArrayStaged[Unit]('{ Array.empty[Object] }, Some(0))).==(())) + assert(run(fromArrayStaged[EmptyTuple]('{ Array.empty[Object] }, Some(0))) == Tuple()) assert(run(fromArrayStaged[Tuple1[String]]('{ Array[Object]("a") }, Some(1))) == Tuple1("a")) assert(run(fromArrayStaged[(String, String)]('{ Array[Object]("a", "b") }, Some(2))) == ("a", "b")) assert(run(fromArrayStaged[(String, String, String)]('{ Array[Object]("a", "b", "c") }, Some(3))) == ("a", "b", "c")) @@ -15,7 +15,7 @@ object Test { assert(run(headStaged[(String, String)]('{ ("a", "b") }, Some(2))) == "a") assert(run(headStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3))) == "a") - assert(run(tailStaged[Tuple1[String]]('{ Tuple1("a") }, Some(1))) == (())) + assert(run(tailStaged[Tuple1[String]]('{ Tuple1("a") }, Some(1))) == Tuple()) assert(run(tailStaged[(String, String)]('{ ("a", "b") }, Some(2))) == Tuple1("b")) assert(run(tailStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3))) == ("b", "c")) diff --git a/tests/run/i5257.scala b/tests/run/i5257.scala index 1fd1abe26e11..6d00813fb95c 100644 --- a/tests/run/i5257.scala +++ b/tests/run/i5257.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - val f: Int *: Int *: Unit => Int = (x, y) => x + y + val f: Int *: Int *: EmptyTuple => Int = (x, y) => x + y val g: Int *: Tuple1[Int] => Int = (x, y) => x + y println(f((1, 2))) diff --git a/tests/run/i9011.scala b/tests/run/i9011.scala index e5b488cb1b5d..93891dcc2b0a 100644 --- a/tests/run/i9011.scala +++ b/tests/run/i9011.scala @@ -15,7 +15,7 @@ object Eq { } inline def summonAll[T <: Tuple]: List[Eq[_]] = inline erasedValue[T] match { - case _: Unit => Nil + case _: EmptyTuple => Nil case _: (t *: ts) => summonInline[Eq[t]] :: summonAll[ts] } diff --git a/tests/run/i9056.scala b/tests/run/i9056.scala new file mode 100644 index 000000000000..e7e37a4cf87f --- /dev/null +++ b/tests/run/i9056.scala @@ -0,0 +1,19 @@ + +@main def Test = + ((): Any).isInstanceOf[Tuple] + assert((1, 2).isInstanceOf[Tuple]) + assert((1, 2, 3).isInstanceOf[Tuple]) + assert(!"".isInstanceOf[Tuple]) + assert(!Some("").isInstanceOf[Tuple]) + + assert(!((): Any).isInstanceOf[NonEmptyTuple]) + assert((1, 2).isInstanceOf[NonEmptyTuple]) + assert((1, 2, 3).isInstanceOf[NonEmptyTuple]) + assert(!("": Any).isInstanceOf[NonEmptyTuple]) + assert(!(Some(""): Any).isInstanceOf[NonEmptyTuple]) + + assert(!((): Any).isInstanceOf[_ *: _]) + assert((1, 2).isInstanceOf[_ *: _]) + assert((1, 2, 3).isInstanceOf[_ *: _]) + assert(!("": Any).isInstanceOf[_ *: _]) + assert(!(Some(""): Any).isInstanceOf[_ *: _]) diff --git a/tests/run/tuple-concat.check b/tests/run/tuple-concat.check index 38350e9aba87..9529173cc978 100644 --- a/tests/run/tuple-concat.check +++ b/tests/run/tuple-concat.check @@ -6,4 +6,4 @@ (1,2,3,4,5,6,7,8,9,10) (1,2,3,4,5,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35) (11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,1,2,3,4,5) -(11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60) \ No newline at end of file +(11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60) diff --git a/tests/run/tuple-concat.scala b/tests/run/tuple-concat.scala index a2f75591ab28..e04f51bc3a42 100644 --- a/tests/run/tuple-concat.scala +++ b/tests/run/tuple-concat.scala @@ -1,6 +1,6 @@ object Test extends App { - val emptyTuple: Tuple = () + val emptyTuple: Tuple = Tuple() val tuple1: Tuple = ("1", "2", "3", "4", "5") val tuple2: Tuple = ("6", "7", "8", "9", "10") val tupleXXL1: Tuple = ("11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35") diff --git a/tests/run/tuple-cons.scala b/tests/run/tuple-cons.scala index bae6c0bce3ca..0f8f4e6b9e65 100644 --- a/tests/run/tuple-cons.scala +++ b/tests/run/tuple-cons.scala @@ -1,6 +1,6 @@ object Test extends App { - val emptyTuple: Tuple = () + val emptyTuple: Tuple = Tuple() val tuple: Tuple = ("1", "2", "3", "4", "5") val tupleXXL: Tuple = ("11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35") val tuple22: Tuple = ("36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57") diff --git a/tests/run/tuple-drop.scala b/tests/run/tuple-drop.scala index e995f9a76296..5af45fd2c3bd 100644 --- a/tests/run/tuple-drop.scala +++ b/tests/run/tuple-drop.scala @@ -1,6 +1,6 @@ object Test extends App { - val emptyTuple: Tuple = () + val emptyTuple: Tuple = Tuple() val tuple: Tuple = ("1", "2", "3", "4", "5") val tupleXXL: Tuple = ("11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35") diff --git a/tests/run/tuple-erased.scala b/tests/run/tuple-erased.scala index ebea5d30e782..83a7d81bbac5 100644 --- a/tests/run/tuple-erased.scala +++ b/tests/run/tuple-erased.scala @@ -49,11 +49,11 @@ object Test { assert(t23.isInstanceOf[*:[_, _]]) assert(t24.isInstanceOf[*:[_, _]]) - val x = () + val x = Tuple() assert(x.asInstanceOf[Tuple] == x) assert(x.asInstanceOf[Any] == x) - val y: *:[Int, *:[String, Unit]] = (1, "s") + val y: *:[Int, *:[String, EmptyTuple]] = (1, "s") y: Tuple } } diff --git a/tests/run/tuple-map.scala b/tests/run/tuple-map.scala index 10ddb6bf0241..02c2803a6a27 100644 --- a/tests/run/tuple-map.scala +++ b/tests/run/tuple-map.scala @@ -1,6 +1,6 @@ object Test extends App { - val emptyTuple: Tuple = () + val emptyTuple: Tuple = Tuple() val tuple: Tuple = ("1", "2", "3", "4", "5") val tupleXXL: Tuple = ("11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35") diff --git a/tests/run/tuple-ops.scala b/tests/run/tuple-ops.scala index 93eb7488e432..598c3c7b007a 100644 --- a/tests/run/tuple-ops.scala +++ b/tests/run/tuple-ops.scala @@ -1,7 +1,7 @@ val a: (1, 2, 3) = (1, 2, 3) val b: (4, 5, 6) = (4, 5, 6) val c: (7, 8) = (7, 8) -val d: Unit = () +val d: EmptyTuple = Tuple() // Zip val r1: ((1, 4), (2, 5), (3, 6)) = a.zip(b) diff --git a/tests/run/tuple-product.scala b/tests/run/tuple-product.scala index 4441ee75f1af..2fa176777006 100644 --- a/tests/run/tuple-product.scala +++ b/tests/run/tuple-product.scala @@ -1,9 +1,9 @@ @main def Test = { - val a: Product = 1 *: () + val a: Product = 1 *: Tuple() assert(a.productArity == 1) - val b: Product = 1 *: 2 *: () + val b: Product = 1 *: 2 *: Tuple() assert(b.productArity == 2) - val c: Product = 1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: () + val c: Product = 1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: Tuple() assert(c.productArity == 25) val d: NonEmptyTuple = (1, 2) val e: Product = d diff --git a/tests/run/tuple-split.scala b/tests/run/tuple-split.scala index 2415462af7cf..17a0e851590a 100644 --- a/tests/run/tuple-split.scala +++ b/tests/run/tuple-split.scala @@ -1,6 +1,6 @@ object Test extends App { - val emptyTuple: Tuple = () + val emptyTuple: Tuple = Tuple() val tuple: Tuple = ("1", "2", "3", "4", "5") val tupleXXL: Tuple = ("11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35") diff --git a/tests/run/tuple-take.scala b/tests/run/tuple-take.scala index 54328b38937c..0185f149dcc9 100644 --- a/tests/run/tuple-take.scala +++ b/tests/run/tuple-take.scala @@ -1,6 +1,6 @@ object Test extends App { - val emptyTuple: Tuple = () + val emptyTuple: Tuple = Tuple() val tuple: Tuple = ("1", "2", "3", "4", "5") val tupleXXL: Tuple = ("11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35") diff --git a/tests/run/tuple-typetests.scala b/tests/run/tuple-typetests.scala index c36ad810efe1..f968b293b513 100644 --- a/tests/run/tuple-typetests.scala +++ b/tests/run/tuple-typetests.scala @@ -2,9 +2,9 @@ object Test extends App { def nonEmpty(x: Any) = x match { case _: (h *: t) => true - case () => false + case _: EmptyTuple => false } - println(nonEmpty(())) + println(nonEmpty(Tuple())) println(nonEmpty(1, 2,3)) } \ No newline at end of file diff --git a/tests/run/tuple-zip.scala b/tests/run/tuple-zip.scala index e5f36d7a1583..2a97b803c304 100644 --- a/tests/run/tuple-zip.scala +++ b/tests/run/tuple-zip.scala @@ -1,6 +1,6 @@ object Test extends App { - val emptyTuple: Tuple = () + val emptyTuple: Tuple = Tuple() val tuple1: Tuple = ("1", "2", "3", "4", "5") val tuple2: Tuple = ("6", "7", "8", "9", "10") val tupleXXL1: Tuple = ("11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35") diff --git a/tests/run/tupled-function-apply.scala b/tests/run/tupled-function-apply.scala index 2a0cfd68d7be..16c90e952f6c 100644 --- a/tests/run/tupled-function-apply.scala +++ b/tests/run/tupled-function-apply.scala @@ -2,7 +2,7 @@ object Test { def main(args: Array[String]): Unit = { val f0 = () => 0 - val t0 = () + val t0 = Tuple() println(f0(t0)) val f1 = (x: Int) => x diff --git a/tests/run/tupled-function-untupled.scala b/tests/run/tupled-function-untupled.scala index 576c8aa14052..605836f16909 100644 --- a/tests/run/tupled-function-untupled.scala +++ b/tests/run/tupled-function-untupled.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - val f0 = (args: Unit) => 0 + val f0 = (args: EmptyTuple) => 0 val g0: () => Int = f0.untupled println(g0()) diff --git a/tests/run/tuples-empty.scala b/tests/run/tuples-empty.scala new file mode 100644 index 000000000000..b9bb20485a43 --- /dev/null +++ b/tests/run/tuples-empty.scala @@ -0,0 +1,19 @@ +@main def Test: Unit = { + + val tup0: Tuple = Tuple() + val tup1: Tuple = 1 *: Tuple() + val tup2: Tuple = 1 *: 2 *: Tuple() + + tup0 match + case head *: tail => assert(false) + case Tuple() => // ok + + tup1 match + case Tuple() => assert(false) + case (x) => // ok + + tup2 match + case Tuple() => assert(false) + case (1, 2) => // ok + +} diff --git a/tests/run/tuples1.scala b/tests/run/tuples1.scala index df6fe0377a85..53b2c43852cd 100644 --- a/tests/run/tuples1.scala +++ b/tests/run/tuples1.scala @@ -1,5 +1,5 @@ object Test extends App { - val x0 = (); println(x0) + val x0 = Tuple(); println(x0) val x1 = 1 *: x0; println(x1) val x2 = ("A", 1); println(x2) val x3 = 2 *: x2; println(x3) @@ -14,8 +14,8 @@ object Test extends App { val h2 = x2.head; val h2c: String = h2; println(s"h2 = $h2") val h7 = x7.head; val h7c: Int = h7; println(s"h7 = $h7") val h8 = x8.head; val h8c: String = h8; println(s"h8 = $h8") - val t1 = x1.tail; val t1c: Unit = t1; println(s"t1 = $t1") - val t2 = x2.tail; val t2c: Int *: Unit = t2; println(s"t2 = $t2") + val t1 = x1.tail; val t1c: EmptyTuple = t1; println(s"t1 = $t1") + val t2 = x2.tail; val t2c: Int *: EmptyTuple = t2; println(s"t2 = $t2") val t7 = x7.tail; val t7c: (String, Int) = t7.tail.tail.tail.tail; println(s"t7 = $t7") val t8 = x8.tail; val t8c: Int = t8(6); println(s"t8 = $t8") val a1_0 = x1(0); val a1_0c: Int = a1_0; println(s"a1_0 = $a1_0") @@ -24,9 +24,9 @@ object Test extends App { val a4_3 = x4(3); val a4_3c: Int = a4_3; println(s"a4_3 = $a4_3") val a6_4 = x6(4); val a6_4c: String = a6_4; println(s"a6_4 = $a6_4") val a8_0 = x8(0); val a8_0c: String = a8_0; println(s"a8_0 = $a8_0") - val c0_0 = x0 ++ x0; val c0_0c: Unit = c0_0; println(s"c0_0 = $c0_0") - val c0_1 = x0 ++ x1; val c0_1c: Int *: Unit = c0_1; println(s"c0_1 = $c0_1") - val c1_0 = x1 ++ x0; val c1_0c: Int *: Unit = c1_0; println(s"c1_0 = $c1_0") + val c0_0 = x0 ++ x0; val c0_0c: EmptyTuple = c0_0; println(s"c0_0 = $c0_0") + val c0_1 = x0 ++ x1; val c0_1c: Int *: EmptyTuple = c0_1; println(s"c0_1 = $c0_1") + val c1_0 = x1 ++ x0; val c1_0c: Int *: EmptyTuple = c1_0; println(s"c1_0 = $c1_0") val c0_4 = x0 ++ x4; val c0_4c: (String, Int, String, Int) = c0_4; println(s"c0_4 = $c0_4") val c4_0 = x4 ++ x0; val c4_0c: (String, Int, String, Int) = c4_0; println(s"c4_0 = $c4_0") val c1_1 = x1 ++ x1; val c1_1c: (Int, Int) = c1_1; println(s"c1_1 = $c1_1") @@ -42,7 +42,7 @@ object Test extends App { { val (x, xs) = decompose1 val xc: String = x - val xsc: Int *: Unit = xs + val xsc: Int *: EmptyTuple = xs println(s"$x2 -> $x, $xs") } @@ -54,7 +54,7 @@ object Test extends App { } */ val x3s: 3 = x3.size - val us: 0 = ().size + val us: 0 = Tuple().size // dynamic operations @@ -82,17 +82,17 @@ object Test extends App { def concat[X <: Tuple, Y <: Tuple](x: X, y: Y): Tuple.Concat[X, Y] = x ++ y def concat0(x: Tuple, y: Tuple): Tuple.Concat[x.type, y.type] = x ++ y - val conc1: (String, Int) = concat((), tl1) - val conc2: (String, Int) = concat(tl1, ()) + val conc1: (String, Int) = concat(Tuple(), tl1) + val conc2: (String, Int) = concat(tl1, Tuple()) val conc3: (String, Int, String, Int) = concat(tl1, tl1) - val conc4: (String, Int) = concat0((), tl1) - val conc5: (String, Int) = concat0(tl1, ()) + val conc4: (String, Int) = concat0(Tuple(), tl1) + val conc5: (String, Int) = concat0(tl1, Tuple()) val conc6: (String, Int, String, Int) = concat0(tl1, tl1) def size[X <: Tuple](x: X): Tuple.Size[X] = x.size def size0(x: Tuple): Tuple.Size[x.type] = x.size val x3s0: 3 = size(x3) - val us0: 0 = size(()) + val us0: 0 = size(Tuple()) val x3s1: 3 = size0(x3) - val us1: 0 = size0(()) + val us1: 0 = size0(Tuple()) } diff --git a/tests/run/tuples1a.scala b/tests/run/tuples1a.scala index ee1e5b9aa360..d1764caebf74 100644 --- a/tests/run/tuples1a.scala +++ b/tests/run/tuples1a.scala @@ -1,9 +1,9 @@ object Test extends App { - val t7 = '5' *: 4 *: "C" *: () + val t7 = '5' *: 4 *: "C" *: Tuple() val t7a = t7.tail val t7b = t7a.tail val t7c: Unit = (t7.tail: (Int, String)).tail - val t7d: Unit = (t7.tail: Int *: String *: Unit).tail + val t7d: Unit = (t7.tail: Int *: String *: EmptyTuple).tail val t7e: Unit = t7.tail.tail } diff --git a/tests/run/typeclass-derivation-doc-example.scala b/tests/run/typeclass-derivation-doc-example.scala index cf798c74e770..0d2195ae474d 100644 --- a/tests/run/typeclass-derivation-doc-example.scala +++ b/tests/run/typeclass-derivation-doc-example.scala @@ -2,7 +2,7 @@ import scala.deriving._ import scala.compiletime.{erasedValue, summonInline} inline def summonAll[T <: Tuple]: List[Eq[_]] = inline erasedValue[T] match { - case _: Unit => Nil + case _: EmptyTuple => Nil case _: (t *: ts) => summonInline[Eq[t]] :: summonAll[ts] } diff --git a/tests/run/typeclass-derivation1.scala b/tests/run/typeclass-derivation1.scala index 7e04c73cd1c4..acc18048a75f 100644 --- a/tests/run/typeclass-derivation1.scala +++ b/tests/run/typeclass-derivation1.scala @@ -23,9 +23,9 @@ object Deriving { def fromProduct(xs: (T, Lst[T])): Lst.Cons[T] = Lst.Cons(xs(0), xs(1)).asInstanceOf } - implicit def nilShape[T]: HasProductShape[Lst.Nil.type, Unit] = new { - def toProduct(xs: Lst.Nil.type) = () - def fromProduct(xs: Unit) = Lst.Nil + implicit def nilShape[T]: HasProductShape[Lst.Nil.type, EmptyTuple] = new { + def toProduct(xs: Lst.Nil.type) = Tuple() + def fromProduct(xs: EmptyTuple) = Lst.Nil } implicit def LstEq[T: Eq]: Eq[Lst[T]] = Eq.derivedForSum @@ -50,7 +50,7 @@ object Deriving { } case _ => deriveForSum[alts1](x, y) } - case _: Unit => + case _: EmptyTuple => false } @@ -60,7 +60,7 @@ object Deriving { val ys1 = ys.asInstanceOf[elem *: elems1] tryEq[elem](xs1.head, ys1.head) && deriveForProduct[elems1](xs1.tail, ys1.tail) - case _: Unit => + case _: EmptyTuple => true } diff --git a/tests/run/typeclass-derivation2a.scala b/tests/run/typeclass-derivation2a.scala index 371b66ddb5bc..687c9c436d7c 100644 --- a/tests/run/typeclass-derivation2a.scala +++ b/tests/run/typeclass-derivation2a.scala @@ -128,7 +128,7 @@ object Lst { private type ShapeOf[T] = Shape.Cases[( Shape.Case[Cons[T], (T, Lst[T])], - Shape.Case[Nil.type, Unit] + Shape.Case[Nil.type, EmptyTuple] )] implicit def GenericLst[T]: Generic[Lst[T]] { type Shape = ShapeOf[T] } = @@ -190,8 +190,8 @@ object Either { import genericClass.mirror private type ShapeOf[L, R] = Shape.Cases[( - Shape.Case[Left[L], L *: Unit], - Shape.Case[Right[R], R *: Unit] + Shape.Case[Left[L], L *: EmptyTuple], + Shape.Case[Right[R], R *: EmptyTuple] )] implicit def GenericEither[L, R]: Generic[Either[L, R]] { type Shape = ShapeOf[L, R] } = @@ -229,7 +229,7 @@ object Eq { case _: (elem *: elems1) => tryEql[elem](xm(n).asInstanceOf, ym(n).asInstanceOf) && eqlElems[elems1](xm, ym, n + 1) - case _: Unit => + case _: EmptyTuple => true } @@ -238,7 +238,7 @@ object Eq { case _: (Shape.Case[alt, elems] *: alts1) => if (xm.ordinal == n) eqlElems[elems](xm, ym, 0) else eqlCases[alts1](xm, ym, n + 1) - case _: Unit => + case _: EmptyTuple => false } @@ -280,7 +280,7 @@ object Pickler { case _: (elem *: elems1) => tryPickle[elem](buf, elems(n).asInstanceOf[elem]) pickleElems[elems1](buf, elems, n + 1) - case _: Unit => + case _: EmptyTuple => } inline def pickleCases[Alts <: Tuple](buf: mutable.ListBuffer[Int], xm: Mirror, n: Int): Unit = @@ -288,7 +288,7 @@ object Pickler { case _: (Shape.Case[alt, elems] *: alts1) => if (xm.ordinal == n) pickleElems[elems](buf, xm, 0) else pickleCases[alts1](buf, xm, n + 1) - case _: Unit => + case _: EmptyTuple => } inline def tryUnpickle[T](buf: mutable.ListBuffer[Int]): T = summonInline[Pickler[T]].unpickle(buf) @@ -298,7 +298,7 @@ object Pickler { case _: (elem *: elems1) => elems(n) = tryUnpickle[elem](buf).asInstanceOf[AnyRef] unpickleElems[elems1](buf, elems, n + 1) - case _: Unit => + case _: EmptyTuple => } inline def unpickleCase[T, Elems <: Tuple](gen: Generic[T], buf: mutable.ListBuffer[Int], ordinal: Int): T = { @@ -362,7 +362,7 @@ object Show { val formal = elems.elementLabel(n) val actual = tryShow[elem](elems(n).asInstanceOf) s"$formal = $actual" :: showElems[elems1](elems, n + 1) - case _: Unit => + case _: EmptyTuple => Nil } @@ -371,7 +371,7 @@ object Show { case _: (Shape.Case[alt, elems] *: alts1) => if (xm.ordinal == n) showElems[elems](xm, 0).mkString(", ") else showCases[alts1](xm, n + 1) - case _: Unit => + case _: EmptyTuple => throw new MatchError(xm) } diff --git a/tests/run/typeclass-derivation2b.scala b/tests/run/typeclass-derivation2b.scala index a868efddc0e5..704e8cb2cc9b 100644 --- a/tests/run/typeclass-derivation2b.scala +++ b/tests/run/typeclass-derivation2b.scala @@ -72,7 +72,7 @@ object Lst { } case object Nil extends Lst[Nothing] { class GenericNil extends GenericProduct[Nil.type] { - type Shape = Unit + type Shape = EmptyTuple def toProduct(x: Nil.type): Product = EmptyProduct def fromProduct(p: Product): Nil.type = Nil } @@ -103,7 +103,7 @@ object Eq { x.productElement(n).asInstanceOf[elem], y.productElement(n).asInstanceOf[elem]) && eqlElems[elems1](x, y, n + 1) - case _: Unit => + case _: EmptyTuple => true } @@ -119,7 +119,7 @@ object Eq { 0) } else eqlCases[T, alts1](x, y, genSum, ord, n + 1) - case _: Unit => + case _: EmptyTuple => false } @@ -199,8 +199,8 @@ object Either { import genericClass.mirror private type ShapeOf[L, R] = Shape.Cases[( - Shape.Case[Left[L], L *: Unit], - Shape.Case[Right[R], R *: Unit] + Shape.Case[Left[L], L *: EmptyTuple], + Shape.Case[Right[R], R *: EmptyTuple] )] implicit def GenericEither[L, R]: Generic[Either[L, R]] { type Shape = ShapeOf[L, R] } = @@ -240,7 +240,7 @@ object Eq { case _: (elem *: elems1) => tryEql[elem](xm(n).asInstanceOf, ym(n).asInstanceOf) && eqlElems[elems1](xm, ym, n + 1) - case _: Unit => + case _: EmptyTuple => true } @@ -249,7 +249,7 @@ object Eq { case _: (Shape.Case[alt, elems] *: alts1) => if (xm.ordinal == n) eqlElems[elems](xm, ym, 0) else eqlCases[alts1](xm, ym, n + 1) - case _: Unit => + case _: EmptyTuple => false } @@ -293,7 +293,7 @@ object Pickler { case _: (elem *: elems1) => tryPickle[elem](buf, elems(n).asInstanceOf[elem]) pickleElems[elems1](buf, elems, n + 1) - case _: Unit => + case _: EmptyTuple => } inline def pickleCases[Alts <: Tuple](buf: mutable.ListBuffer[Int], xm: Mirror, n: Int): Unit = @@ -301,7 +301,7 @@ object Pickler { case _: (Shape.Case[alt, elems] *: alts1) => if (xm.ordinal == n) pickleElems[elems](buf, xm, 0) else pickleCases[alts1](buf, xm, n + 1) - case _: Unit => + case _: EmptyTuple => } inline def tryUnpickle[T](buf: mutable.ListBuffer[Int]): T = summonFrom { @@ -313,7 +313,7 @@ object Pickler { case _: (elem *: elems1) => elems(n) = tryUnpickle[elem](buf).asInstanceOf[AnyRef] unpickleElems[elems1](buf, elems, n + 1) - case _: Unit => + case _: EmptyTuple => } inline def unpickleCase[T, Elems <: Tuple](gen: Generic[T], buf: mutable.ListBuffer[Int], ordinal: Int): T = { @@ -379,7 +379,7 @@ object Show { val formal = elems.elementLabel(n) val actual = tryShow[elem](elems(n).asInstanceOf) s"$formal = $actual" :: showElems[elems1](elems, n + 1) - case _: Unit => + case _: EmptyTuple => Nil } @@ -388,7 +388,7 @@ object Show { case _: (Shape.Case[alt, elems] *: alts1) => if (xm.ordinal == n) showElems[elems](xm, 0).mkString(", ") else showCases[alts1](xm, n + 1) - case _: Unit => + case _: EmptyTuple => throw new MatchError(xm) } diff --git a/tests/run/typeclass-derivation2d.scala b/tests/run/typeclass-derivation2d.scala index a67e55d584d9..2705da90f6d1 100644 --- a/tests/run/typeclass-derivation2d.scala +++ b/tests/run/typeclass-derivation2d.scala @@ -108,9 +108,9 @@ object Lst extends Mirror.Sum { implicit def mirror: Mirror.Singleton { type _MonoType = Nil.type - type ElemTypes = Unit + type ElemTypes = EmptyTuple type CaseLabel = "Nil" - type ElemLabels = Unit + type ElemLabels = EmptyTuple } = this.asInstanceOf } @@ -173,9 +173,9 @@ object Left extends Mirror.Product { def _fromProduct(p: Product): Left[_] = Left(productElement[Any](p, 0)) implicit def mirror[L]: Mirror.Product { type _MonoType = Left[L] - type ElemTypes = L *: Unit + type ElemTypes = L *: EmptyTuple type CaseLabel = "Left" - type ElemLabels = "x" *: Unit + type ElemLabels = "x" *: EmptyTuple } = this.asInstanceOf } @@ -184,9 +184,9 @@ object Right extends Mirror.Product { def _fromProduct(p: Product): Right[_] = Right(productElement[Any](p, 0)) implicit def mirror[R]: Mirror.Product { type _MonoType = Right[R] - type ElemTypes = R *: Unit + type ElemTypes = R *: EmptyTuple type CaseLabel = "Right" - type ElemLabels = "x" *: Unit + type ElemLabels = "x" *: EmptyTuple } = this.asInstanceOf } @@ -206,7 +206,7 @@ object Eq { case _: (elem *: elems1) => tryEql[elem](productElement[elem](x, n), productElement[elem](y, n)) && eqlElems[elems1](n + 1)(x, y) - case _: Unit => + case _: EmptyTuple => true } @@ -221,7 +221,7 @@ object Eq { case m: Mirror.ProductOf[`alt`] => eqlElems[m.ElemTypes](0)(x, y) } else eqlCases[alts1](n + 1)(x, y, ord) - case _: Unit => + case _: EmptyTuple => false } @@ -261,7 +261,7 @@ object Pickler { case _: (elem *: elems1) => tryPickle[elem](buf, productElement[elem](x, n)) pickleElems[elems1](n + 1)(buf, x) - case _: Unit => + case _: EmptyTuple => } inline def pickleCases[Alts <: Tuple](n: Int)(buf: mutable.ListBuffer[Int], x: Any, ord: Int): Unit = @@ -272,7 +272,7 @@ object Pickler { case m: Mirror.ProductOf[`alt`] => pickleElems[m.ElemTypes](0)(buf, x) } else pickleCases[alts1](n + 1)(buf, x, ord) - case _: Unit => + case _: EmptyTuple => } inline def tryUnpickle[T](buf: mutable.ListBuffer[Int]): T = @@ -283,7 +283,7 @@ object Pickler { case _: (elem *: elems1) => elems(n) = tryUnpickle[elem](buf).asInstanceOf[AnyRef] unpickleElems[elems1](n + 1)(buf, elems) - case _: Unit => + case _: EmptyTuple => } inline def unpickleCase[T, Elems <: Tuple](buf: mutable.ListBuffer[Int], m: Mirror.ProductOf[T]): T = { @@ -306,7 +306,7 @@ object Pickler { unpickleCase[`alt` & T, m.ElemTypes](buf, m) } else unpickleCases[T, alts1](n + 1)(buf, ord) - case _: Unit => + case _: EmptyTuple => throw new IndexOutOfBoundsException(s"unexpected ordinal number: $ord") } @@ -355,7 +355,7 @@ object Show { val actual = tryShow(productElement[elem](x, n)) s"$formal = $actual" :: showElems[elems1, labels1](n + 1)(x) } - case _: Unit => + case _: EmptyTuple => Nil } @@ -376,7 +376,7 @@ object Show { showCase(x, m) } else showCases[alts1](n + 1)(x, ord) - case _: Unit => + case _: EmptyTuple => throw new MatchError(x) } diff --git a/tests/run/typeclass-derivation3.scala b/tests/run/typeclass-derivation3.scala index d855ecd79f4c..3a879908cb69 100644 --- a/tests/run/typeclass-derivation3.scala +++ b/tests/run/typeclass-derivation3.scala @@ -44,7 +44,7 @@ object typeclasses { case _: (elem *: elems1) => tryEql[elem](productElement[elem](x, n), productElement[elem](y, n)) && eqlElems[elems1](n + 1)(x, y) - case _: Unit => + case _: EmptyTuple => true } @@ -59,7 +59,7 @@ object typeclasses { case m: Mirror.ProductOf[`alt`] => eqlElems[m.MirroredElemTypes](0)(x, y) } else eqlCases[alts1](n + 1)(x, y, ord) - case _: Unit => + case _: EmptyTuple => false } @@ -101,7 +101,7 @@ object typeclasses { case _: (elem *: elems1) => tryPickle[elem](buf, productElement[elem](x, n)) pickleElems[elems1](n + 1)(buf, x) - case _: Unit => + case _: EmptyTuple => } inline def pickleCases[Alts <: Tuple](n: Int)(buf: mutable.ListBuffer[Int], x: Any, ord: Int): Unit = @@ -112,7 +112,7 @@ object typeclasses { case m: Mirror.ProductOf[`alt`] => pickleElems[m.MirroredElemTypes](0)(buf, x) } else pickleCases[alts1](n + 1)(buf, x, ord) - case _: Unit => + case _: EmptyTuple => } inline def tryUnpickle[T](buf: mutable.ListBuffer[Int]): T = summonFrom { @@ -124,7 +124,7 @@ object typeclasses { case _: (elem *: elems1) => elems(n) = tryUnpickle[elem](buf).asInstanceOf[AnyRef] unpickleElems[elems1](n + 1)(buf, elems) - case _: Unit => + case _: EmptyTuple => } inline def unpickleCase[T, Elems <: Tuple](buf: mutable.ListBuffer[Int], m: Mirror.ProductOf[T]): T = { @@ -147,7 +147,7 @@ object typeclasses { unpickleCase[`alt` & T, m.MirroredElemTypes](buf, m) } else unpickleCases[T, alts1](n + 1)(buf, ord) - case _: Unit => + case _: EmptyTuple => throw new IndexOutOfBoundsException(s"unexpected ordinal number: $ord") } @@ -197,7 +197,7 @@ object typeclasses { val actual = tryShow(productElement[elem](x, n)) s"$formal = $actual" :: showElems[elems1, labels1](n + 1)(x) } - case _: Unit => + case _: EmptyTuple => Nil } @@ -214,7 +214,7 @@ object typeclasses { case _: (alt *: alts1) => if (ord == n) showCase(x, summonInline[Mirror.ProductOf[`alt`]]) else showCases[alts1](n + 1)(x, ord) - case _: Unit => + case _: EmptyTuple => throw new MatchError(x) }