From 18ebd6b2adc2c672a441ec45359eff2de5757c0f Mon Sep 17 00:00:00 2001 From: Antoine Brunner Date: Fri, 4 Oct 2019 11:50:19 +0200 Subject: [PATCH 1/3] Fix unreachable code in DynamicTuple.dynamiamicConcat --- library/src/scala/runtime/DynamicTuple.scala | 4 ++-- tests/run/tuple-concat.check | 5 +++++ tests/run/tuple-concat.scala | 13 +++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/run/tuple-concat.check create mode 100644 tests/run/tuple-concat.scala diff --git a/library/src/scala/runtime/DynamicTuple.scala b/library/src/scala/runtime/DynamicTuple.scala index 031b36a4eefd..ae75f133a5c1 100644 --- a/library/src/scala/runtime/DynamicTuple.scala +++ b/library/src/scala/runtime/DynamicTuple.scala @@ -212,8 +212,8 @@ object DynamicTuple { def dynamicConcat[This <: Tuple, That <: Tuple](self: This, that: That): Concat[This, That] = { type Result = Concat[This, That] - (this: Any) match { - case self: Unit => return self.asInstanceOf[Result] + (self: Any) match { + case self: Unit => return that.asInstanceOf[Result] case _ => } (that: Any) match { diff --git a/tests/run/tuple-concat.check b/tests/run/tuple-concat.check new file mode 100644 index 000000000000..32888b26a398 --- /dev/null +++ b/tests/run/tuple-concat.check @@ -0,0 +1,5 @@ +tuple1 ++ emptyTuple = (e1,e2,e3) +emptyTuple ++ tuple1 = (e1,e2,e3) +tuple2 ++ emptyTuple = (e4,e5,e6) +emptyTuple ++ tuple2 = (e4,e5,e6) +tuple1 ++ tuple2 = (e1,e2,e3,e4,e5,e6) diff --git a/tests/run/tuple-concat.scala b/tests/run/tuple-concat.scala new file mode 100644 index 000000000000..3ce5f1f2d1dc --- /dev/null +++ b/tests/run/tuple-concat.scala @@ -0,0 +1,13 @@ + +object Test extends App { + val emptyTuple: Tuple = () + val tuple1: Tuple = "e1" *: "e2" *: "e3" *: () + val tuple2: Tuple = "e4" *: "e5" *: "e6" *: () + val result: Tuple = "e1" *: "e2" *: "e3" *: "e4" *: "e5" *: "e6" *: () + + println("tuple1 ++ emptyTuple = " + (tuple1 ++ emptyTuple)) + println("emptyTuple ++ tuple1 = " + (emptyTuple ++ tuple1)) + println("tuple2 ++ emptyTuple = " + (tuple2 ++ emptyTuple)) + println("emptyTuple ++ tuple2 = " + (emptyTuple ++ tuple2)) + println("tuple1 ++ tuple2 = " + (tuple1 ++ tuple2)) +} From c0faa2227046a86bd3f4c307dc7e4794a024af53 Mon Sep 17 00:00:00 2001 From: brunnerant <33020895+brunnerant@users.noreply.github.com> Date: Fri, 4 Oct 2019 14:14:04 +0200 Subject: [PATCH 2/3] Update tests/run/tuple-concat.scala Check that concatenation with an empty tuple returns the original reference Co-Authored-By: Nicolas Stucki --- tests/run/tuple-concat.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/run/tuple-concat.scala b/tests/run/tuple-concat.scala index 3ce5f1f2d1dc..648c186db354 100644 --- a/tests/run/tuple-concat.scala +++ b/tests/run/tuple-concat.scala @@ -10,4 +10,6 @@ object Test extends App { println("tuple2 ++ emptyTuple = " + (tuple2 ++ emptyTuple)) println("emptyTuple ++ tuple2 = " + (emptyTuple ++ tuple2)) println("tuple1 ++ tuple2 = " + (tuple1 ++ tuple2)) + assert((tuple1 ++ emptyTuple) eq tuple1) + assert((emptyTuple ++tuple1) eq tuple1) } From 4db4831c151e75f89545e37e52f7399229f281ec Mon Sep 17 00:00:00 2001 From: Antoine Brunner Date: Fri, 4 Oct 2019 18:25:14 +0200 Subject: [PATCH 3/3] Fixed problem m in reference equality on tuples --- tests/run/tuple-concat.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run/tuple-concat.scala b/tests/run/tuple-concat.scala index 648c186db354..86b6e428f2c9 100644 --- a/tests/run/tuple-concat.scala +++ b/tests/run/tuple-concat.scala @@ -10,6 +10,6 @@ object Test extends App { println("tuple2 ++ emptyTuple = " + (tuple2 ++ emptyTuple)) println("emptyTuple ++ tuple2 = " + (emptyTuple ++ tuple2)) println("tuple1 ++ tuple2 = " + (tuple1 ++ tuple2)) - assert((tuple1 ++ emptyTuple) eq tuple1) - assert((emptyTuple ++tuple1) eq tuple1) + assert((tuple1 ++ emptyTuple).asInstanceOf[AnyRef] eq tuple1.asInstanceOf[AnyRef]) + assert((emptyTuple ++tuple1).asInstanceOf[AnyRef] eq tuple1.asInstanceOf[AnyRef]) }