diff options
author | Tiark Rompf <tiark.rompf@epfl.ch> | 2010-03-22 16:52:10 +0000 |
---|---|---|
committer | Tiark Rompf <tiark.rompf@epfl.ch> | 2010-03-22 16:52:10 +0000 |
commit | a263215e095d8168ed78b16c829a56ff48b2f9b6 (patch) | |
tree | 3ae5da4071776d431c75bdf2eef64c4911ea24e8 | |
parent | 1935b66102808cc72262cffca3546f4bb5b7baac (diff) | |
download | scala-a263215e095d8168ed78b16c829a56ff48b2f9b6.tar.gz scala-a263215e095d8168ed78b16c829a56ff48b2f9b6.tar.bz2 scala-a263215e095d8168ed78b16c829a56ff48b2f9b6.zip |
closes #3199. review by community.
-rw-r--r-- | src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala | 5 | ||||
-rw-r--r-- | test/files/continuations-run/t3199.check | 1 | ||||
-rw-r--r-- | test/files/continuations-run/t3199.scala | 20 | ||||
-rw-r--r-- | test/files/continuations-run/t3199b.check | 1 | ||||
-rw-r--r-- | test/files/continuations-run/t3199b.scala | 11 |
5 files changed, 37 insertions, 1 deletions
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala index a09772d236..5bad9e960c 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala @@ -234,8 +234,11 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with case Typed(expr0, tpt) => // TODO: should x: A @cps[B,C] have a special meaning? + // type casts used in different ways (see match2.scala, #3199) val (stms, expr, spc) = transInlineValue(expr0, cpsA) - val tpt1 = treeCopy.TypeTree(tpt).setType(removeAllCPSAnnotations(tpt.tpe)) + val tpt1 = if (treeInfo.isWildcardStarArg(tree)) tpt else + treeCopy.TypeTree(tpt).setType(removeAllCPSAnnotations(tpt.tpe)) +// (stms, updateSynthFlag(treeCopy.Typed(tree, expr, tpt1)), spc) (stms, treeCopy.Typed(tree, expr, tpt1).setType(removeAllCPSAnnotations(tree.tpe)), spc) case TypeApply(fun, args) => diff --git a/test/files/continuations-run/t3199.check b/test/files/continuations-run/t3199.check new file mode 100644 index 0000000000..a065247b8c --- /dev/null +++ b/test/files/continuations-run/t3199.check @@ -0,0 +1 @@ +Right(7) diff --git a/test/files/continuations-run/t3199.scala b/test/files/continuations-run/t3199.scala new file mode 100644 index 0000000000..3fd2f1959a --- /dev/null +++ b/test/files/continuations-run/t3199.scala @@ -0,0 +1,20 @@ +import _root_.scala.collection.Seq +import _root_.scala.util.control.Exception +import _root_.scala.util.continuations._ + +object Test { + + trait AbstractResource[+R <: AnyRef] { + def reflect[B] : R @cpsParam[B,Either[Throwable, B]] = shift(acquireFor) + def acquireFor[B](f : R => B) : Either[Throwable, B] = { + import Exception._ + catching(List(classOf[Throwable]) : _*) either (f(null.asInstanceOf[R])) + } + } + + def main(args: Array[String]) : Unit = { + val x = new AbstractResource[String] { } + val result = x.acquireFor( x => 7 ) + println(result) + } + } diff --git a/test/files/continuations-run/t3199b.check b/test/files/continuations-run/t3199b.check new file mode 100644 index 0000000000..b5d8bb58d9 --- /dev/null +++ b/test/files/continuations-run/t3199b.check @@ -0,0 +1 @@ +[1, 2, 3] diff --git a/test/files/continuations-run/t3199b.scala b/test/files/continuations-run/t3199b.scala new file mode 100644 index 0000000000..950c584153 --- /dev/null +++ b/test/files/continuations-run/t3199b.scala @@ -0,0 +1,11 @@ +object Test { + + def test() = { + java.util.Arrays.asList(Array(1,2,3):_*) + } + + def main(args: Array[String]) = { + println(test()) + } + +}
\ No newline at end of file |