Skip to content

Commit 3d9b5d1

Browse files
committed
Fix #5269: Fix StagedTuple/Tuple implementation
1 parent 54cc7f5 commit 3d9b5d1

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class CompilationTests extends ParallelTesting {
171171
@Test def runAll: Unit = {
172172
implicit val testGroup: TestGroup = TestGroup("runAll")
173173
compileFilesInDir("tests/run-custom-args/Yretain-trees", defaultOptions and "-Yretain-trees") +
174+
compileFile("tests/run-custom-args/tuple-cons.scala", allowDeepSubtypes) +
174175
compileFilesInDir("tests/run", defaultOptions)
175176
}.checkRuns()
176177

library/src-scala3/scala/StagedTuple.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ object StagedTuple {
190190
case Some(4) =>
191191
self.as[Tuple4[_, _, _, _]].bind(t => '(Tuple5(~x, (~t)._1, (~t)._2, (~t)._3, (~t)._4)))
192192
case Some(n) =>
193-
fromArrayStaged('($consArray(~x, ~toArrayStaged(self, tailSize))), Some(n + 1))
193+
fromArrayStaged[H *: T]('($consArray(~x, ~toArrayStaged(self, tailSize))), Some(n + 1))
194194
case _ =>
195195
'(dynamic_*:[T, H](~self, ~x))
196196
}

library/src-scala3/scala/Tuple.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ object Tuple {
131131
val t = self.asInstanceOf[Tuple4[Object, Object, Object, Object]]
132132
Array(t._1, t._2, t._3, t._4)
133133
case self: TupleXXL =>
134-
asInstanceOf[TupleXXL].elems
134+
self.elems
135135
case self: Product =>
136136
val arr = new Array[Object](self.productArity)
137137
for (i <- 0 until arr.length) arr(i) = self.productElement(i).asInstanceOf[Object]

tests/run/tuple-cons-2.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
object Test {
3+
def main(args: Array[String]): Unit = {
4+
val t6: (Int,Int,Int,Int,Int,Int) = 1 *: (2, 3, 4, 5, 6)
5+
println(t6)
6+
}
7+
}

0 commit comments

Comments
 (0)