diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-07-09 10:50:52 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-07-09 10:50:52 +1000 |
commit | e4053220e091988e883f87d66459f329d5a39920 (patch) | |
tree | a8c95fdf158b9f4ca7cf766e8569d28ef33d9b4d /src/test | |
parent | 2d8506a64392cd7192b6831c38798cc9a7c8bfed (diff) | |
download | scala-async-e4053220e091988e883f87d66459f329d5a39920.tar.gz scala-async-e4053220e091988e883f87d66459f329d5a39920.tar.bz2 scala-async-e4053220e091988e883f87d66459f329d5a39920.zip |
Fix "BoxedUnit cannot be cast to String" error.
When convering If and Match nodes to ANF, set the type to Unit.
Otherwise, erasure might end up casting BoxedUnit to a real type.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/scala/scala/async/run/match0/Match0.scala | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/scala/scala/async/run/match0/Match0.scala b/src/test/scala/scala/async/run/match0/Match0.scala index 49a3a69..7c392ab 100644 --- a/src/test/scala/scala/async/run/match0/Match0.scala +++ b/src/test/scala/scala/async/run/match0/Match0.scala @@ -125,4 +125,25 @@ class MatchSpec { } m4("") mustBe 0 } + + @Test def bugCastBoxedUnitToStringMatch() { + import scala.async.internal.AsyncId.{async, await} + def foo = async { + val p2 = await(5) + "foo" match { + case p3: String => + p2.toString + } + } + foo mustBe "5" + } + + @Test def bugCastBoxedUnitToStringIf() { + import scala.async.internal.AsyncId.{async, await} + def foo = async { + val p2 = await(5) + if (true) p2.toString else p2.toString + } + foo mustBe "5" + } } |