Skip to content

Fix #5269: Fix StagedTuple/Tuple implementation #5321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class CompilationTests extends ParallelTesting {
@Test def runAll: Unit = {
implicit val testGroup: TestGroup = TestGroup("runAll")
compileFilesInDir("tests/run-custom-args/Yretain-trees", defaultOptions and "-Yretain-trees") +
compileFile("tests/run-custom-args/tuple-cons.scala", allowDeepSubtypes) +
compileFilesInDir("tests/run", defaultOptions)
}.checkRuns()

Expand Down
4 changes: 2 additions & 2 deletions library/src-scala3/scala/StagedTuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object StagedTuple {

def fromArrayStaged[T <: Tuple : Type](xs: Expr[Array[Object]], size: Option[Int]): Expr[T] = {
if (!specialize) '(dynamicFromArray[T](~xs))
else {
else xs.bind { xs =>
val tup: Expr[Any] = size match {
case Some(0) => '()
case Some(1) => '(Tuple1( (~xs)(0)))
Expand Down Expand Up @@ -190,7 +190,7 @@ object StagedTuple {
case Some(4) =>
self.as[Tuple4[_, _, _, _]].bind(t => '(Tuple5(~x, (~t)._1, (~t)._2, (~t)._3, (~t)._4)))
case Some(n) =>
fromArrayStaged('($consArray(~x, ~toArrayStaged(self, tailSize))), Some(n + 1))
fromArrayStaged[H *: T]('($consArray(~x, ~toArrayStaged(self, tailSize))), Some(n + 1))
case _ =>
'(dynamic_*:[T, H](~self, ~x))
}
Expand Down
2 changes: 1 addition & 1 deletion library/src-scala3/scala/Tuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ object Tuple {
val t = self.asInstanceOf[Tuple4[Object, Object, Object, Object]]
Array(t._1, t._2, t._3, t._4)
case self: TupleXXL =>
asInstanceOf[TupleXXL].elems
self.elems
case self: Product =>
val arr = new Array[Object](self.productArity)
for (i <- 0 until arr.length) arr(i) = self.productElement(i).asInstanceOf[Object]
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions tests/run/tuple-cons-2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

object Test {
def main(args: Array[String]): Unit = {
val t6: (Int,Int,Int,Int,Int,Int) = 1 *: (2, 3, 4, 5, 6)
println(t6)
}
}