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 a1c39f40bf48..a874330e3a0e 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 @@ -1,7 +1,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ -import scala.runtime.DynamicTuple @State(Scope.Thread) class Apply { 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 3dc15c632f61..70e5f84d0bb0 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 @@ -2,7 +2,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ import org.openjdk.jmh.infra.Blackhole -import scala.runtime.DynamicTuple @State(Scope.Thread) class Concat { 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 adfa3d9694e8..b2a98014728f 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 @@ -1,7 +1,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ -import scala.runtime.DynamicTuple @State(Scope.Thread) class Cons { 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 37b8eefc0592..7322ac220156 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 @@ -1,7 +1,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ -import scala.runtime.DynamicTuple @State(Scope.Thread) class Conversions { 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 b145e7508ea1..317de969736e 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 @@ -1,7 +1,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ -import scala.runtime.DynamicTuple @State(Scope.Thread) class Map { 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 1446a02e05b4..88acf9f174ee 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 @@ -1,7 +1,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ -import scala.runtime.DynamicTuple @State(Scope.Thread) class Tail { 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 28c8789d6bee..d92e8666102b 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 @@ -1,7 +1,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ -import scala.runtime.DynamicTuple @State(Scope.Thread) class Zip { diff --git a/bench-run/src/main/scala/tuples/Drop.scala b/bench-run/src/main/scala/tuples/Drop.scala index d9b8924b5324..bfeab387ca09 100644 --- a/bench-run/src/main/scala/tuples/Drop.scala +++ b/bench-run/src/main/scala/tuples/Drop.scala @@ -1,7 +1,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ -import scala.runtime.DynamicTuple @State(Scope.Thread) class Drop { diff --git a/bench-run/src/main/scala/tuples/Split.scala b/bench-run/src/main/scala/tuples/Split.scala index 23cbc0c23148..a63e061f0bc6 100644 --- a/bench-run/src/main/scala/tuples/Split.scala +++ b/bench-run/src/main/scala/tuples/Split.scala @@ -1,7 +1,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ -import scala.runtime.DynamicTuple @State(Scope.Thread) class Split { diff --git a/bench-run/src/main/scala/tuples/Take.scala b/bench-run/src/main/scala/tuples/Take.scala index ec3762e33889..1d81201aed82 100644 --- a/bench-run/src/main/scala/tuples/Take.scala +++ b/bench-run/src/main/scala/tuples/Take.scala @@ -1,7 +1,6 @@ package dotty.tools.benchmarks.tuples import org.openjdk.jmh.annotations._ -import scala.runtime.DynamicTuple @State(Scope.Thread) class Take { diff --git a/library/src/scala/Tuple.scala b/library/src/scala/Tuple.scala index 032364a0c14b..db983f55e835 100644 --- a/library/src/scala/Tuple.scala +++ b/library/src/scala/Tuple.scala @@ -3,8 +3,6 @@ import annotation.showAsInfix import compiletime._ import internal._ -import scala.runtime.DynamicTuple - /** Tuple of arbitrary arity */ sealed trait Tuple extends Any { import Tuple._ diff --git a/library/src/scala/runtime/DynamicTupleOld.scala b/library/src/scala/runtime/DynamicTupleOld.scala deleted file mode 100644 index 2950349f8a85..000000000000 --- a/library/src/scala/runtime/DynamicTupleOld.scala +++ /dev/null @@ -1,59 +0,0 @@ -package scala.runtime - -@deprecated("Use scala.runtime.Tuple", "") -object DynamicTuple { - - inline val MaxSpecialized = 22 - - @deprecated("use toArray", "") - def dynamicToArray(self: Tuple): Array[Object] = scala.runtime.Tuple.toArray(self) - - @deprecated("use toIArray", "") - def dynamicToIArray(self: Tuple): IArray[Object] = scala.runtime.Tuple.toIArray(self) - - @deprecated("Use fromArray") - def dynamicFromArray[T <: Tuple](xs: Array[Object]): T = scala.runtime.Tuple.fromArray(xs).asInstanceOf[T] - - @deprecated("Use fromIArray", "") - def dynamicFromIArray[T <: Tuple](xs: IArray[Object]): T = scala.runtime.Tuple.fromIArray(xs).asInstanceOf[T] - - @deprecated("Use fromProduct", "") - def dynamicFromProduct[T <: Tuple](xs: Product): T = scala.runtime.Tuple.fromProduct(xs).asInstanceOf[T] - - @deprecated("Use cons", "") - def dynamicCons[H, This <: Tuple](x: H, self: This): H *: This = scala.runtime.Tuple.cons(x, self).asInstanceOf[H *: This] - - @deprecated("Use concat", "") - def dynamicConcat[This <: Tuple, That <: Tuple](self: This, that: That): scala.Tuple.Concat[This, That] = scala.runtime.Tuple.concat(self, that).asInstanceOf[scala.Tuple.Concat[This, That]] - - @deprecated("Use size", "") - def dynamicSize[This <: Tuple](self: This): scala.Tuple.Size[This] = scala.runtime.Tuple.size(self).asInstanceOf[scala.Tuple.Size[This]] - - @deprecated("Use tail", "") - def dynamicTail[This <: NonEmptyTuple](self: This): scala.Tuple.Tail[This] = scala.runtime.Tuple.tail(self).asInstanceOf[scala.Tuple.Tail[This]] - - @deprecated("Use apply", "") - def dynamicApply[This <: NonEmptyTuple, N <: Int](self: This, n: N): scala.Tuple.Elem[This, N] = scala.runtime.Tuple.apply(self, n).asInstanceOf[scala.Tuple.Elem[This, N]] - - @deprecated("Use zip", "") - def dynamicZip[This <: Tuple, T2 <: Tuple](t1: This, t2: T2): scala.Tuple.Zip[This, T2] = scala.runtime.Tuple.zip(t1, t2).asInstanceOf[scala.Tuple.Zip[This, T2]] - - @deprecated("Use map", "") - def dynamicMap[This <: Tuple, F[_]](self: This, f: [t] => t => F[t]): scala.Tuple.Map[This, F] = scala.runtime.Tuple.map(self, f).asInstanceOf[scala.Tuple.Map[This, F]] - - @deprecated("Use take", "") - def dynamicTake[This <: Tuple, N <: Int](self: This, n: N): scala.Tuple.Take[This, N] = scala.runtime.Tuple.take(self, n).asInstanceOf[scala.Tuple.Take[This, N]] - - @deprecated("Use drop", "") - def dynamicDrop[This <: Tuple, N <: Int](self: This, n: N): scala.Tuple.Drop[This, N] = scala.runtime.Tuple.drop(self, n).asInstanceOf[scala.Tuple.Drop[This, N]] - - @deprecated("Use splitAt", "") - def dynamicSplitAt[This <: Tuple, N <: Int](self: This, n: N): scala.Tuple.Split[This, N] = scala.runtime.Tuple.splitAt(self, n).asInstanceOf[scala.Tuple.Split[This, N]] - - def consIterator(head: Any, tail: Tuple): Iterator[Any] = - Iterator.single(head) ++ tail.asInstanceOf[Product].productIterator - - def concatIterator(tup1: Tuple, tup2: Tuple): Iterator[Any] = - tup1.asInstanceOf[Product].productIterator ++ tup2.asInstanceOf[Product].productIterator - -} diff --git a/tests/run-staging/staged-tuples/StagedTuple.scala b/tests/run-staging/staged-tuples/StagedTuple.scala index d4e0e7999718..23eadeda91f6 100644 --- a/tests/run-staging/staged-tuples/StagedTuple.scala +++ b/tests/run-staging/staged-tuples/StagedTuple.scala @@ -4,18 +4,19 @@ import scala.quoted._ import scala.runtime.TupleXXL +import scala.runtime.Tuple.MaxSpecialized + object StagedTuple { import Tuple.Concat import Tuple.Head import Tuple.Tail import Tuple.Size import Tuple.Elem - import scala.runtime.DynamicTuple._ private final val specialize = true def toArrayStaged(tup: Expr[Tuple], size: Option[Int])(using QuoteContext): Expr[Array[Object]] = { - if (!specialize) '{dynamicToArray($tup)} + if (!specialize) '{scala.runtime.Tuple.toArray($tup)} else size match { case Some(0) => '{Array.emptyObjectArray} @@ -30,12 +31,12 @@ object StagedTuple { case Some(n) => '{ ${tup.as[TupleXXL]}.toArray } case None => - '{dynamicToArray($tup)} + '{scala.runtime.Tuple.toArray($tup)} } } def fromArrayStaged[T <: Tuple : Type](xs: Expr[Array[Object]], size: Option[Int])(using QuoteContext): Expr[T] = { - if (!specialize) '{dynamicFromArray[T]($xs)} + if (!specialize) '{scala.runtime.Tuple.fromArray($xs)}.as[T] else xs.bind { xs => val tup: Expr[Any] = size match { case Some(0) => '{} @@ -62,7 +63,7 @@ object StagedTuple { case Some(21) => '{Tuple21($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14), $xs(15), $xs(16), $xs(17), $xs(18), $xs(19), $xs(20))} case Some(22) => '{Tuple22($xs(0), $xs(1), $xs(2), $xs(3), $xs(4), $xs(5), $xs(6), $xs(7), $xs(8), $xs(9), $xs(10), $xs(11), $xs(12), $xs(13), $xs(14), $xs(15), $xs(16), $xs(17), $xs(18), $xs(19), $xs(20), $xs(21))} case Some(_) => '{TupleXXL($xs)} - case None => '{dynamicFromArray[T]($xs)} + case None => '{scala.runtime.Tuple.fromArray($xs)} } tup.as[T] } @@ -70,16 +71,16 @@ object StagedTuple { def sizeStaged[Res <: Int : Type](tup: Expr[Tuple], size: Option[Int])(using QuoteContext): Expr[Res] = { val res = - if (!specialize) '{dynamicSize($tup)} + if (!specialize) '{scala.runtime.Tuple.size($tup)} else size match { case Some(n) => Expr(n) - case None => '{dynamicSize($tup)} + case None => '{scala.runtime.Tuple.size($tup)} } res.as[Res] } def headStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int])(using QuoteContext): Expr[Head[Tup]] = { - if (!specialize) '{dynamicApply[Tup, 0]($tup, 0)} + if (!specialize) '{scala.runtime.Tuple.apply($tup, 0)}.as[Head[Tup]] else { val resVal = size match { case Some(1) => @@ -95,14 +96,14 @@ object StagedTuple { case Some(n) if n > MaxSpecialized => '{${tup.as[TupleXXL] }.elems(0)} case None => - '{dynamicApply($tup, 0)} + '{scala.runtime.Tuple.apply($tup, 0)} } resVal.as[Head[Tup]] } } def tailStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int])(using QuoteContext): Expr[Tail[Tup]] = { - if (!specialize) '{dynamicTail[Tup]($tup)} + if (!specialize) '{scala.runtime.Tuple.tail($tup)}.as[Tail[Tup]] else { val res = size match { case Some(1) => @@ -119,7 +120,7 @@ object StagedTuple { val arr = toArrayStaged(tup, size) fromArrayStaged[Tail[Tup]]('{ $arr.tail }, Some(n - 1)) case None => - '{dynamicTail($tup)} + '{scala.runtime.Tuple.tail($tup)} } res.as[Tail[Tup]] } @@ -127,13 +128,13 @@ object StagedTuple { def applyStaged[Tup <: NonEmptyTuple : Type, N <: Int : Type](tup: Expr[Tup], size: Option[Int], n: Expr[N], nValue: Option[Int])(using qctx: QuoteContext): Expr[Elem[Tup, N]] = { - if (!specialize) '{dynamicApply($tup, $n)} + if (!specialize) '{scala.runtime.Tuple.apply($tup, $n)}.as[Elem[Tup, N]] else { def fallbackApply(): Expr[Elem[Tup, N]] = nValue match { case Some(n) => qctx.error("index out of bounds: " + n, tup) '{ throw new IndexOutOfBoundsException(${Expr(n.toString)}) } - case None => '{dynamicApply($tup, $n)} + case None => '{scala.runtime.Tuple.apply($tup, $n)}.as[Elem[Tup, N]] } val res = size match { case Some(1) => @@ -185,7 +186,7 @@ object StagedTuple { } def consStaged[T <: Tuple & Singleton : Type, H : Type](self: Expr[T], x: Expr[H], tailSize: Option[Int])(using QuoteContext): Expr[H *: T] = - if (!specialize) '{dynamicCons[H, T]($x, $self)} + if (!specialize) '{scala.runtime.Tuple.cons($x, $self)}.as[H *: T] else { val res = tailSize match { case Some(0) => @@ -199,13 +200,13 @@ object StagedTuple { case Some(4) => self.as[Tuple4[_, _, _, _]].bind(t => '{Tuple5($x, $t._1, $t._2, $t._3, $t._4)}) case _ => - '{dynamicCons[H, T]($x, $self)} + '{scala.runtime.Tuple.cons($x, $self)} } res.as[H *: T] } def concatStaged[Self <: Tuple & Singleton : Type, That <: Tuple & Singleton : Type](self: Expr[Self], selfSize: Option[Int], that: Expr[That], thatSize: Option[Int])(using QuoteContext): Expr[Concat[Self, That]] = { - if (!specialize) '{dynamicConcat[Self, That]($self, $that)} + if (!specialize) '{scala.runtime.Tuple.concat($self, $that)}.as[Concat[Self, That]] else { def genericConcat(xs: Expr[Tuple], ys: Expr[Tuple]): Expr[Tuple] = // TODO remove ascriptions when #6126 is fixed @@ -247,7 +248,7 @@ object StagedTuple { if (thatSize.contains(0)) self else genericConcat(self, that) case None => - '{dynamicConcat($self, $that)} + '{scala.runtime.Tuple.concat($self, $that)} } res.as[Concat[Self, That]] }