summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-12-02 17:10:35 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-12-13 17:36:16 -0800
commit858a5d513779f4af6f12c0a530bdeceb7a7fd4d9 (patch)
treebecda6df1363a92c1fcdf39643433ba101de4c10
parent7e74aa6b134bcaf158bd51aa7a63a4aaa8fee62e (diff)
downloadscala-858a5d513779f4af6f12c0a530bdeceb7a7fd4d9.tar.gz
scala-858a5d513779f4af6f12c0a530bdeceb7a7fd4d9.tar.bz2
scala-858a5d513779f4af6f12c0a530bdeceb7a7fd4d9.zip
Modularize continuations plugin.
The continuations plugin and library will still ship with 2.11 (albeit unsupported). They now reside at https://github.com/scala/scala-continuations.
-rw-r--r--build-ant-macros.xml4
-rwxr-xr-xbuild.xml127
-rw-r--r--dbuild-meta.json12
-rw-r--r--src/build/bnd/continuations.bnd5
-rw-r--r--src/build/bnd/scala-continuations-library.bnd5
-rw-r--r--src/build/bnd/scala-continuations-plugin.bnd5
-rw-r--r--src/build/dbuild-meta-json-gen.scala3
-rw-r--r--src/build/maven/maven-deploy.xml1
-rw-r--r--src/build/maven/plugins/continuations-pom.xml59
-rw-r--r--src/continuations/library/scala/util/continuations/ControlContext.scala249
-rw-r--r--src/continuations/library/scala/util/continuations/package.scala187
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala520
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala137
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala545
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala56
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala383
-rw-r--r--src/continuations/plugin/scalac-plugin.xml5
-rw-r--r--src/eclipse/continuations-library/.classpath8
-rw-r--r--src/eclipse/continuations-library/.project30
-rw-r--r--src/eclipse/continuations-library/.settings/org.scala-ide.sdt.core.prefs2
-rw-r--r--src/eclipse/reflect/.classpath1
-rw-r--r--src/eclipse/scala-compiler/.classpath1
-rw-r--r--src/eclipse/test-junit/.classpath1
-rw-r--r--src/intellij/continuations-library.iml.SAMPLE23
-rw-r--r--src/intellij/continuations-plugin.iml.SAMPLE25
-rw-r--r--src/intellij/scala-lang.ipr.SAMPLE2
-rw-r--r--test/disabled/continuations-neg/infer0.check4
-rw-r--r--test/disabled/continuations-neg/infer0.scala12
-rw-r--r--test/files/continuations-neg/function0.check6
-rw-r--r--test/files/continuations-neg/function0.scala16
-rw-r--r--test/files/continuations-neg/function2.check6
-rw-r--r--test/files/continuations-neg/function2.scala16
-rw-r--r--test/files/continuations-neg/function3.check6
-rw-r--r--test/files/continuations-neg/function3.scala15
-rw-r--r--test/files/continuations-neg/infer2.check4
-rw-r--r--test/files/continuations-neg/infer2.scala19
-rw-r--r--test/files/continuations-neg/lazy.check4
-rw-r--r--test/files/continuations-neg/lazy.scala16
-rw-r--r--test/files/continuations-neg/t1929.check6
-rw-r--r--test/files/continuations-neg/t1929.scala17
-rw-r--r--test/files/continuations-neg/t2285.check6
-rw-r--r--test/files/continuations-neg/t2285.scala11
-rw-r--r--test/files/continuations-neg/t2949.check6
-rw-r--r--test/files/continuations-neg/t2949.scala15
-rw-r--r--test/files/continuations-neg/t3628.check4
-rw-r--r--test/files/continuations-neg/t3628.scala11
-rw-r--r--test/files/continuations-neg/t3718.check4
-rw-r--r--test/files/continuations-neg/t3718.scala3
-rw-r--r--test/files/continuations-neg/t5314-missing-result-type.check4
-rw-r--r--test/files/continuations-neg/t5314-missing-result-type.scala13
-rw-r--r--test/files/continuations-neg/t5314-npe.check4
-rw-r--r--test/files/continuations-neg/t5314-npe.scala3
-rw-r--r--test/files/continuations-neg/t5314-return-reset.check4
-rw-r--r--test/files/continuations-neg/t5314-return-reset.scala21
-rw-r--r--test/files/continuations-neg/t5314-type-error.check6
-rw-r--r--test/files/continuations-neg/t5314-type-error.scala17
-rw-r--r--test/files/continuations-neg/t5445.check4
-rw-r--r--test/files/continuations-neg/t5445.scala5
-rw-r--r--test/files/continuations-neg/trycatch2.check7
-rw-r--r--test/files/continuations-neg/trycatch2.scala33
-rwxr-xr-xtest/files/continuations-run/basics.check2
-rwxr-xr-xtest/files/continuations-run/basics.scala23
-rw-r--r--test/files/continuations-run/function1.check1
-rw-r--r--test/files/continuations-run/function1.scala16
-rw-r--r--test/files/continuations-run/function4.check1
-rw-r--r--test/files/continuations-run/function4.scala15
-rw-r--r--test/files/continuations-run/function5.check1
-rw-r--r--test/files/continuations-run/function5.scala15
-rw-r--r--test/files/continuations-run/function6.check1
-rw-r--r--test/files/continuations-run/function6.scala16
-rw-r--r--test/files/continuations-run/ifelse0.check2
-rw-r--r--test/files/continuations-run/ifelse0.scala18
-rw-r--r--test/files/continuations-run/ifelse1.check4
-rw-r--r--test/files/continuations-run/ifelse1.scala25
-rw-r--r--test/files/continuations-run/ifelse2.check4
-rw-r--r--test/files/continuations-run/ifelse2.scala16
-rw-r--r--test/files/continuations-run/ifelse3.check2
-rw-r--r--test/files/continuations-run/ifelse3.scala21
-rw-r--r--test/files/continuations-run/ifelse4.check4
-rw-r--r--test/files/continuations-run/ifelse4.scala31
-rw-r--r--test/files/continuations-run/implicit-infer-annotations.check5
-rw-r--r--test/files/continuations-run/implicit-infer-annotations.scala59
-rw-r--r--test/files/continuations-run/infer1.scala33
-rw-r--r--test/files/continuations-run/match0.check2
-rw-r--r--test/files/continuations-run/match0.scala18
-rw-r--r--test/files/continuations-run/match1.check2
-rw-r--r--test/files/continuations-run/match1.scala18
-rw-r--r--test/files/continuations-run/match2.check2
-rw-r--r--test/files/continuations-run/match2.scala26
-rw-r--r--test/files/continuations-run/patvirt.check2
-rw-r--r--test/files/continuations-run/patvirt.scala32
-rw-r--r--test/files/continuations-run/shift-pct.check25
-rw-r--r--test/files/continuations-run/shift-pct.scala30
-rw-r--r--test/files/continuations-run/t1807.check1
-rw-r--r--test/files/continuations-run/t1807.scala14
-rw-r--r--test/files/continuations-run/t1808.scala10
-rw-r--r--test/files/continuations-run/t1820.scala14
-rw-r--r--test/files/continuations-run/t1821.check4
-rw-r--r--test/files/continuations-run/t1821.scala20
-rw-r--r--test/files/continuations-run/t2864.check1
-rw-r--r--test/files/continuations-run/t2864.scala30
-rw-r--r--test/files/continuations-run/t2934.check1
-rw-r--r--test/files/continuations-run/t2934.scala10
-rw-r--r--test/files/continuations-run/t3199.check1
-rw-r--r--test/files/continuations-run/t3199.scala20
-rw-r--r--test/files/continuations-run/t3223.check1
-rw-r--r--test/files/continuations-run/t3223.scala19
-rw-r--r--test/files/continuations-run/t3225.check12
-rw-r--r--test/files/continuations-run/t3225.scala56
-rw-r--r--test/files/continuations-run/t3501.check5
-rw-r--r--test/files/continuations-run/t3501.scala15
-rw-r--r--test/files/continuations-run/t5314-2.check5
-rw-r--r--test/files/continuations-run/t5314-2.scala44
-rw-r--r--test/files/continuations-run/t5314-3.check4
-rw-r--r--test/files/continuations-run/t5314-3.scala27
-rw-r--r--test/files/continuations-run/t5314-with-if.check1
-rw-r--r--test/files/continuations-run/t5314-with-if.scala17
-rw-r--r--test/files/continuations-run/t5314.check14
-rw-r--r--test/files/continuations-run/t5314.scala52
-rw-r--r--test/files/continuations-run/t5472.check25
-rw-r--r--test/files/continuations-run/t5472.scala91
-rw-r--r--test/files/continuations-run/t5506.check7
-rw-r--r--test/files/continuations-run/t5506.scala58
-rw-r--r--test/files/continuations-run/t5538.check2
-rw-r--r--test/files/continuations-run/t5538.scala52
-rw-r--r--test/files/continuations-run/trycatch0.check2
-rw-r--r--test/files/continuations-run/trycatch0.scala25
-rw-r--r--test/files/continuations-run/trycatch1.check10
-rw-r--r--test/files/continuations-run/trycatch1.scala48
-rw-r--r--test/files/continuations-run/while0.check1
-rw-r--r--test/files/continuations-run/while0.scala22
-rw-r--r--test/files/continuations-run/while1.check11
-rw-r--r--test/files/continuations-run/while1.scala22
-rw-r--r--test/files/continuations-run/while2.check19
-rw-r--r--test/files/continuations-run/while2.scala23
-rw-r--r--test/files/continuations-run/z1673.scala31
-rw-r--r--test/files/run/t3199b.check (renamed from test/files/continuations-run/t3199b.check)0
-rw-r--r--test/files/run/t3199b.scala (renamed from test/files/continuations-run/t3199b.scala)0
-rw-r--r--test/pending/continuations-pos/t3620.scala73
-rw-r--r--test/pending/continuations-run/example0.scala9
-rw-r--r--test/pending/continuations-run/example1.scala9
-rw-r--r--test/pending/continuations-run/example16.scala9
-rw-r--r--test/pending/continuations-run/example2.scala9
-rw-r--r--test/pending/continuations-run/example3.scala9
-rw-r--r--test/pending/continuations-run/example4.scala9
-rw-r--r--test/pending/continuations-run/example5.scala9
-rw-r--r--test/pending/continuations-run/example6.scala9
-rw-r--r--test/pending/continuations-run/example7.scala9
-rw-r--r--test/pending/continuations-run/example8.scala9
-rw-r--r--test/pending/continuations-run/example9.scala9
-rw-r--r--test/pending/continuations-run/foreach.check4
-rw-r--r--test/pending/continuations-run/foreach.scala33
-rw-r--r--versions.properties8
153 files changed, 57 insertions, 4203 deletions
diff --git a/build-ant-macros.xml b/build-ant-macros.xml
index 735e91ba7b..593f93b784 100644
--- a/build-ant-macros.xml
+++ b/build-ant-macros.xml
@@ -190,10 +190,6 @@
<and>
<available file="tools/zinc"/>
<equals arg1="@{stage}" arg2="quick"/>
- <not>
- <equals arg1="@{project}" arg2="continuations-plugins"/>
- </not>
- <!-- doesn't work in zinc because it requires the quick compiler, which isn't jarred up-->
</and>
<then>
<zinc taskname="Z.@{stage}.@{project}" compilerpathref="@{with}.compiler.path" destdir="${build-@{stage}.dir}/classes/@{destproject}" srcdir="${src.dir}/@{srcdir}" srcpath="@{srcpath}" buildpathref="@{stage}.@{project}.build.path" params="${scalac.args.@{stage}} @{args}" java-excludes="@{java-excludes}"/>
diff --git a/build.xml b/build.xml
index c83ad41f1e..9876c0111e 100755
--- a/build.xml
+++ b/build.xml
@@ -107,6 +107,10 @@ TODO:
<target name="distclean" depends="dist.clean" description="Removes all distributions. Binaries and documentation are untouched."/>
+ <target name="test.continuations.suite">
+ <echo message="DEPRECATED: the continuations have moved to https://github.com/scala/scala-continuations"/>
+ </target>
+
<!-- ===========================================================================
PROPERTIES
============================================================================ -->
@@ -303,6 +307,8 @@ TODO:
<artifact:remoteRepository refid="extra-repo"/>
<dependency groupId="org.scala-lang.modules" artifactId="scala-xml_${scala.binary.version}" version="${scala-xml.version.number}"/>
<dependency groupId="org.scala-lang.modules" artifactId="scala-parser-combinators_${scala.binary.version}" version="${scala-parser-combinators.version.number}"/>
+ <dependency groupId="org.scala-lang.plugins" artifactId="scala-continuations-plugin_${scala.binary.version}" version="${scala-continuations-plugin.version.number}"/>
+ <dependency groupId="org.scala-lang.plugins" artifactId="scala-continuations-library_${scala.binary.version}" version="${scala-continuations-library.version.number}"/>
</artifact:dependencies>
<!-- External modules, excluding the core -->
@@ -320,6 +326,8 @@ TODO:
<propertyForCrossedArtifact name="scala-parser-combinators" jar="org.scala-lang.modules:scala-parser-combinators"/>
<propertyForCrossedArtifact name="scala-xml" jar="org.scala-lang.modules:scala-xml"/>
+ <propertyForCrossedArtifact name="scala-continuations-plugin" jar="org.scala-lang.plugins:scala-continuations-plugin"/>
+ <propertyForCrossedArtifact name="scala-continuations-library" jar="org.scala-lang.plugins:scala-continuations-library"/>
<!-- BND support -->
<typedef resource="aQute/bnd/ant/taskdef.properties" classpathref="extra.tasks.classpath" />
@@ -560,17 +568,19 @@ TODO:
<property name="actors.description" value="Scala Actors Library"/>
- <property name="continuations-plugin.description" value="Scala Delimited Continuations Compiler Plugin"/>
- <property name="continuations-plugin.package" value="plugins." />
- <property name="continuations-plugin.dir" value="plugins/"/>
- <property name="continuations-plugin.name" value="continuations"/>
- <property name="continuations-plugin.targetdir" value="misc/scala-devel/plugins"/>
- <property name="continuations-plugin.srcdir" value="continuations/plugin"/>
+ <property name="swing.description" value="Scala Swing Library"/>
- <property name="continuations-library.description" value="Scala Delimited Continuations Library"/>
- <property name="continuations-library.srcdir" value="continuations/library"/>
+ <property name="continuations-plugin.description" value="Scala Delimited Continuations Compiler Plugin"/>
+ <property name="continuations-plugin.package" value="plugins." />
+ <property name="continuations-plugin.jar" value="${scala-continuations-plugin}"/>
+ <property name="continuations-plugin.src" value="false"/>
+ <property name="continuations-plugin.srcjar" value="${scala-continuations-plugin-sources}"/>
- <property name="swing.description" value="Scala Swing Library"/>
+ <property name="continuations-library.description" value="Scala Delimited Continuations Library"/>
+ <property name="continuations-library.package" value="plugins." />
+ <property name="continuations-library.jar" value="${scala-continuations-library}"/>
+ <property name="continuations-library.src" value="false"/>
+ <property name="continuations-library.srcjar" value="${scala-continuations-library-sources}"/>
<property name="parser-combinators.description" value="Scala Parser Combinators Library"/>
<property name="parser-combinators.package" value="modules."/>
@@ -592,12 +602,12 @@ TODO:
<property name="partest-javaagent.description" value="Scala Compiler Testing Tool (compiler-specific java agent)"/>
<!-- projects without project-specific options: asm, forkjoin, manual, bin, repl -->
- <for list="actors,compiler,interactive,scaladoc,continuations-library,continuations-plugin,library,parser-combinators,partest,partest-extras,partest-javaagent,reflect,scalap,swing,xml" param="project">
+ <for list="actors,compiler,interactive,scaladoc,library,parser-combinators,partest,partest-extras,partest-javaagent,reflect,scalap,swing,xml,continuations-plugin,continuations-library" param="project">
<sequential>
<!-- description is mandatory -->
- <init-project-prop project="@{project}" name="package" default=""/>
- <init-project-prop project="@{project}" name="dir" default=""/>
- <init-project-prop project="@{project}" name="name" default="scala-@{project}"/>
+ <init-project-prop project="@{project}" name="package" default=""/> <!-- used by mvn-package, copy-bundle, make-bundle -->
+ <init-project-prop project="@{project}" name="dir" default=""/> <!-- used by mvn-package -->
+ <init-project-prop project="@{project}" name="name" default="scala-@{project}"/> <!-- used for defaults in this block and by mvn-package, copy-bundle, make-bundle -->
<init-project-prop project="@{project}" name="namesuffix" default=""/>
<init-project-prop project="@{project}" name="version" default="${osgi.version.number}"/>
<init-project-prop project="@{project}" name="targetdir" default="lib"/>
@@ -641,7 +651,7 @@ TODO:
There must be a variable of the shape @{stage}.@{project}.build.path
for all @{stage} in locker, quick, strap
and all @{project} in library, reflect, compiler
- when stage is quick, @{project} also includes: actors, repl, swing, continuations-plugin, continuations-library, scalap
+ when stage is quick, @{project} also includes: actors, repl, swing, scalap
NOTE: interactive, scaladoc, are only used upto quick; they are still packed into the compiler jar
-->
@@ -701,14 +711,6 @@ TODO:
<pathelement location="${build-quick.dir}/classes/swing"/>
</path>
- <path id="quick.continuations-plugin.build.path">
- <!-- plugins are run by locker compiler during quick stage,
- so must compile against the same classes the locker was compiled to
- -->
- <path refid="locker.compiler.build.path"/>
- <pathelement location="${build-quick.dir}/classes/continuations-plugin"/>
- </path>
-
<path id="quick.scalap.build.path">
<path refid="quick.compiler.build.path"/>
<pathelement location="${build-quick.dir}/classes/scalap"/>
@@ -743,7 +745,6 @@ TODO:
<path refid="quick.repl.build.path"/>
<path refid="quick.actors.build.path"/>
<pathelement location="${build-quick.dir}/classes/scalap"/>
- <pathelement location="${build-quick.dir}/classes/continuations-library"/>
<path refid="external-modules-nocore"/>
</path>
@@ -772,7 +773,6 @@ TODO:
<path id="pack.library.files">
<fileset dir="${build-quick.dir}/classes/library"/>
- <fileset dir="${build-quick.dir}/classes/continuations-library"/>
<fileset dir="${forkjoin-classes}"/>
</path>
@@ -797,7 +797,6 @@ TODO:
<path id="pack.swing.files"> <fileset dir="${build-quick.dir}/classes/swing"/> </path>
<path id="pack.reflect.files"> <fileset dir="${build-quick.dir}/classes/reflect"/> </path>
- <path id="pack.continuations-plugin.files"> <fileset dir="${build-quick.dir}/classes/continuations-plugin"/> </path>
<path id="pack.scalap.files"> <fileset dir="${build-quick.dir}/classes/scalap"/>
<fileset file="${src.dir}/scalap/decoder.properties"/> </path>
@@ -829,8 +828,6 @@ TODO:
<path id="docs.scaladoc.build.path"> <path refid="quick.scaladoc.build.path"/> </path>
<path id="docs.interactive.build.path"> <path refid="quick.interactive.build.path"/> </path>
<path id="docs.scalap.build.path"> <path refid="quick.scalap.build.path"/> </path>
- <path id="docs.continuations-plugin.build.path"> <path refid="quick.continuations-plugin.build.path"/> </path>
- <path id="docs.continuations-library.build.path"> <path refid="quick.continuations-plugin.build.path"/> </path>
<path id="docs.actors.build.path"> <path refid="quick.actors.build.path"/> </path>
<path id="docs.swing.build.path"> <path refid="quick.swing.build.path"/> </path>
@@ -1075,34 +1072,8 @@ TODO:
<staged-build with="locker" stage="quick" project="swing"/> </target>
- <target name="quick.plugins" depends="quick.comp">
- <staged-uptodate stage="quick" project="continuations-plugin">
- <check><srcfiles dir="${src.dir}/continuations"/></check>
- <do>
- <stopwatch name="quick.continuations-plugin.timer"/>
- <mkdir dir="${build-quick.dir}/classes/continuations-plugin"/>
- <staged-scalac with="locker" stage="quick" project="continuations-plugin" srcdir="${continuations-plugin.srcdir}"/>
- <copy
- file="${src.dir}/${continuations-plugin.srcdir}/scalac-plugin.xml"
- todir="${build-quick.dir}/classes/continuations-plugin"/>
-
- <!-- not very nice to create jar here but needed to load plugin -->
- <mkdir dir="${build-quick.dir}/${continuations-plugin.targetdir}"/>
- <jar whenmanifestonly="fail" destfile="${build-quick.dir}/${continuations-plugin.targetdir}/continuations.jar" basedir="${build-quick.dir}/classes/continuations-plugin"/>
-
- <!-- might split off library part into its own ant target -->
- <mkdir dir="${build-quick.dir}/classes/continuations-library"/>
- <staged-scalac with="locker" stage="quick" project="continuations-plugin"
- srcdir="continuations/library" destproject="continuations-library"
- args="-Xplugin-require:continuations -P:continuations:enable -Xpluginsdir ${build-quick.dir}/${continuations-plugin.targetdir}"/>
-
- <stopwatch name="quick.continuations-plugin.timer" action="total"/>
- </do>
- </staged-uptodate>
- </target>
-
- <target name="quick.modules" depends="quick.repl, quick.scaladoc, quick.interactive, quick.scalap, quick.swing, quick.plugins"/>
+ <target name="quick.modules" depends="quick.repl, quick.scaladoc, quick.interactive, quick.scalap, quick.swing"/>
<target name="quick.bin" depends="quick.lib, quick.reflect, quick.comp, quick.modules">
<staged-bin stage="quick" classpathref="quick.bin.tool.path"/>
@@ -1115,7 +1086,7 @@ TODO:
<!-- ===========================================================================
PACKED QUICK BUILD (PACK)
============================================================================ -->
- <target name="pack.lib" depends="quick.lib, quick.plugins, forkjoin.done"> <staged-pack project="library"/></target>
+ <target name="pack.lib" depends="quick.lib, forkjoin.done"> <staged-pack project="library"/></target>
<target name="pack.reflect" depends="quick.reflect"> <staged-pack project="reflect"/> </target>
@@ -1154,14 +1125,12 @@ TODO:
<target name="pack.actors" depends="quick.actors"> <staged-pack project="actors"/> </target>
<target name="pack.swing" if="has.java6" depends="quick.swing"> <staged-pack project="swing"/> </target>
- <target name="pack.plugins" depends="quick.plugins"> <staged-pack project="continuations-plugin"/> </target>
-
<target name="pack.scalap" depends="quick.scalap"> <staged-pack project="scalap"/> </target>
<target name="pack.core" depends="pack.reflect, pack.comp, pack.lib"/>
<!-- TODO modularize compiler: pack.scaladoc, pack.interactive, -->
- <target name="pack.modules" depends="pack.actors, pack.swing, pack.plugins, pack.scalap">
+ <target name="pack.modules" depends="pack.actors, pack.swing, pack.scalap">
<copy todir="${build-pack.dir}/lib">
<path refid="external-modules-nocore" />
<mapper type="flatten" />
@@ -1230,7 +1199,6 @@ TODO:
<stopwatch name="osgi.core.timer"/>
<make-bundle project="library">
<fileset dir="${src.dir}/library"/>
- <fileset dir="${src.dir}/continuations/library"/>
</make-bundle>
<make-bundle project="reflect">
@@ -1262,8 +1230,10 @@ TODO:
-->
<include name="${actors.jar}"/>
- <include name="${continuations-plugin.jar}"/>
<include name="${swing.jar}"/>
+
+ <include name="${continuations-plugin.jar}"/>
+ <include name="${continuations-library.jar}"/>
<include name="${parser-combinators.jar}"/>
<include name="${xml.jar}"/>
</srcfiles>
@@ -1290,16 +1260,14 @@ TODO:
<fileset dir="${src.dir}/actors"/>
</make-bundle>
- <make-bundle project="continuations-plugin">
- <fileset dir="${src.dir}/${continuations-plugin.srcdir}"/>
- </make-bundle>
-
<if><isset property="has.java6"/><then>
<make-bundle project="swing">
<fileset dir="${src.dir}/swing"/>
</make-bundle>
</then></if>
+ <make-bundle project="continuations-plugin"/>
+ <make-bundle project="continuations-library"/>
<make-bundle project="parser-combinators"/>
<make-bundle project="xml"/>
@@ -1477,12 +1445,6 @@ TODO:
<testSuite kinds="run jvm"/>
</target>
- <target name="test.continuations.suite" depends="test.suite.init">
- <testSuite kinds="continuations-neg continuations-run"
- scalacOpts="${scalac.args.optimise} -Xpluginsdir ${build-quick.dir}/${continuations-plugin.targetdir} -Xplugin-require:continuations -P:continuations:enable"
- />
- </target>
-
<target name="test.scaladoc" depends="test.suite.init">
<testSuite kinds="run scalacheck" srcdir="scaladoc"/>
</target>
@@ -1493,7 +1455,7 @@ TODO:
<!-- for use in PR validation, where stability is rarely broken, so we're going to use starr for locker,
and skip test.stability (which requires locker == quick) -->
- <target name="test.core" depends="test.osgi, test.sbt, test.bc, test.junit, test.interactive, test.continuations.suite, test.scaladoc, test.suite"/>
+ <target name="test.core" depends="test.osgi, test.sbt, test.bc, test.junit, test.interactive, test.scaladoc, test.suite"/>
<target name="test.done" depends="test.core, test.stability"/>
<!-- ===========================================================================
@@ -1611,18 +1573,6 @@ TODO:
</staged-docs>
</target>
- <target name="docs.continuations-plugin" depends="docs.start" unless="docs.skip">
- <staged-docs project="continuations-plugin">
- <include name="**/*.scala"/>
- </staged-docs>
- </target>
-
- <target name="docs.continuations-library" depends="docs.start" unless="docs.skip">
- <staged-docs project="continuations-library">
- <include name="**/*.scala"/>
- </staged-docs>
- </target>
-
<target name="docs.man" depends="docs.start">
<staged-uptodate stage="docs" project="manual">
<check><srcfiles dir="${src.dir}/manual"/></check>
@@ -1662,7 +1612,7 @@ TODO:
<target name="docs.core" depends="docs.lib, docs.reflect, docs.comp" unless="docs.skip"/>
<!-- TODO modularize compiler: docs.scaladoc, docs.interactive, -->
- <target name="docs.done" depends="docs.core, docs.actors, docs.swing, docs.scalap, docs.continuations-plugin, docs.continuations-library" unless="docs.skip"/>
+ <target name="docs.done" depends="docs.core, docs.actors, docs.swing, docs.scalap" unless="docs.skip"/>
<!-- ===========================================================================
DISTRIBUTION
@@ -1673,7 +1623,6 @@ TODO:
<mkdir dir="${dist.dir}/lib"/>
- <mkdir dir="${dist.dir}/${continuations-plugin.targetdir}"/>
<mkdir dir="${dist.dir}/src"/>
<copy todir="${dist.dir}/lib" overwrite="true">
@@ -1690,9 +1639,10 @@ TODO:
<copy-bundle project="swing"/>
<copy-bundle project="actors"/>
- <copy-bundle project="xml"/>
- <copy-bundle project="parser-combinators"/>
<copy-bundle project="continuations-plugin"/>
+ <copy-bundle project="continuations-library"/>
+ <copy-bundle project="parser-combinators"/>
+ <copy-bundle project="xml"/>
<!-- scalap -->
<copy toDir="${dist.dir}/lib" overwrite="true">
@@ -1733,6 +1683,8 @@ TODO:
<copy toDir="${dist.dir}/doc/api" overwrite="true" flatten="true">
<file file="${scala-xml-javadoc}"/>
<file file="${scala-parser-combinators-javadoc}"/>
+ <file file="${scala-continuations-plugin-javadoc}"/>
+ <file file="${scala-continuations-library-javadoc}"/>
</copy>
</target>
@@ -1848,7 +1800,6 @@ MAIN DISTRIBUTION PACKAGING
<mvn-package project="swing"/>
<mvn-package project="actors"/>
- <mvn-package project="continuations-plugin"/>
<!-- don't bother fitting scalap into the mould: it will move out soon -->
<copy tofile="${maven-base}/scalap/scalap-pom.xml" file="${src.dir}/build/maven/scalap-pom.xml" overwrite="true"/>
diff --git a/dbuild-meta.json b/dbuild-meta.json
index 8d3b65afd0..3021dbe72a 100644
--- a/dbuild-meta.json
+++ b/dbuild-meta.json
@@ -113,18 +113,6 @@
],
"name": "scalap",
"organization": "org.scala-lang"
- },
- {
- "artifacts": [
- {
- "extension": "jar",
- "name": "continuations",
- "organization": "org.scala-lang.plugins"
- }
- ],
- "dependencies": [],
- "name": "continuations",
- "organization": "org.scala-lang.plugins"
}
]
}
diff --git a/src/build/bnd/continuations.bnd b/src/build/bnd/continuations.bnd
deleted file mode 100644
index 748502f653..0000000000
--- a/src/build/bnd/continuations.bnd
+++ /dev/null
@@ -1,5 +0,0 @@
-Bundle-Name: Scala Continuations Plugin
-Bundle-SymbolicName: org.scala-lang.plugins.continuations
-ver: @VERSION@
-Bundle-Version: ${ver}
-Export-Package: *;version=${ver}
diff --git a/src/build/bnd/scala-continuations-library.bnd b/src/build/bnd/scala-continuations-library.bnd
new file mode 100644
index 0000000000..66022d473a
--- /dev/null
+++ b/src/build/bnd/scala-continuations-library.bnd
@@ -0,0 +1,5 @@
+Bundle-Name: Scala Delimited Continuations Library
+Bundle-SymbolicName: org.scala-lang.plugins.continuations-library
+ver: @VERSION@
+Bundle-Version: ${ver}
+Export-Package: *;version=${ver}
diff --git a/src/build/bnd/scala-continuations-plugin.bnd b/src/build/bnd/scala-continuations-plugin.bnd
new file mode 100644
index 0000000000..94bd3ccc8f
--- /dev/null
+++ b/src/build/bnd/scala-continuations-plugin.bnd
@@ -0,0 +1,5 @@
+Bundle-Name: Scala Delimited Continuations Compiler Plugin
+Bundle-SymbolicName: org.scala-lang.plugins.continuations-plugin
+ver: @VERSION@
+Bundle-Version: ${ver}
+Export-Package: *;version=${ver}
diff --git a/src/build/dbuild-meta-json-gen.scala b/src/build/dbuild-meta-json-gen.scala
index ee1976ffa4..1693513203 100644
--- a/src/build/dbuild-meta-json-gen.scala
+++ b/src/build/dbuild-meta-json-gen.scala
@@ -44,9 +44,8 @@ val meta =
Project("scalap", "org.scala-lang",
Seq(ProjectRef("scalap", "org.scala-lang")),
- Seq(ProjectRef("scala-compiler", "org.scala-lang"))),
+ Seq(ProjectRef("scala-compiler", "org.scala-lang")))
- Project("continuations", "org.scala-lang.plugins", Seq(ProjectRef("continuations", "org.scala-lang.plugins")), Seq.empty)
))
println(Utils.writeValue(meta))
diff --git a/src/build/maven/maven-deploy.xml b/src/build/maven/maven-deploy.xml
index 822cc1a25f..5146abd830 100644
--- a/src/build/maven/maven-deploy.xml
+++ b/src/build/maven/maven-deploy.xml
@@ -126,7 +126,6 @@
<deploy-one dir="@{dir}" name="scala-actors" local="@{local}" signed="@{signed}"/>
<deploy-one dir="@{dir}" name="scala-swing" local="@{local}" signed="@{signed}"/>
<deploy-one dir="@{dir}" name="scalap" local="@{local}" signed="@{signed}"/>
- <deploy-one dir="@{dir}plugins/" name="continuations" local="@{local}" signed="@{signed}"/>
</sequential>
</macrodef>
diff --git a/src/build/maven/plugins/continuations-pom.xml b/src/build/maven/plugins/continuations-pom.xml
deleted file mode 100644
index 8dc79c8664..0000000000
--- a/src/build/maven/plugins/continuations-pom.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.scala-lang.plugins</groupId>
- <artifactId>continuations</artifactId>
- <packaging>jar</packaging>
- <version>@VERSION@</version>
- <name>Scala Continuations Plugin</name>
- <description>Delimited continuations compilation for Scala</description>
- <url>http://www.scala-lang.org/</url>
- <inceptionYear>2010</inceptionYear>
- <organization>
- <name>LAMP/EPFL</name>
- <url>http://lamp.epfl.ch/</url>
- </organization>
- <licenses>
- <license>
- <name>BSD 3-Clause</name>
- <url>http://www.scala-lang.org/license.html</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <scm>
- <connection>scm:git:git://github.com/scala/scala.git</connection>
- <url>https://github.com/scala/scala.git</url>
- </scm>
- <issueManagement>
- <system>JIRA</system>
- <url>https://issues.scala-lang.org/</url>
- </issueManagement>
- <dependencies>
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-compiler</artifactId>
- <version>@VERSION@</version>
- </dependency>
- </dependencies>
- <distributionManagement>
- <repository>
- <id>scala-tools.org</id>
- <url>@RELEASE_REPOSITORY@</url>
- </repository>
- <snapshotRepository>
- <id>scala-tools.org</id>
- <url>@SNAPSHOT_REPOSITORY@</url>
- <uniqueVersion>false</uniqueVersion>
- </snapshotRepository>
- </distributionManagement>
- <developers>
- <developer>
- <id>lamp</id>
- <name>EPFL LAMP</name>
- </developer>
- <developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
- </developer>
- </developers>
-</project>
diff --git a/src/continuations/library/scala/util/continuations/ControlContext.scala b/src/continuations/library/scala/util/continuations/ControlContext.scala
deleted file mode 100644
index c196809da9..0000000000
--- a/src/continuations/library/scala/util/continuations/ControlContext.scala
+++ /dev/null
@@ -1,249 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2010-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util.continuations
-
-import scala.annotation.{ Annotation, StaticAnnotation, TypeConstraint }
-
-/** This annotation is used to mark a parameter as part of a continuation
- * context.
- *
- * The type `A @cpsParam[B,C]` is desugared to `ControlContext[A,B,C]` at compile
- * time.
- *
- * @tparam B The type of computation state after computation has executed, and
- * before control is returned to the shift.
- * @tparam C The eventual return type of this delimited compuation.
- * @see scala.util.continuations.ControlContext
- */
-class cpsParam[-B,+C] extends StaticAnnotation with TypeConstraint
-
-private class cpsSym[B] extends Annotation // implementation detail
-
-private class cpsSynth extends Annotation // implementation detail
-
-private class cpsPlus extends StaticAnnotation with TypeConstraint // implementation detail
-private class cpsMinus extends Annotation // implementation detail
-
-
-/**
- * This class represent a portion of computation that has a 'hole' in it. The
- * class has the ability to compute state up until a certain point where the
- * state has the `A` type. If this context is given a function of type
- * `A => B` to move the state to the `B` type, then the entire computation can
- * be completed resulting in a value of type `C`.
- *
- * An Example: {{{
- * val cc = new ControlContext[String, String, String](
- * fun = { (f: String=>String, err: Exception => String) =>
- * val updatedState =
- * try f("State")
- * catch {
- * case e: Exception => err(e)
- * }
- * updatedState + "-Complete!"
- * },
- * x = null.asIntanceOf[String]
- * }
- * cc.foreach(_ + "-Continued") // Results in "State-Continued-Complete!"
- * }}}
- *
- * This class is used to transform calls to `shift` in the `continuations`
- * package. Direct use and instantiation is possible, but usually reserved
- * for advanced cases.
- *
- *
- * A context may either be ''trivial'' or ''non-trivial''. A ''trivial''
- * context '''just''' has a state of type `A`. When completing the computation,
- * it's only necessary to use the function of type `A => B` directly against
- * the trivial value. A ''non-trivial'' value stores a computation '''around'''
- * the state transformation of type `A => B` and cannot be short-circuited.
- *
- * @param fun The captured computation so far. The type
- * `(A => B, Exception => B) => C` is a function where:
- * - The first parameter `A=>B` represents the computation defined against
- * the current state held in the ControlContext.
- * - The second parameter `Exception => B` represents a computation to
- * perform if an exception is thrown from the first parameter's computation.
- * - The return value is the result of the entire computation contained in this
- * `ControlContext`.
- * @param x The current state stored in this context. Allowed to be null if
- * the context is non-trivial.
- * @tparam A The type of the state currently held in the context.
- * @tparam B The type of the transformed state needed to complete this computation.
- * @tparam C The return type of the entire computation stored in this context.
- * @note `fun` and `x` are allowed to be `null`.
- * @see scala.util.continutations.shiftR
- */
-final class ControlContext[+A,-B,+C](val fun: (A => B, Exception => B) => C, val x: A) extends Serializable {
-
- /*
- final def map[A1](f: A => A1): ControlContext[A1,B,C] = {
- new ControlContext((k:(A1 => B)) => fun((x:A) => k(f(x))), null.asInstanceOf[A1])
- }
-
- final def flatMap[A1,B1<:B](f: (A => ControlContext[A1,B1,B])): ControlContext[A1,B1,C] = {
- new ControlContext((k:(A1 => B1)) => fun((x:A) => f(x).fun(k)))
- }
- */
-
- /**
- * Modifies the currently captured state in this `ControlContext`.
- * @tparam A1 The new type of state in this context.
- * @param f A transformation function on the current state of the `ControlContext`.
- * @return The new `ControlContext`.
- */
- @noinline final def map[A1](f: A => A1): ControlContext[A1,B,C] = {
- if (fun eq null)
- try {
- new ControlContext[A1,B,C](null, f(x)) // TODO: only alloc if f(x) != x
- } catch {
- case ex: Exception =>
- new ControlContext((k: A1 => B, thr: Exception => B) => thr(ex).asInstanceOf[C], null.asInstanceOf[A1])
- }
- else
- new ControlContext({ (k: A1 => B, thr: Exception => B) =>
- fun( { (x:A) =>
- var done = false
- try {
- val res = f(x)
- done = true
- k(res)
- } catch {
- case ex: Exception if !done =>
- thr(ex)
- }
- }, thr)
- }, null.asInstanceOf[A1])
- }
-
-
- // it would be nice if @inline would turn the trivial path into a tail call.
- // unfortunately it doesn't, so we do it ourselves in SelectiveCPSTransform
-
- /**
- * Maps and flattens this `ControlContext` with another `ControlContext` generated from the current state.
- * @note The resulting comuptation is still the type `C`.
- * @tparam A1 The new type of the contained state.
- * @tparam B1 The new type of the state after the stored continuation has executed.
- * @tparam C1 The result type of the nested `ControlContext`. Because the nested `ControlContext` is executed within
- * the outer `ControlContext`, this type must `>: B` so that the resulting nested computation can be fed through
- * the current continuation.
- * @param f A transformation function from the current state to a nested `ControlContext`.
- * @return The transformed `ControlContext`.
- */
- @noinline final def flatMap[A1,B1,C1<:B](f: (A => ControlContext[A1,B1,C1])): ControlContext[A1,B1,C] = {
- if (fun eq null)
- try {
- f(x).asInstanceOf[ControlContext[A1,B1,C]]
- } catch {
- case ex: Exception =>
- new ControlContext((k: A1 => B1, thr: Exception => B1) => thr(ex).asInstanceOf[C], null.asInstanceOf[A1])
- }
- else
- new ControlContext({ (k: A1 => B1, thr: Exception => B1) =>
- fun( { (x:A) =>
- var done = false
- try {
- val ctxR = f(x)
- done = true
- val res: C1 = ctxR.foreachFull(k, thr) // => B1
- res
- } catch {
- case ex: Exception if !done =>
- thr(ex).asInstanceOf[B] // => B NOTE: in general this is unsafe!
- } // However, the plugin will not generate offending code
- }, thr.asInstanceOf[Exception=>B]) // => B
- }, null.asInstanceOf[A1])
- }
-
- /**
- * Runs the computation against the state stored in this `ControlContext`.
- * @param f the computation that modifies the current state of the context.
- * @note This method could throw exceptions from the computations.
- */
- final def foreach(f: A => B) = foreachFull(f, throw _)
-
- def foreachFull(f: A => B, g: Exception => B): C = {
- if (fun eq null)
- f(x).asInstanceOf[C]
- else
- fun(f, g)
- }
-
- /** @return true if this context only stores a state value and not any deferred computation. */
- final def isTrivial = fun eq null
- /** @return The current state value. */
- final def getTrivialValue = x.asInstanceOf[A]
-
- // need filter or other functions?
-
- final def flatMapCatch[A1>:A,B1<:B,C1>:C<:B1](pf: PartialFunction[Exception, ControlContext[A1,B1,C1]]): ControlContext[A1,B1,C1] = { // called by codegen from SelectiveCPSTransform
- if (fun eq null)
- this
- else {
- val fun1 = (ret1: A1 => B1, thr1: Exception => B1) => {
- val thr: Exception => B1 = { t: Exception =>
- var captureExceptions = true
- try {
- if (pf.isDefinedAt(t)) {
- val cc1 = pf(t)
- captureExceptions = false
- cc1.foreachFull(ret1, thr1) // Throw => B
- } else {
- captureExceptions = false
- thr1(t) // Throw => B1
- }
- } catch {
- case t1: Exception if captureExceptions => thr1(t1) // => E2
- }
- }
- fun(ret1, thr)// fun(ret1, thr) // => B
- }
- new ControlContext(fun1, null.asInstanceOf[A1])
- }
- }
-
- final def mapFinally(f: () => Unit): ControlContext[A,B,C] = { // called in code generated by SelectiveCPSTransform
- if (fun eq null) {
- try {
- f()
- this
- } catch {
- case ex: Exception =>
- new ControlContext((k: A => B, thr: Exception => B) => thr(ex).asInstanceOf[C], null.asInstanceOf[A])
- }
- } else {
- val fun1 = (ret1: A => B, thr1: Exception => B) => {
- val ret: A => B = { x: A =>
- var captureExceptions = true
- try {
- f()
- captureExceptions = false
- ret1(x)
- } catch {
- case t1: Exception if captureExceptions => thr1(t1)
- }
- }
- val thr: Exception => B = { t: Exception =>
- var captureExceptions = true
- try {
- f()
- captureExceptions = false
- thr1(t)
- } catch {
- case t1: Exception if captureExceptions => thr1(t1)
- }
- }
- fun(ret, thr1)
- }
- new ControlContext(fun1, null.asInstanceOf[A])
- }
- }
-
-}
diff --git a/src/continuations/library/scala/util/continuations/package.scala b/src/continuations/library/scala/util/continuations/package.scala
deleted file mode 100644
index 573fae85e7..0000000000
--- a/src/continuations/library/scala/util/continuations/package.scala
+++ /dev/null
@@ -1,187 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2010-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util
-
-/* TODO: better documentation of return-type modification.
- * (Especially what means "Illegal answer type modification: ... andThen ...")
- */
-
-/**
- * Delimited continuations are a feature for modifying the usual control flow
- * of a program. To use continuations, provide the option `-P:continuations:enable`
- * to the Scala compiler or REPL to activate the compiler plugin.
- *
- * Below is an example of using continuations to suspend execution while awaiting
- * user input. Similar facilities are used in so-called continuation-based web frameworks.
- *
- * {{{
- * def go =
- * reset {
- * println("Welcome!")
- * val first = ask("Please give me a number")
- * val second = ask("Please enter another number")
- * printf("The sum of your numbers is: %d\n", first + second)
- * }
- * }}}
- *
- * The `reset` is provided by this package and delimits the extent of the
- * transformation. The `ask` is a function that will be defined below. Its
- * effect is to issue a prompt and then suspend execution awaiting user input.
- * Once the user provides an input value, execution of the suspended block
- * resumes.
- *
- * {{{
- * val sessions = new HashMap[UUID, Int=>Unit]
- * def ask(prompt: String): Int @cps[Unit] =
- * shift {
- * k: (Int => Unit) => {
- * val id = uuidGen
- * printf("%s\nrespond with: submit(0x%x, ...)\n", prompt, id)
- * sessions += id -> k
- * }
- * }
- * }}}
- *
- * The type of `ask` includes a `@cps` annotation which drives the transformation.
- * The type signature `Int @cps[Unit]` means that `ask` should be used in a
- * context requiring an `Int`, but actually it will suspend and return `Unit`.
- *
- * The computation leading up to the first `ask` is executed normally. The
- * remainder of the reset block is wrapped into a closure that is passed as
- * the parameter `k` to the `shift` function, which can then decide whether
- * and how to execute the continuation. In this example, the continuation is
- * stored in a sessions map for later execution. This continuation includes a
- * second call to `ask`, which is treated likewise once the execution resumes.
- *
- * <h2>CPS Annotation</h2>
- *
- * The aforementioned `@cps[A]` annotation is an alias for the more general
- * `@cpsParam[B,C]` where `B=C`. The type `A @cpsParam[B,C]` describes a term
- * which yields a value of type `A` within an evaluation context producing a
- * value of type `B`. After the CPS transformation, this return type is
- * modified to `C`.
- *
- * The `@cpsParam` annotations are introduced by `shift` blocks, and propagate
- * via the return types to the dynamically enclosing context. The propagation
- * stops upon reaching a `reset` block.
- */
-
-package object continuations {
-
- /** An annotation that denotes a type is part of a continuation context.
- * `@cps[A]` is shorthand for `cpsParam[A,A]`.
- * @tparam A The return type of the continuation context.
- */
- type cps[A] = cpsParam[A,A]
-
- /** An annotation that denotes a type is part of a side effecting continuation context.
- * `@suspendable` is shorthand notation for `@cpsParam[Unit,Unit]` or `@cps[Unit]`.
- */
- type suspendable = cps[Unit]
-
- /**
- * The `shift` function captures the remaining computation in a `reset` block
- * and passes it to a closure provided by the user.
- *
- * For example:
- * {{{
- * reset {
- * shift { (k: Int => Int) => k(5) } + 1
- * }
- * }}}
- *
- * In this example, `shift` is used in the expression `shift ... + 1`.
- * The compiler will alter this expression so that the call
- * to `shift` becomes a parameter to a function, creating something like:
- * {{{
- * { (k: Int => Int) => k(5) } apply { _ + 1 }
- * }}}
- * The result of this expression is 6.
- *
- * There can be more than one `shift` call in a `reset` block. Each call
- * to `shift` can alter the return type of expression within the reset block,
- * but will not change the return type of the entire `reset { block }`
- * expression.
- *
- * @param fun A function where
- * - The parameter is the remainder of computation within the current
- * `reset` block. This is passed as a function `A => B`.
- * - The return is the return value of the `ControlContext` which is
- * generated from this inversion.
- * @note Must be invoked in the context of a call to `reset` This context
- * may not be far up the stack, but a call to reset is needed to
- * eventually remove the `@cps` annotations from types.
- */
- def shift[A,B,C](fun: (A => B) => C): A @cpsParam[B,C] = {
- throw new NoSuchMethodException("this code has to be compiled with the Scala continuations plugin enabled")
- }
- /** Creates a context for continuations captured within the argument closure
- * of this `reset` call and returns the result of the entire transformed
- * computation. Within an expression of the form `reset { block }`,
- * the closure expression (`block`) will be modified such that at each
- * call to `shift` the remainder of the expression is transformed into a
- * function to be passed into the shift.
- * @return The result of a block of code that uses `shift` to capture continuations.
- */
- def reset[A,C](ctx: =>(A @cpsParam[A,C])): C = {
- val ctxR = reify[A,A,C](ctx)
- if (ctxR.isTrivial)
- ctxR.getTrivialValue.asInstanceOf[C]
- else
- ctxR.foreach((x:A) => x)
- }
-
- def reset0[A](ctx: =>(A @cpsParam[A,A])): A = reset(ctx)
-
- def run[A](ctx: =>(Any @cpsParam[Unit,A])): A = {
- val ctxR = reify[Any,Unit,A](ctx)
- if (ctxR.isTrivial)
- ctxR.getTrivialValue.asInstanceOf[A]
- else
- ctxR.foreach((x:Any) => ())
- }
-
-
- // methods below are primarily implementation details and are not
- // needed frequently in client code
-
- def shiftUnit0[A,B](x: A): A @cpsParam[B,B] = {
- shiftUnit[A,B,B](x)
- }
-
- def shiftUnit[A,B,C>:B](x: A): A @cpsParam[B,C] = {
- throw new NoSuchMethodException("this code has to be compiled with the Scala continuations plugin enabled")
- }
-
- /** This method converts from the sugared `A @cpsParam[B,C]` type to the desugared
- * `ControlContext[A,B,C]` type. The underlying data is not changed.
- */
- def reify[A,B,C](ctx: =>(A @cpsParam[B,C])): ControlContext[A,B,C] = {
- throw new NoSuchMethodException("this code has to be compiled with the Scala continuations plugin enabled")
- }
-
- def shiftUnitR[A,B](x: A): ControlContext[A,B,B] = { // called in code generated by SelectiveCPSTransform
- new ControlContext[A, B, B](null, x)
- }
-
- /**
- * Captures a computation into a `ControlContext`.
- * @param fun The function which accepts the inverted computation and returns
- * a final result.
- * @see shift
- */
- def shiftR[A,B,C](fun: (A => B) => C): ControlContext[A,B,C] = { // called in code generated by SelectiveCPSTransform
- new ControlContext((f:A=>B,g:Exception=>B) => fun(f), null.asInstanceOf[A])
- }
-
- def reifyR[A,B,C](ctx: => ControlContext[A,B,C]): ControlContext[A,B,C] = { // called in code generated by SelectiveCPSTransform
- ctx
- }
-
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala
deleted file mode 100644
index 3963447de3..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala
+++ /dev/null
@@ -1,520 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc.{ Global, Mode }
-import scala.tools.nsc.MissingRequirementError
-
-abstract class CPSAnnotationChecker extends CPSUtils {
- val global: Global
- import global._
- import analyzer.{AnalyzerPlugin, Typer}
- import definitions._
-
- //override val verbose = true
- @inline override final def vprintln(x: =>Any): Unit = if (verbose) println(x)
-
- /**
- * Checks whether @cps annotations conform
- */
- object checker extends AnnotationChecker {
- private[CPSAnnotationChecker] def addPlusMarker(tp: Type) = tp withAnnotation newPlusMarker()
- private[CPSAnnotationChecker] def addMinusMarker(tp: Type) = tp withAnnotation newMinusMarker()
-
- private[CPSAnnotationChecker] def cleanPlus(tp: Type) =
- removeAttribs(tp, MarkerCPSAdaptPlus, MarkerCPSTypes)
- private[CPSAnnotationChecker] def cleanPlusWith(tp: Type)(newAnnots: AnnotationInfo*) =
- cleanPlus(tp) withAnnotations newAnnots.toList
-
- /** Check annotations to decide whether tpe1 <:< tpe2 */
- def annotationsConform(tpe1: Type, tpe2: Type): Boolean = {
- if (!cpsEnabled) return true
-
- vprintln("check annotations: " + tpe1 + " <:< " + tpe2)
-
- // Nothing is least element, but Any is not the greatest
- if (tpe1.typeSymbol eq NothingClass)
- return true
-
- val annots1 = cpsParamAnnotation(tpe1)
- val annots2 = cpsParamAnnotation(tpe2)
-
- // @plus and @minus should only occur at the left, and never together
- // TODO: insert check
-
- // @minus @cps is the same as no annotations
- if (hasMinusMarker(tpe1))
- return annots2.isEmpty
-
- // to handle answer type modification, we must make @plus <:< @cps
- if (hasPlusMarker(tpe1) && annots1.isEmpty)
- return true
-
- // @plus @cps will fall through and compare the @cps type args
- // @cps parameters must match exactly
- if ((annots1 corresponds annots2)(_.atp <:< _.atp))
- return true
-
- // Need to handle uninstantiated type vars specially:
-
- // g map (x => x) with expected type List[Int] @cps
- // results in comparison ?That <:< List[Int] @cps
-
- // Instantiating ?That to an annotated type would fail during
- // transformation.
-
- // Instead we force-compare tpe1 <:< tpe2.withoutAnnotations
- // to trigger instantiation of the TypeVar to the base type
-
- // This is a bit unorthodox (we're only supposed to look at
- // annotations here) but seems to work.
-
- if (!annots2.isEmpty && !tpe1.isGround)
- return tpe1 <:< tpe2.withoutAnnotations
-
- false
- }
-
- /** Refine the computed least upper bound of a list of types.
- * All this should do is add annotations. */
- override def annotationsLub(tpe: Type, ts: List[Type]): Type = {
- if (!cpsEnabled) return tpe
-
- val annots1 = cpsParamAnnotation(tpe)
- val annots2 = ts flatMap cpsParamAnnotation
-
- if (annots2.nonEmpty) {
- val cpsLub = newMarker(global.lub(annots1:::annots2 map (_.atp)))
- val tpe1 = if (annots1.nonEmpty) removeAttribs(tpe, MarkerCPSTypes) else tpe
- tpe1.withAnnotation(cpsLub)
- }
- else tpe
- }
-
- /** Refine the bounds on type parameters to the given type arguments. */
- override def adaptBoundsToAnnotations(bounds: List[TypeBounds], tparams: List[Symbol], targs: List[Type]): List[TypeBounds] = {
- if (!cpsEnabled) return bounds
-
- val anyAtCPS = newCpsParamsMarker(NothingTpe, AnyTpe)
- if (isFunctionType(tparams.head.owner.tpe_*) || isPartialFunctionType(tparams.head.owner.tpe_*)) {
- vprintln("function bound: " + tparams.head.owner.tpe + "/"+bounds+"/"+targs)
- if (hasCpsParamTypes(targs.last))
- bounds.reverse match {
- case res::b if !hasCpsParamTypes(res.hi) =>
- (TypeBounds(res.lo, res.hi.withAnnotation(anyAtCPS))::b).reverse
- case _ => bounds
- }
- else
- bounds
- }
- else if (tparams.head.owner == ByNameParamClass) {
- vprintln("byname bound: " + tparams.head.owner.tpe + "/"+bounds+"/"+targs)
- val TypeBounds(lo, hi) = bounds.head
- if (hasCpsParamTypes(targs.head) && !hasCpsParamTypes(hi))
- TypeBounds(lo, hi withAnnotation anyAtCPS) :: Nil
- else bounds
- } else
- bounds
- }
- }
-
- object plugin extends AnalyzerPlugin {
-
- import checker._
-
- override def canAdaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Boolean = {
- if (!cpsEnabled) return false
- vprintln("can adapt annotations? " + tree + " / " + tree.tpe + " / " + mode + " / " + pt)
-
- val annots1 = cpsParamAnnotation(tree.tpe)
- val annots2 = cpsParamAnnotation(pt)
-
- if (mode.inPatternMode) {
- //println("can adapt pattern annotations? " + tree + " / " + tree.tpe + " / " + Integer.toHexString(mode) + " / " + pt)
- if (!annots1.isEmpty) {
- return true
- }
- }
-
-/*
- // not precise enough -- still relying on addAnnotations to remove things from ValDef symbols
- if (mode.inAllModes(TYPEmode | BYVALmode)) {
- if (!annots1.isEmpty) {
- return true
- }
- }
-*/
-
-/*
- this interferes with overloading resolution
- if (mode.inByValMode && tree.tpe <:< pt) {
- vprintln("already compatible, can't adapt further")
- return false
- }
-*/
- if (mode.inExprMode) {
- if ((annots1 corresponds annots2)(_.atp <:< _.atp)) {
- vprintln("already same, can't adapt further")
- false
- } else if (annots1.isEmpty && !annots2.isEmpty && !mode.inByValMode) {
- //println("can adapt annotations? " + tree + " / " + tree.tpe + " / " + Integer.toHexString(mode) + " / " + pt)
- if (!hasPlusMarker(tree.tpe)) {
- // val base = tree.tpe <:< removeAllCPSAnnotations(pt)
- // val known = global.analyzer.isFullyDefined(pt)
- // println(same + "/" + base + "/" + known)
- //val same = annots2 forall { case AnnotationInfo(atp: TypeRef, _, _) => atp.typeArgs(0) =:= atp.typeArgs(1) }
- // TBD: use same or not?
- //if (same) {
- vprintln("yes we can!! (unit)")
- true
- //}
- } else false
- } else if (!hasPlusMarker(tree.tpe) && annots1.isEmpty && !annots2.isEmpty && typer.context.inReturnExpr) {
- vprintln("checking enclosing method's result type without annotations")
- tree.tpe <:< pt.withoutAnnotations
- } else if (!hasMinusMarker(tree.tpe) && !annots1.isEmpty && mode.inByValMode) {
- val optCpsTypes: Option[(Type, Type)] = cpsParamTypes(tree.tpe)
- val optExpectedCpsTypes: Option[(Type, Type)] = cpsParamTypes(pt)
- if (optCpsTypes.isEmpty || optExpectedCpsTypes.isEmpty) {
- vprintln("yes we can!! (byval)")
- true
- } else { // check cps param types
- val cpsTpes = optCpsTypes.get
- val cpsPts = optExpectedCpsTypes.get
- // class cpsParam[-B,+C], therefore:
- cpsPts._1 <:< cpsTpes._1 && cpsTpes._2 <:< cpsPts._2
- }
- } else false
- } else false
- }
-
- override def adaptAnnotations(tree: Tree, typer: Typer, mode: Mode, pt: Type): Tree = {
- if (!cpsEnabled) return tree
-
- vprintln("adapt annotations " + tree + " / " + tree.tpe + " / " + mode + " / " + pt)
-
- val annotsTree = cpsParamAnnotation(tree.tpe)
- val annotsExpected = cpsParamAnnotation(pt)
- def isMissingExpectedAnnots = annotsTree.isEmpty && annotsExpected.nonEmpty
-
- // not sure I rephrased this comment correctly:
- // replacing `mode.inPatternMode` in the condition below by `mode.inPatternMode || mode.inAllModes(TYPEmode | BYVALmode)`
- // doesn't work correctly -- still relying on addAnnotations to remove things from ValDef symbols
- if (mode.inPatternMode && annotsTree.nonEmpty) tree modifyType removeAllCPSAnnotations
- else if (mode.typingExprNotValue && !hasPlusMarker(tree.tpe) && isMissingExpectedAnnots) { // shiftUnit
- // add a marker annotation that will make tree.tpe behave as pt, subtyping wise
- // tree will look like having any possible annotation
- //println("adapt annotations " + tree + " / " + tree.tpe + " / " + Integer.toHexString(mode) + " / " + pt)
-
- // CAVEAT:
- // for monomorphic answer types we want to have @plus @cps (for better checking)
- // for answer type modification we want to have only @plus (because actual answer type may differ from pt)
-
- val res = tree modifyType (_ withAnnotations newPlusMarker() :: annotsExpected) // needed for #1807
- vprintln("adapted annotations (not by val) of " + tree + " to " + res.tpe)
- res
- } else if (mode.typingExprByValue && !hasMinusMarker(tree.tpe) && annotsTree.nonEmpty) { // dropping annotation
- // add a marker annotation that will make tree.tpe behave as pt, subtyping wise
- // tree will look like having no annotation
- val res = tree modifyType addMinusMarker
- vprintln("adapted annotations (by val) of " + tree + " to " + res.tpe)
- res
- } else if (typer.context.inReturnExpr && !hasPlusMarker(tree.tpe) && isMissingExpectedAnnots) {
- // add a marker annotation that will make tree.tpe behave as pt, subtyping wise
- // tree will look like having any possible annotation
-
- // note 1: we are only adding a plus marker if the method's result type is a cps type
- // (annotsExpected.nonEmpty == cpsParamAnnotation(pt).nonEmpty)
- // note 2: we are not adding the expected cps annotations, since they will be added
- // by adaptTypeOfReturn (see below).
- val res = tree modifyType (_ withAnnotation newPlusMarker())
- vprintln("adapted annotations (return) of " + tree + " to " + res.tpe)
- res
- } else tree
- }
-
- /** Returns an adapted type for a return expression if the method's result type (pt) is a CPS type.
- * Otherwise, it returns the `default` type (`typedReturn` passes `NothingTpe`).
- *
- * A return expression in a method that has a CPS result type is an error unless the return
- * is in tail position. Therefore, we are making sure that only the types of return expressions
- * are adapted which will either be removed, or lead to an error.
- */
- override def pluginsTypedReturn(default: Type, typer: Typer, tree: Return, pt: Type): Type = {
- val expr = tree.expr
- // only adapt if method's result type (pt) is cps type
- val annots = cpsParamAnnotation(pt)
- if (annots.nonEmpty) {
- // return type of `expr` without plus marker, but only if it doesn't have other cps annots
- if (hasPlusMarker(expr.tpe) && !hasCpsParamTypes(expr.tpe))
- expr.setType(removeAttribs(expr.tpe, MarkerCPSAdaptPlus))
- expr.tpe
- } else default
- }
-
- def updateAttributesFromChildren(tpe: Type, childAnnots: List[AnnotationInfo], byName: List[Tree]): Type = {
- tpe match {
- // Would need to push annots into each alternative of overloaded type
- // But we can't, since alternatives aren't types but symbols, which we
- // can't change (we'd be affecting symbols globally)
- /*
- case OverloadedType(pre, alts) =>
- OverloadedType(pre, alts.map((sym: Symbol) => updateAttributes(pre.memberType(sym), annots)))
- */
- case OverloadedType(pre, alts) => tpe //reconstruct correct annotations later
- case MethodType(params, restpe) => tpe
- case PolyType(params, restpe) => tpe
- case _ =>
- assert(childAnnots forall (_ matches MarkerCPSTypes), childAnnots)
- /*
- [] + [] = []
- plus + [] = plus
- cps + [] = cps
- plus cps + [] = plus cps
- minus cps + [] = minus cps
- synth cps + [] = synth cps // <- synth on left - does it happen?
-
- [] + cps = cps
- plus + cps = synth cps
- cps + cps = cps! <- lin
- plus cps + cps = synth cps! <- unify
- minus cps + cps = minus cps! <- lin
- synth cps + cps = synth cps! <- unify
- */
-
- val plus = hasPlusMarker(tpe) || (
- hasCpsParamTypes(tpe)
- && byName.nonEmpty
- && (byName forall (t => hasPlusMarker(t.tpe)))
- )
-
- // move @plus annotations outward from by-name children
- if (childAnnots.isEmpty) return {
- if (plus) { // @plus or @plus @cps
- byName foreach (_ modifyType cleanPlus)
- addPlusMarker(tpe)
- }
- else tpe
- }
-
- val annots1 = cpsParamAnnotation(tpe)
-
- if (annots1.isEmpty) { // nothing or @plus
- cleanPlusWith(tpe)(newSynthMarker(), linearize(childAnnots))
- }
- else {
- val annot1 = single(annots1)
- if (plus) { // @plus @cps
- val annot2 = linearize(childAnnots)
-
- if (annot2.atp <:< annot1.atp) {
- try cleanPlusWith(tpe)(newSynthMarker(), annot2)
- finally byName foreach (_ modifyType cleanPlus)
- }
- else throw new TypeError(annot2 + " is not a subtype of " + annot1)
- }
- else if (hasSynthMarker(tpe)) { // @synth @cps
- val annot2 = linearize(childAnnots)
- if (annot2.atp <:< annot1.atp)
- cleanPlusWith(tpe)(annot2)
- else
- throw new TypeError(annot2 + " is not a subtype of " + annot1)
- }
- else // @cps
- cleanPlusWith(tpe)(linearize(childAnnots:::annots1))
- }
- }
- }
-
- def transArgList(fun: Tree, args: List[Tree]): List[List[Tree]] = {
- val formals = fun.tpe.paramTypes
- val overshoot = args.length - formals.length
-
- for ((a,tp) <- args.zip(formals ::: List.fill(overshoot)(NoType))) yield {
- tp match {
- case TypeRef(_, ByNameParamClass, List(elemtp)) =>
- Nil // TODO: check conformance??
- case _ =>
- List(a)
- }
- }
- }
-
-
- def transStms(stms: List[Tree]): List[Tree] = stms match {
- case ValDef(mods, name, tpt, rhs)::xs =>
- rhs::transStms(xs)
- case Assign(lhs, rhs)::xs =>
- rhs::transStms(xs)
- case x::xs =>
- x::transStms(xs)
- case Nil =>
- Nil
- }
-
- def single(xs: List[AnnotationInfo]) = xs match {
- case List(x) => x
- case _ =>
- global.globalError("not a single cps annotation: " + xs)
- xs(0)
- }
-
- def emptyOrSingleList(xs: List[AnnotationInfo]) = if (xs.isEmpty) Nil else List(single(xs))
-
- def transChildrenInOrder(tree: Tree, tpe: Type, childTrees: List[Tree], byName: List[Tree]) = {
- def inspect(t: Tree): List[AnnotationInfo] = {
- if (t.tpe eq null) Nil else {
- val extra: List[AnnotationInfo] = t.tpe match {
- case _: MethodType | _: PolyType | _: OverloadedType =>
- // method types, poly types and overloaded types do not obtain cps annotions by propagation
- // need to reconstruct transitively from their children.
- t match {
- case Select(qual, name) => inspect(qual)
- case Apply(fun, args) => (fun::(transArgList(fun,args).flatten)) flatMap inspect
- case TypeApply(fun, args) => (fun::(transArgList(fun,args).flatten)) flatMap inspect
- case _ => Nil
- }
- case _ => Nil
- }
-
- val types = cpsParamAnnotation(t.tpe)
- // TODO: check that it has been adapted and if so correctly
- extra ++ emptyOrSingleList(types)
- }
- }
- val children = childTrees flatMap inspect
-
- val newtpe = updateAttributesFromChildren(tpe, children, byName)
-
- if (!newtpe.annotations.isEmpty)
- vprintln("[checker] inferred " + tree + " / " + tpe + " ===> "+ newtpe)
-
- newtpe
- }
-
- /** Modify the type that has thus far been inferred
- * for a tree. All this should do is add annotations. */
-
- override def pluginsTyped(tpe: Type, typer: Typer, tree: Tree, mode: Mode, pt: Type): Type = {
- if (!cpsEnabled) {
- val report = try hasCpsParamTypes(tpe) catch { case _: MissingRequirementError => false }
- if (report)
- global.reporter.error(tree.pos, "this code must be compiled with the Scala continuations plugin enabled")
-
- return tpe
- }
-
-// if (tree.tpe.hasAnnotation(MarkerCPSAdaptPlus))
-// println("addAnnotation " + tree + "/" + tpe)
-
- tree match {
-
- case Apply(fun @ Select(qual, name), args) if fun.isTyped =>
-
- // HACK: With overloaded methods, fun will never get annotated. This is because
- // the 'overloaded' type gets annotated, but not the alternatives (among which
- // fun's type is chosen)
-
- vprintln("[checker] checking select apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, tpe, qual::(transArgList(fun, args).flatten), Nil)
-
- case Apply(TypeApply(fun @ Select(qual, name), targs), args) if fun.isTyped => // not trigge
-
- vprintln("[checker] checking select apply type-apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, tpe, qual::(transArgList(fun, args).flatten), Nil)
-
- case TypeApply(fun @ Select(qual, name), args) if fun.isTyped =>
- def stripNullaryMethodType(tp: Type) = tp match { case NullaryMethodType(restpe) => restpe case tp => tp }
- vprintln("[checker] checking select type-apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, stripNullaryMethodType(tpe), List(qual, fun), Nil)
-
- case Apply(fun, args) if fun.isTyped =>
-
- vprintln("[checker] checking unknown apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, tpe, fun::(transArgList(fun, args).flatten), Nil)
-
- case TypeApply(fun, args) =>
-
- vprintln("[checker] checking unknown type apply " + tree + "/" + tpe)
-
- transChildrenInOrder(tree, tpe, List(fun), Nil)
-
- case Select(qual, name) if qual.isTyped =>
-
- vprintln("[checker] checking select " + tree + "/" + tpe)
-
- // straightforward way is problematic (see select.scala and Test2.scala)
- // transChildrenInOrder(tree, tpe, List(qual), Nil)
-
- // the problem is that qual may be of type OverloadedType (or MethodType) and
- // we cannot safely annotate these. so we just ignore these cases and
- // clean up later in the Apply/TypeApply trees.
-
- if (hasCpsParamTypes(qual.tpe)) {
- // however there is one special case:
- // if it's a method without parameters, just apply it. normally done in adapt, but
- // we have to do it here so we don't lose the cps information (wouldn't trigger our
- // adapt and there is no Apply/TypeApply created)
- tpe match {
- case NullaryMethodType(restpe) =>
- //println("yep: " + restpe + "," + restpe.getClass)
- transChildrenInOrder(tree, restpe, List(qual), Nil)
- case _ : PolyType => tpe
- case _ : MethodType => tpe
- case _ : OverloadedType => tpe
- case _ =>
- transChildrenInOrder(tree, tpe, List(qual), Nil)
- }
- } else
- tpe
-
- case If(cond, thenp, elsep) =>
- transChildrenInOrder(tree, tpe, List(cond), List(thenp, elsep))
-
- case Match(select, cases) =>
- transChildrenInOrder(tree, tpe, List(select), cases:::(cases map { case CaseDef(_, _, body) => body }))
-
- case Try(block, catches, finalizer) =>
- val tpe1 = transChildrenInOrder(tree, tpe, Nil, block::catches:::(catches map { case CaseDef(_, _, body) => body }))
-
- val annots = cpsParamAnnotation(tpe1)
- if (annots.nonEmpty) {
- val ann = single(annots)
- val (atp0, atp1) = annTypes(ann)
- if (!(atp0 =:= atp1))
- throw new TypeError("only simple cps types allowed in try/catch blocks (found: " + tpe1 + ")")
- if (!finalizer.isEmpty) // no finalizers allowed. see explanation in SelectiveCPSTransform
- reporter.error(tree.pos, "try/catch blocks that use continuations cannot have finalizers")
- }
- tpe1
-
- case Block(stms, expr) =>
- // if any stm has annotation, so does block
- transChildrenInOrder(tree, tpe, transStms(stms), List(expr))
-
- case ValDef(mods, name, tpt, rhs) =>
- vprintln("[checker] checking valdef " + name + "/"+tpe+"/"+tpt+"/"+tree.symbol.tpe)
- // ValDef symbols must *not* have annotations!
- // lazy vals are currently not supported
- // but if we erase here all annotations, compiler will complain only
- // when generating bytecode.
- // This way lazy vals will be reported as unsupported feature later rather than weird type error.
- if (hasAnswerTypeAnn(tree.symbol.info) && !mods.isLazy) { // is it okay to modify sym here?
- vprintln("removing annotation from sym " + tree.symbol + "/" + tree.symbol.tpe + "/" + tpt)
- tpt modifyType removeAllCPSAnnotations
- tree.symbol modifyInfo removeAllCPSAnnotations
- }
- tpe
-
- case _ =>
- tpe
- }
-
-
- }
- }
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
deleted file mode 100644
index 98d0695865..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
+++ /dev/null
@@ -1,137 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc.Global
-
-trait CPSUtils {
- val global: Global
- import global._
-
- val cpsEnabled: Boolean
- val verbose: Boolean = System.getProperty("cpsVerbose", "false") == "true"
- def vprintln(x: =>Any): Unit = if (verbose) println(x)
-
- object cpsNames {
- val catches = newTermName("$catches")
- val ex = newTermName("$ex")
- val flatMapCatch = newTermName("flatMapCatch")
- val getTrivialValue = newTermName("getTrivialValue")
- val isTrivial = newTermName("isTrivial")
- val reify = newTermName("reify")
- val reifyR = newTermName("reifyR")
- val shift = newTermName("shift")
- val shiftR = newTermName("shiftR")
- val shiftSuffix = newTermName("$shift")
- val shiftUnit0 = newTermName("shiftUnit0")
- val shiftUnit = newTermName("shiftUnit")
- val shiftUnitR = newTermName("shiftUnitR")
- }
-
- lazy val MarkerCPSSym = rootMirror.getRequiredClass("scala.util.continuations.cpsSym")
- lazy val MarkerCPSTypes = rootMirror.getRequiredClass("scala.util.continuations.cpsParam")
- lazy val MarkerCPSSynth = rootMirror.getRequiredClass("scala.util.continuations.cpsSynth")
- lazy val MarkerCPSAdaptPlus = rootMirror.getRequiredClass("scala.util.continuations.cpsPlus")
- lazy val MarkerCPSAdaptMinus = rootMirror.getRequiredClass("scala.util.continuations.cpsMinus")
-
- lazy val Context = rootMirror.getRequiredClass("scala.util.continuations.ControlContext")
- lazy val ModCPS = rootMirror.getPackage("scala.util.continuations")
-
- lazy val MethShiftUnit = definitions.getMember(ModCPS, cpsNames.shiftUnit)
- lazy val MethShiftUnit0 = definitions.getMember(ModCPS, cpsNames.shiftUnit0)
- lazy val MethShiftUnitR = definitions.getMember(ModCPS, cpsNames.shiftUnitR)
- lazy val MethShift = definitions.getMember(ModCPS, cpsNames.shift)
- lazy val MethShiftR = definitions.getMember(ModCPS, cpsNames.shiftR)
- lazy val MethReify = definitions.getMember(ModCPS, cpsNames.reify)
- lazy val MethReifyR = definitions.getMember(ModCPS, cpsNames.reifyR)
-
- lazy val allCPSAnnotations = List(MarkerCPSSym, MarkerCPSTypes, MarkerCPSSynth,
- MarkerCPSAdaptPlus, MarkerCPSAdaptMinus)
-
- // TODO - needed? Can these all use the same annotation info?
- protected def newSynthMarker() = newMarker(MarkerCPSSynth)
- protected def newPlusMarker() = newMarker(MarkerCPSAdaptPlus)
- protected def newMinusMarker() = newMarker(MarkerCPSAdaptMinus)
- protected def newMarker(tpe: Type): AnnotationInfo = AnnotationInfo marker tpe
- protected def newMarker(sym: Symbol): AnnotationInfo = AnnotationInfo marker sym.tpe
-
- protected def newCpsParamsMarker(tp1: Type, tp2: Type) =
- newMarker(appliedType(MarkerCPSTypes, tp1, tp2))
-
- // annotation checker
-
- protected def annTypes(ann: AnnotationInfo): (Type, Type) = {
- val tp0 :: tp1 :: Nil = ann.atp.dealiasWiden.typeArgs
- ((tp0, tp1))
- }
- protected def hasMinusMarker(tpe: Type) = tpe hasAnnotation MarkerCPSAdaptMinus
- protected def hasPlusMarker(tpe: Type) = tpe hasAnnotation MarkerCPSAdaptPlus
- protected def hasSynthMarker(tpe: Type) = tpe hasAnnotation MarkerCPSSynth
- protected def hasCpsParamTypes(tpe: Type) = tpe hasAnnotation MarkerCPSTypes
- protected def cpsParamTypes(tpe: Type) = tpe getAnnotation MarkerCPSTypes map annTypes
-
- def filterAttribs(tpe:Type, cls:Symbol) =
- tpe.annotations filter (_ matches cls)
-
- def removeAttribs(tpe: Type, classes: Symbol*) =
- tpe filterAnnotations (ann => !(classes exists (ann matches _)))
-
- def removeAllCPSAnnotations(tpe: Type) = removeAttribs(tpe, allCPSAnnotations:_*)
-
- def cpsParamAnnotation(tpe: Type) = filterAttribs(tpe, MarkerCPSTypes)
-
- def linearize(ann: List[AnnotationInfo]): AnnotationInfo = {
- ann reduceLeft { (a, b) =>
- val (u0,v0) = annTypes(a)
- val (u1,v1) = annTypes(b)
- // vprintln("check lin " + a + " andThen " + b)
-
- if (v1 <:< u0)
- newCpsParamsMarker(u1, v0)
- else
- throw new TypeError("illegal answer type modification: " + a + " andThen " + b)
- }
- }
-
- // anf transform
-
- def getExternalAnswerTypeAnn(tp: Type) = {
- cpsParamTypes(tp) orElse {
- if (hasPlusMarker(tp))
- global.warning("trying to instantiate type " + tp + " to unknown cps type")
- None
- }
- }
-
- def getAnswerTypeAnn(tp: Type): Option[(Type, Type)] =
- cpsParamTypes(tp) filterNot (_ => hasPlusMarker(tp))
-
- def hasAnswerTypeAnn(tp: Type) =
- hasCpsParamTypes(tp) && !hasPlusMarker(tp)
-
- def updateSynthFlag(tree: Tree) = { // remove annotations if *we* added them (@synth present)
- if (hasSynthMarker(tree.tpe)) {
- log("removing annotation from " + tree)
- tree modifyType removeAllCPSAnnotations
- } else
- tree
- }
-
- type CPSInfo = Option[(Type,Type)]
-
- def linearize(a: CPSInfo, b: CPSInfo)(implicit unit: CompilationUnit, pos: Position): CPSInfo = {
- (a,b) match {
- case (Some((u0,v0)), Some((u1,v1))) =>
- vprintln("check lin " + a + " andThen " + b)
- if (!(v1 <:< u0)) {
- unit.error(pos,"cannot change answer type in composition of cps expressions " +
- "from " + u1 + " to " + v0 + " because " + v1 + " is not a subtype of " + u0 + ".")
- throw new Exception("check lin " + a + " andThen " + b)
- }
- Some((u1,v0))
- case (Some(_), _) => a
- case (_, Some(_)) => b
- case _ => None
- }
- }
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
deleted file mode 100644
index ae95a1bdac..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
+++ /dev/null
@@ -1,545 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc.transform._
-import scala.tools.nsc.symtab._
-import scala.tools.nsc.plugins._
-
-/**
- * In methods marked @cps, explicitly name results of calls to other @cps methods
- */
-abstract class SelectiveANFTransform extends PluginComponent with Transform with
- TypingTransformers with CPSUtils {
- // inherits abstract value `global` and class `Phase` from Transform
-
- import global._ // the global environment
- import definitions._ // standard classes and methods
- import typer.atOwner // methods to type trees
-
- override def description = "ANF pre-transform for @cps"
-
- /** the following two members override abstract members in Transform */
- val phaseName: String = "selectiveanf"
-
- protected def newTransformer(unit: CompilationUnit): Transformer =
- new ANFTransformer(unit)
-
- class ANFTransformer(unit: CompilationUnit) extends TypingTransformer(unit) {
-
- implicit val _unit = unit // allow code in CPSUtils.scala to report errors
- var cpsAllowed: Boolean = false // detect cps code in places we do not handle (yet)
-
- object RemoveTailReturnsTransformer extends Transformer {
- override def transform(tree: Tree): Tree = tree match {
- case Block(stms, r @ Return(expr)) =>
- treeCopy.Block(tree, stms, expr)
-
- case Block(stms, expr) =>
- treeCopy.Block(tree, stms, transform(expr))
-
- case If(cond, r1 @ Return(thenExpr), r2 @ Return(elseExpr)) =>
- treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
-
- case If(cond, r1 @ Return(thenExpr), elseExpr) =>
- treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
-
- case If(cond, thenExpr, r2 @ Return(elseExpr)) =>
- treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
-
- case If(cond, thenExpr, elseExpr) =>
- treeCopy.If(tree, cond, transform(thenExpr), transform(elseExpr))
-
- case Try(block, catches, finalizer) =>
- treeCopy.Try(tree,
- transform(block),
- (catches map (t => transform(t))).asInstanceOf[List[CaseDef]],
- transform(finalizer))
-
- case CaseDef(pat, guard, r @ Return(expr)) =>
- treeCopy.CaseDef(tree, pat, guard, expr)
-
- case CaseDef(pat, guard, body) =>
- treeCopy.CaseDef(tree, pat, guard, transform(body))
-
- case Return(_) =>
- unit.error(tree.pos, "return expressions in CPS code must be in tail position")
- tree
-
- case _ =>
- super.transform(tree)
- }
- }
-
- def removeTailReturns(body: Tree): Tree = {
- // support body with single return expression
- body match {
- case Return(expr) => expr
- case _ => RemoveTailReturnsTransformer.transform(body)
- }
- }
-
- override def transform(tree: Tree): Tree = {
- if (!cpsEnabled) return tree
-
- tree match {
-
- // Maybe we should further generalize the transform and move it over
- // to the regular Transformer facility. But then, actual and required cps
- // state would need more complicated (stateful!) tracking.
-
- // Making the default case use transExpr(tree, None, None) instead of
- // calling super.transform() would be a start, but at the moment,
- // this would cause infinite recursion. But we could remove the
- // ValDef case here.
-
- case dd @ DefDef(mods, name, tparams, vparamss, tpt, rhs0) =>
- debuglog("transforming " + dd.symbol)
-
- atOwner(dd.symbol) {
- val rhs =
- if (cpsParamTypes(tpt.tpe).nonEmpty) removeTailReturns(rhs0)
- else rhs0
- val rhs1 = transExpr(rhs, None, getExternalAnswerTypeAnn(tpt.tpe))(getExternalAnswerTypeAnn(tpt.tpe).isDefined)
-
- debuglog("result "+rhs1)
- debuglog("result is of type "+rhs1.tpe)
-
- treeCopy.DefDef(dd, mods, name, transformTypeDefs(tparams), transformValDefss(vparamss),
- transform(tpt), rhs1)
- }
-
- case ff @ Function(vparams, body) =>
- debuglog("transforming anon function " + ff.symbol)
-
- atOwner(ff.symbol) {
-
- //val body1 = transExpr(body, None, getExternalAnswerTypeAnn(body.tpe))
-
- // need to special case partial functions: if expected type is @cps
- // but all cases are pure, then we would transform
- // { x => x match { case A => ... }} to
- // { x => shiftUnit(x match { case A => ... })}
- // which Uncurry cannot handle (see function6.scala)
- // thus, we push down the shiftUnit to each of the case bodies
-
- val ext = getExternalAnswerTypeAnn(body.tpe)
- val pureBody = getAnswerTypeAnn(body.tpe).isEmpty
- implicit val isParentImpure = ext.isDefined
-
- def transformPureMatch(tree: Tree, selector: Tree, cases: List[CaseDef]) = {
- val caseVals = cases map { case cd @ CaseDef(pat, guard, body) =>
- // if (!hasPlusMarker(body.tpe)) body modifyType (_ withAnnotation newPlusMarker()) // TODO: to avoid warning
- val bodyVal = transExpr(body, None, ext) // ??? triggers "cps-transformed unexpectedly" warning in transTailValue
- treeCopy.CaseDef(cd, transform(pat), transform(guard), bodyVal)
- }
- treeCopy.Match(tree, transform(selector), caseVals)
- }
-
- def transformPureVirtMatch(body: Block, selDef: ValDef, cases: List[Tree], matchEnd: Tree) = {
- val stats = transform(selDef) :: (cases map (transExpr(_, None, ext)))
- treeCopy.Block(body, stats, transExpr(matchEnd, None, ext))
- }
-
- val body1 = body match {
- case Match(selector, cases) if ext.isDefined && pureBody =>
- transformPureMatch(body, selector, cases)
-
- // virtpatmat switch
- case Block(List(selDef: ValDef), mat@Match(selector, cases)) if ext.isDefined && pureBody =>
- treeCopy.Block(body, List(transform(selDef)), transformPureMatch(mat, selector, cases))
-
- // virtpatmat
- case b@Block(matchStats@((selDef: ValDef) :: cases), matchEnd) if ext.isDefined && pureBody && (matchStats forall treeInfo.hasSynthCaseSymbol) =>
- transformPureVirtMatch(b, selDef, cases, matchEnd)
-
- // virtpatmat that stores the scrut separately -- TODO: can we eliminate this case??
- case Block(List(selDef0: ValDef), mat@Block(matchStats@((selDef: ValDef) :: cases), matchEnd)) if ext.isDefined && pureBody && (matchStats forall treeInfo.hasSynthCaseSymbol)=>
- treeCopy.Block(body, List(transform(selDef0)), transformPureVirtMatch(mat, selDef, cases, matchEnd))
-
- case _ =>
- transExpr(body, None, ext)
- }
-
- debuglog("anf result "+body1+"\nresult is of type "+body1.tpe)
-
- treeCopy.Function(ff, transformValDefs(vparams), body1)
- }
-
- case vd @ ValDef(mods, name, tpt, rhs) => // object-level valdefs
- debuglog("transforming valdef " + vd.symbol)
-
- if (getExternalAnswerTypeAnn(tpt.tpe).isEmpty) {
-
- atOwner(vd.symbol) {
-
- val rhs1 = transExpr(rhs, None, None)
-
- treeCopy.ValDef(vd, mods, name, transform(tpt), rhs1)
- }
- } else {
- unit.error(tree.pos, "cps annotations not allowed on by-value parameters or value definitions")
- super.transform(tree)
- }
-
- case TypeTree() =>
- // circumvent cpsAllowed here
- super.transform(tree)
-
- case Apply(_,_) =>
- // this allows reset { ... } in object constructors
- // it's kind of a hack to put it here (see note above)
- transExpr(tree, None, None)
-
- case _ =>
- if (hasAnswerTypeAnn(tree.tpe)) {
- if (!cpsAllowed) {
- if (tree.symbol.isLazy)
- unit.error(tree.pos, "implementation restriction: cps annotations not allowed on lazy value definitions")
- else
- unit.error(tree.pos, "cps code not allowed here / " + tree.getClass + " / " + tree)
- }
- log(tree)
- }
-
- cpsAllowed = false
- super.transform(tree)
- }
- }
-
-
- def transExpr(tree: Tree, cpsA: CPSInfo, cpsR: CPSInfo)(implicit isAnyParentImpure: Boolean = false): Tree = {
- transTailValue(tree, cpsA, cpsR)(cpsR.isDefined || isAnyParentImpure) match {
- case (Nil, b) => b
- case (a, b) =>
- treeCopy.Block(tree, a,b)
- }
- }
-
-
- def transArgList(fun: Tree, args: List[Tree], cpsA: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[List[Tree]], List[Tree], CPSInfo) = {
- val formals = fun.tpe.paramTypes
- val overshoot = args.length - formals.length
-
- var spc: CPSInfo = cpsA
-
- val (stm,expr) = (for ((a,tp) <- args.zip(formals ::: List.fill(overshoot)(NoType))) yield {
- tp match {
- case TypeRef(_, ByNameParamClass, List(elemtp)) =>
- // note that we're not passing just isAnyParentImpure
- (Nil, transExpr(a, None, getAnswerTypeAnn(elemtp))(getAnswerTypeAnn(elemtp).isDefined || isAnyParentImpure))
- case _ =>
- val (valStm, valExpr, valSpc) = transInlineValue(a, spc)
- spc = valSpc
- (valStm, valExpr)
- }
- }).unzip
-
- (stm,expr,spc)
- }
-
-
- // precondition: cpsR.isDefined "implies" isAnyParentImpure
- def transValue(tree: Tree, cpsA: CPSInfo, cpsR: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], Tree, CPSInfo) = {
- // return value: (stms, expr, spc), where spc is CPSInfo after stms but *before* expr
- implicit val pos = tree.pos
- tree match {
- case Block(stms, expr) =>
- val (cpsA2, cpsR2) = (cpsA, linearize(cpsA, getAnswerTypeAnn(tree.tpe))) // tbd
- // val (cpsA2, cpsR2) = (None, getAnswerTypeAnn(tree.tpe))
-
- val (a, b) = transBlock(stms, expr, cpsA2, cpsR2)(cpsR2.isDefined || isAnyParentImpure)
- val tree1 = (treeCopy.Block(tree, a, b)) // no updateSynthFlag here!!!
-
- (Nil, tree1, cpsA)
-
- case If(cond, thenp, elsep) =>
- /* possible situations:
- cps before (cpsA)
- cps in condition (spc) <-- synth flag set if *only* here!
- cps in (one or both) branches */
- val (condStats, condVal, spc) = transInlineValue(cond, cpsA)
- val (cpsA2, cpsR2) = if (hasSynthMarker(tree.tpe))
- (spc, linearize(spc, getAnswerTypeAnn(tree.tpe))) else
- (None, getAnswerTypeAnn(tree.tpe)) // if no cps in condition, branches must conform to tree.tpe directly
- val thenVal = transExpr(thenp, cpsA2, cpsR2)(cpsR2.isDefined || isAnyParentImpure)
- val elseVal = transExpr(elsep, cpsA2, cpsR2)(cpsR2.isDefined || isAnyParentImpure)
-
- // check that then and else parts agree (not necessary any more, but left as sanity check)
- if (cpsR.isDefined) {
- if (elsep == EmptyTree)
- unit.error(tree.pos, "always need else part in cps code")
- }
- if (hasAnswerTypeAnn(thenVal.tpe) != hasAnswerTypeAnn(elseVal.tpe)) {
- unit.error(tree.pos, "then and else parts must both be cps code or neither of them")
- }
-
- (condStats, updateSynthFlag(treeCopy.If(tree, condVal, thenVal, elseVal)), spc)
-
- case Match(selector, cases) =>
- val (selStats, selVal, spc) = transInlineValue(selector, cpsA)
- val (cpsA2, cpsR2) =
- if (hasSynthMarker(tree.tpe)) (spc, linearize(spc, getAnswerTypeAnn(tree.tpe)))
- else (None, getAnswerTypeAnn(tree.tpe))
-
- val caseVals = cases map { case cd @ CaseDef(pat, guard, body) =>
- val bodyVal = transExpr(body, cpsA2, cpsR2)(cpsR2.isDefined || isAnyParentImpure)
- treeCopy.CaseDef(cd, transform(pat), transform(guard), bodyVal)
- }
-
- (selStats, updateSynthFlag(treeCopy.Match(tree, selVal, caseVals)), spc)
-
- // this is utterly broken: LabelDefs need to be considered together when transforming them to DefDefs:
- // suppose a Block {L1; ... ; LN}
- // this should become {D1def ; ... ; DNdef ; D1()}
- // where D$idef = def L$i(..) = {L$i.body; L${i+1}(..)}
-
- case ldef @ LabelDef(name, params, rhs) =>
- // println("trans LABELDEF "+(name, params, tree.tpe, hasAnswerTypeAnn(tree.tpe)))
- // TODO why does the labeldef's type have a cpsMinus annotation, whereas the rhs does not? (BYVALmode missing/too much somewhere?)
- if (hasAnswerTypeAnn(tree.tpe)) {
- // currentOwner.newMethod(name, tree.pos, Flags.SYNTHETIC) setInfo ldef.symbol.info
- val sym = ldef.symbol resetFlag Flags.LABEL
- val rhs1 = rhs //new TreeSymSubstituter(List(ldef.symbol), List(sym)).transform(rhs)
- val rhsVal = transExpr(rhs1, None, getAnswerTypeAnn(tree.tpe))(getAnswerTypeAnn(tree.tpe).isDefined || isAnyParentImpure) changeOwner (currentOwner -> sym)
-
- val stm1 = localTyper.typed(DefDef(sym, rhsVal))
- // since virtpatmat does not rely on fall-through, don't call the labels it emits
- // transBlock will take care of calling the first label
- // calling each labeldef is wrong, since some labels may be jumped over
- // we can get away with this for now since the only other labels we emit are for tailcalls/while loops,
- // which do not have consecutive labeldefs (and thus fall-through is irrelevant)
- if (treeInfo.hasSynthCaseSymbol(ldef)) (List(stm1), localTyper.typed{Literal(Constant(()))}, cpsA)
- else {
- assert(params.isEmpty, "problem in ANF transforming label with non-empty params "+ ldef)
- (List(stm1), localTyper.typed{Apply(Ident(sym), List())}, cpsA)
- }
- } else {
- val rhsVal = transExpr(rhs, None, None)
- (Nil, updateSynthFlag(treeCopy.LabelDef(tree, name, params, rhsVal)), cpsA)
- }
-
-
- case Try(block, catches, finalizer) =>
- val blockVal = transExpr(block, cpsA, cpsR)
-
- val catchVals = for {
- cd @ CaseDef(pat, guard, body) <- catches
- bodyVal = transExpr(body, cpsA, cpsR)
- } yield {
- treeCopy.CaseDef(cd, transform(pat), transform(guard), bodyVal)
- }
-
- val finallyVal = transExpr(finalizer, None, None) // for now, no cps in finally
-
- (Nil, updateSynthFlag(treeCopy.Try(tree, blockVal, catchVals, finallyVal)), cpsA)
-
- case Assign(lhs, rhs) =>
- // allow cps code in rhs only
- val (stms, expr, spc) = transInlineValue(rhs, cpsA)
- (stms, updateSynthFlag(treeCopy.Assign(tree, transform(lhs), expr)), spc)
-
- case Return(expr0) =>
- if (isAnyParentImpure)
- unit.error(tree.pos, "return expression not allowed, since method calls CPS method")
- val (stms, expr, spc) = transInlineValue(expr0, cpsA)
- (stms, updateSynthFlag(treeCopy.Return(tree, expr)), spc)
-
- case Throw(expr0) =>
- val (stms, expr, spc) = transInlineValue(expr0, cpsA)
- (stms, updateSynthFlag(treeCopy.Throw(tree, expr)), spc)
-
- 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 = 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) =>
- val (stms, expr, spc) = transInlineValue(fun, cpsA)
- (stms, updateSynthFlag(treeCopy.TypeApply(tree, expr, args)), spc)
-
- case Select(qual, name) =>
- val (stms, expr, spc) = transInlineValue(qual, cpsA)
- (stms, updateSynthFlag(treeCopy.Select(tree, expr, name)), spc)
-
- case Apply(fun, args) =>
- val (funStm, funExpr, funSpc) = transInlineValue(fun, cpsA)
- val (argStm, argExpr, argSpc) = transArgList(fun, args, funSpc)
-
- (funStm ::: (argStm.flatten), updateSynthFlag(treeCopy.Apply(tree, funExpr, argExpr)),
- argSpc)
-
- case _ =>
- cpsAllowed = true
- (Nil, transform(tree), cpsA)
- }
- }
-
- // precondition: cpsR.isDefined "implies" isAnyParentImpure
- def transTailValue(tree: Tree, cpsA: CPSInfo, cpsR: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], Tree) = {
-
- val (stms, expr, spc) = transValue(tree, cpsA, cpsR)
-
- val bot = linearize(spc, getAnswerTypeAnn(expr.tpe))(unit, tree.pos)
-
- val plainTpe = removeAllCPSAnnotations(expr.tpe)
-
- if (cpsR.isDefined && !bot.isDefined) {
-
- if (!expr.isEmpty && (expr.tpe.typeSymbol ne NothingClass)) {
- // must convert!
- debuglog("cps type conversion (has: " + cpsA + "/" + spc + "/" + expr.tpe + ")")
- debuglog("cps type conversion (expected: " + cpsR.get + "): " + expr)
-
- if (!hasPlusMarker(expr.tpe))
- unit.warning(tree.pos, "expression " + tree + " is cps-transformed unexpectedly")
-
- try {
- val Some((a, b)) = cpsR
- /* Since shiftUnit is bounded [A,B,C>:B] this may not typecheck
- * if C is overly specific. So if !(B <:< C), call shiftUnit0
- * instead, which takes only two type arguments.
- */
- val conforms = a <:< b
- val call = localTyper.typedPos(tree.pos)(
- Apply(
- TypeApply(
- gen.mkAttributedRef( if (conforms) MethShiftUnit else MethShiftUnit0 ),
- List(TypeTree(plainTpe), TypeTree(a)) ++ ( if (conforms) List(TypeTree(b)) else Nil )
- ),
- List(expr)
- )
- )
- // This is today's sick/meaningless heuristic for spotting breakdown so
- // we don't proceed until stack traces start draping themselves over everything.
- // If there are wildcard types in the tree and B == Nothing, something went wrong.
- // (I thought WildcardTypes would be enough, but nope. 'reset0 { 0 }' has them.)
- //
- // Code as simple as reset((_: String).length)
- // will crash meaninglessly without this check. See SI-3718.
- //
- // TODO - obviously this should be done earlier, differently, or with
- // a more skilled hand. Most likely, all three.
- if ((b.typeSymbol eq NothingClass) && call.tpe.exists(_ eq WildcardType))
- unit.error(tree.pos, "cannot cps-transform malformed (possibly in shift/reset placement) expression")
- else
- return ((stms, call))
- }
- catch {
- case ex:TypeError =>
- unit.error(ex.pos, "cannot cps-transform expression " + tree + ": " + ex.msg)
- }
- }
-
- } else if (!cpsR.isDefined && bot.isDefined) {
- // error!
- debuglog("cps type error: " + expr)
- //println("cps type error: " + expr + "/" + expr.tpe + "/" + getAnswerTypeAnn(expr.tpe))
-
- //println(cpsR + "/" + spc + "/" + bot)
-
- unit.error(tree.pos, "found cps expression in non-cps position")
- } else {
- // all is well
-
- if (hasPlusMarker(expr.tpe)) {
- unit.warning(tree.pos, "expression " + expr + " of type " + expr.tpe + " is not expected to have a cps type")
- expr modifyType removeAllCPSAnnotations
- }
-
- // TODO: sanity check that types agree
- }
-
- (stms, expr)
- }
-
- def transInlineValue(tree: Tree, cpsA: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], Tree, CPSInfo) = {
-
- val (stms, expr, spc) = transValue(tree, cpsA, None) // never required to be cps
-
- getAnswerTypeAnn(expr.tpe) match {
- case spcVal @ Some(_) =>
-
- val valueTpe = removeAllCPSAnnotations(expr.tpe)
-
- val sym: Symbol = (
- currentOwner.newValue(newTermName(unit.fresh.newName("tmp")), tree.pos, Flags.SYNTHETIC)
- setInfo valueTpe
- setAnnotations List(AnnotationInfo(MarkerCPSSym.tpe_*, Nil, Nil))
- )
- expr.changeOwner(currentOwner -> sym)
-
- (stms ::: List(ValDef(sym, expr) setType(NoType)),
- Ident(sym) setType(valueTpe) setPos(tree.pos), linearize(spc, spcVal)(unit, tree.pos))
-
- case _ =>
- (stms, expr, spc)
- }
-
- }
-
-
-
- def transInlineStm(stm: Tree, cpsA: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], CPSInfo) = {
- stm match {
-
- // TODO: what about DefDefs?
- // TODO: relation to top-level val def?
- // TODO: what about lazy vals?
-
- case tree @ ValDef(mods, name, tpt, rhs) =>
- val (stms, anfRhs, spc) = atOwner(tree.symbol) { transValue(rhs, cpsA, None) }
-
- val tv = new ChangeOwnerTraverser(tree.symbol, currentOwner)
- stms.foreach(tv.traverse(_))
-
- // TODO: symbol might already have annotation. Should check conformance
- // TODO: better yet: do without annotations on symbols
-
- val spcVal = getAnswerTypeAnn(anfRhs.tpe)
- spcVal foreach (_ => tree.symbol setAnnotations List(AnnotationInfo(MarkerCPSSym.tpe_*, Nil, Nil)))
-
- (stms:::List(treeCopy.ValDef(tree, mods, name, tpt, anfRhs)), linearize(spc, spcVal)(unit, tree.pos))
-
- case _ =>
- val (headStms, headExpr, headSpc) = transInlineValue(stm, cpsA)
- val valSpc = getAnswerTypeAnn(headExpr.tpe)
- (headStms:::List(headExpr), linearize(headSpc, valSpc)(unit, stm.pos))
- }
- }
-
- // precondition: cpsR.isDefined "implies" isAnyParentImpure
- def transBlock(stms: List[Tree], expr: Tree, cpsA: CPSInfo, cpsR: CPSInfo)(implicit isAnyParentImpure: Boolean): (List[Tree], Tree) = {
- def rec(currStats: List[Tree], currAns: CPSInfo, accum: List[Tree]): (List[Tree], Tree) =
- currStats match {
- case Nil =>
- val (anfStats, anfExpr) = transTailValue(expr, currAns, cpsR)
- (accum ++ anfStats, anfExpr)
-
- case stat :: rest =>
- val (stats, nextAns) = transInlineStm(stat, currAns)
- rec(rest, nextAns, accum ++ stats)
- }
-
- val (anfStats, anfExpr) = rec(stms, cpsA, List())
- // println("\nanf-block:\n"+ ((stms :+ expr) mkString ("{", "\n", "}")) +"\nBECAME\n"+ ((anfStats :+ anfExpr) mkString ("{", "\n", "}")))
- // println("synth case? "+ (anfStats map (t => (t, t.isDef, treeInfo.hasSynthCaseSymbol(t)))))
- // SUPER UGLY HACK: handle virtpatmat-style matches, whose labels have already been turned into DefDefs
- if (anfStats.nonEmpty && (anfStats forall (t => !t.isDef || treeInfo.hasSynthCaseSymbol(t)))) {
- val (prologue, rest) = (anfStats :+ anfExpr) span (s => !s.isInstanceOf[DefDef]) // find first case
- // println("rest: "+ rest)
- // val (defs, calls) = rest partition (_.isInstanceOf[DefDef])
- if (rest.nonEmpty) {
- // the filter drops the ()'s emitted when transValue encountered a LabelDef
- val stats = prologue ++ (rest filter (_.isInstanceOf[DefDef])).reverse // ++ calls
- // println("REVERSED "+ (stats mkString ("{", "\n", "}")))
- (stats, localTyper.typed{Apply(Ident(rest.head.symbol), List())}) // call first label to kick-start the match
- } else (anfStats, anfExpr)
- } else (anfStats, anfExpr)
- }
- }
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
deleted file mode 100644
index a7e82e949b..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc
-import nsc.Global
-import nsc.plugins.Plugin
-import nsc.plugins.PluginComponent
-
-class SelectiveCPSPlugin(val global: Global) extends Plugin {
- val name = "continuations"
- val description = "applies selective cps conversion"
-
- val pluginEnabled = options contains "enable"
-
- val anfPhase = new {
- val global = SelectiveCPSPlugin.this.global
- val cpsEnabled = pluginEnabled
- override val enabled = cpsEnabled
- } with SelectiveANFTransform {
- val runsAfter = List("pickler")
- }
-
- val cpsPhase = new {
- val global = SelectiveCPSPlugin.this.global
- val cpsEnabled = pluginEnabled
- override val enabled = cpsEnabled
- } with SelectiveCPSTransform {
- val runsAfter = List("selectiveanf")
- override val runsBefore = List("uncurry")
- }
-
- val components = List[PluginComponent](anfPhase, cpsPhase)
-
- val checker = new {
- val global: SelectiveCPSPlugin.this.global.type = SelectiveCPSPlugin.this.global
- val cpsEnabled = pluginEnabled
- } with CPSAnnotationChecker
-
- // TODO don't muck up global with unused checkers
- global.addAnnotationChecker(checker.checker)
- global.analyzer.addAnalyzerPlugin(checker.plugin)
-
- global.log("instantiated cps plugin: " + this)
-
- override def init(options: List[String], error: String => Unit) = {
- options foreach {
- case "enable" => // in initializer
- case arg => error(s"Bad argument: $arg")
- }
- pluginEnabled
- }
-
- override val optionsHelp: Option[String] =
- Some(" -P:continuations:enable Enable continuations")
-}
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
deleted file mode 100644
index 0210ad3459..0000000000
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
+++ /dev/null
@@ -1,383 +0,0 @@
-// $Id$
-
-package scala.tools.selectivecps
-
-import scala.tools.nsc.transform._
-import scala.tools.nsc.plugins._
-import scala.tools.nsc.ast._
-
-/**
- * In methods marked @cps, CPS-transform assignments introduced by ANF-transform phase.
- */
-abstract class SelectiveCPSTransform extends PluginComponent with
- InfoTransform with TypingTransformers with CPSUtils with TreeDSL {
- // inherits abstract value `global` and class `Phase` from Transform
-
- import global._ // the global environment
- import definitions._ // standard classes and methods
- import typer.atOwner // methods to type trees
-
- override def description = "@cps-driven transform of selectiveanf assignments"
-
- /** the following two members override abstract members in Transform */
- val phaseName: String = "selectivecps"
-
- protected def newTransformer(unit: CompilationUnit): Transformer =
- new CPSTransformer(unit)
-
- /** This class does not change linearization */
- override def changesBaseClasses = false
-
- /** - return symbol's transformed type,
- */
- def transformInfo(sym: Symbol, tp: Type): Type = {
- if (!cpsEnabled) return tp
-
- val newtp = transformCPSType(tp)
-
- if (newtp != tp)
- debuglog("transformInfo changed type for " + sym + " to " + newtp);
-
- if (sym == MethReifyR)
- debuglog("transformInfo (not)changed type for " + sym + " to " + newtp);
-
- newtp
- }
-
- def transformCPSType(tp: Type): Type = { // TODO: use a TypeMap? need to handle more cases?
- tp match {
- case PolyType(params,res) => PolyType(params, transformCPSType(res))
- case NullaryMethodType(res) => NullaryMethodType(transformCPSType(res))
- case MethodType(params,res) => MethodType(params, transformCPSType(res))
- case TypeRef(pre, sym, args) => TypeRef(pre, sym, args.map(transformCPSType(_)))
- case _ =>
- getExternalAnswerTypeAnn(tp) match {
- case Some((res, outer)) =>
- appliedType(Context.tpeHK, List(removeAllCPSAnnotations(tp), res, outer))
- case _ =>
- removeAllCPSAnnotations(tp)
- }
- }
- }
-
-
- class CPSTransformer(unit: CompilationUnit) extends TypingTransformer(unit) {
- private val patmatTransformer = patmat.newTransformer(unit)
-
- override def transform(tree: Tree): Tree = {
- if (!cpsEnabled) return tree
- postTransform(mainTransform(tree))
- }
-
- def postTransform(tree: Tree): Tree = {
- tree.setType(transformCPSType(tree.tpe))
- }
-
-
- def mainTransform(tree: Tree): Tree = {
- tree match {
-
- // TODO: can we generalize this?
-
- case Apply(TypeApply(fun, targs), args)
- if (fun.symbol == MethShift) =>
- debuglog("found shift: " + tree)
- atPos(tree.pos) {
- val funR = gen.mkAttributedRef(MethShiftR) // TODO: correct?
- //gen.mkAttributedSelect(gen.mkAttributedSelect(gen.mkAttributedSelect(gen.mkAttributedIdent(ScalaPackage),
- //ScalaPackage.tpe.member("util")), ScalaPackage.tpe.member("util").tpe.member("continuations")), MethShiftR)
- //gen.mkAttributedRef(ModCPS.tpe, MethShiftR) // TODO: correct?
- debuglog("funR.tpe: " + funR.tpe)
- Apply(
- TypeApply(funR, targs).setType(appliedType(funR.tpe, targs.map((t:Tree) => t.tpe))),
- args.map(transform(_))
- ).setType(transformCPSType(tree.tpe))
- }
-
- case Apply(TypeApply(fun, targs), args)
- if (fun.symbol == MethShiftUnit) =>
- debuglog("found shiftUnit: " + tree)
- atPos(tree.pos) {
- val funR = gen.mkAttributedRef(MethShiftUnitR) // TODO: correct?
- debuglog("funR.tpe: " + funR.tpe)
- Apply(
- TypeApply(funR, List(targs(0), targs(1))).setType(appliedType(funR.tpe,
- List(targs(0).tpe, targs(1).tpe))),
- args.map(transform(_))
- ).setType(appliedType(Context.tpeHK, List(targs(0).tpe,targs(1).tpe,targs(1).tpe)))
- }
-
- case Apply(TypeApply(fun, targs), args)
- if (fun.symbol == MethReify) =>
- log("found reify: " + tree)
- atPos(tree.pos) {
- val funR = gen.mkAttributedRef(MethReifyR) // TODO: correct?
- debuglog("funR.tpe: " + funR.tpe)
- Apply(
- TypeApply(funR, targs).setType(appliedType(funR.tpe, targs.map((t:Tree) => t.tpe))),
- args.map(transform(_))
- ).setType(transformCPSType(tree.tpe))
- }
-
- case Try(block, catches, finalizer) =>
- // currently duplicates the catch block into a partial function.
- // this is kinda risky, but we don't expect there will be lots
- // of try/catches inside catch blocks (exp. blowup unlikely).
-
- // CAVEAT: finalizers are surprisingly tricky!
- // the problem is that they cannot easily be removed
- // from the regular control path and hence will
- // also be invoked after creating the Context object.
-
- /*
- object Test {
- def foo1 = {
- throw new Exception("in sub")
- shift((k:Int=>Int) => k(1))
- 10
- }
- def foo2 = {
- shift((k:Int=>Int) => k(2))
- 20
- }
- def foo3 = {
- shift((k:Int=>Int) => k(3))
- throw new Exception("in sub")
- 30
- }
- def foo4 = {
- shift((k:Int=>Int) => 4)
- throw new Exception("in sub")
- 40
- }
- def bar(x: Int) = try {
- if (x == 1)
- foo1
- else if (x == 2)
- foo2
- else if (x == 3)
- foo3
- else //if (x == 4)
- foo4
- } catch {
- case _ =>
- println("exception")
- 0
- } finally {
- println("done")
- }
- }
-
- reset(Test.bar(1)) // should print: exception,done,0
- reset(Test.bar(2)) // should print: done,20 <-- but prints: done,done,20
- reset(Test.bar(3)) // should print: exception,done,0 <-- but prints: done,exception,done,0
- reset(Test.bar(4)) // should print: 4 <-- but prints: done,4
- */
-
- val block1 = transform(block)
- val catches1 = transformCaseDefs(catches)
- val finalizer1 = transform(finalizer)
-
- if (hasAnswerTypeAnn(tree.tpe)) {
- //vprintln("CPS Transform: " + tree + "/" + tree.tpe + "/" + block1.tpe)
-
- val (stms, expr1) = block1 match {
- case Block(stms, expr) => (stms, expr)
- case expr => (Nil, expr)
- }
-
- val targettp = transformCPSType(tree.tpe)
-
- val pos = catches.head.pos
- val funSym = currentOwner.newValueParameter(cpsNames.catches, pos).setInfo(appliedType(PartialFunctionClass, ThrowableTpe, targettp))
- val funDef = localTyper.typedPos(pos) {
- ValDef(funSym, Match(EmptyTree, catches1))
- }
- val expr2 = localTyper.typedPos(pos) {
- Apply(Select(expr1, expr1.tpe.member(cpsNames.flatMapCatch)), List(Ident(funSym)))
- }
-
- val exSym = currentOwner.newValueParameter(cpsNames.ex, pos).setInfo(ThrowableTpe)
-
- import CODE._
- // generate a case that is supported directly by the back-end
- val catchIfDefined = CaseDef(
- Bind(exSym, Ident(nme.WILDCARD)),
- EmptyTree,
- IF ((REF(funSym) DOT nme.isDefinedAt)(REF(exSym))) THEN (REF(funSym) APPLY (REF(exSym))) ELSE Throw(REF(exSym))
- )
-
- val catch2 = localTyper.typedCases(List(catchIfDefined), ThrowableTpe, targettp)
- //typedCases(tree, catches, ThrowableTpe, pt)
-
- patmatTransformer.transform(localTyper.typed(Block(List(funDef), treeCopy.Try(tree, treeCopy.Block(block1, stms, expr2), catch2, finalizer1))))
-
-
-/*
- disabled for now - see notes above
-
- val expr3 = if (!finalizer.isEmpty) {
- val pos = finalizer.pos
- val finalizer2 = duplicateTree(finalizer1)
- val fun = Function(List(), finalizer2)
- val expr3 = localTyper.typedPos(pos) { Apply(Select(expr2, expr2.tpe.member("mapFinally")), List(fun)) }
-
- val chown = new ChangeOwnerTraverser(currentOwner, fun.symbol)
- chown.traverse(finalizer2)
-
- expr3
- } else
- expr2
-*/
- } else {
- treeCopy.Try(tree, block1, catches1, finalizer1)
- }
-
- case Block(stms, expr) =>
-
- val (stms1, expr1) = transBlock(stms, expr)
- treeCopy.Block(tree, stms1, expr1)
-
- case _ =>
- super.transform(tree)
- }
- }
-
-
-
- def transBlock(stms: List[Tree], expr: Tree): (List[Tree], Tree) = {
-
- stms match {
- case Nil =>
- (Nil, transform(expr))
-
- case stm::rest =>
-
- stm match {
- case vd @ ValDef(mods, name, tpt, rhs)
- if (vd.symbol.hasAnnotation(MarkerCPSSym)) =>
-
- debuglog("found marked ValDef "+name+" of type " + vd.symbol.tpe)
-
- val tpe = vd.symbol.tpe
- val rhs1 = atOwner(vd.symbol) { transform(rhs) }
- rhs1.changeOwner(vd.symbol -> currentOwner) // TODO: don't traverse twice
-
- debuglog("valdef symbol " + vd.symbol + " has type " + tpe)
- debuglog("right hand side " + rhs1 + " has type " + rhs1.tpe)
-
- debuglog("currentOwner: " + currentOwner)
- debuglog("currentMethod: " + currentMethod)
-
- val (bodyStms, bodyExpr) = transBlock(rest, expr)
- // FIXME: result will later be traversed again by TreeSymSubstituter and
- // ChangeOwnerTraverser => exp. running time.
- // Should be changed to fuse traversals into one.
-
- val specialCaseTrivial = bodyExpr match {
- case Apply(fun, args) =>
- // for now, look for explicit tail calls only.
- // are there other cases that could profit from specializing on
- // trivial contexts as well?
- (bodyExpr.tpe.typeSymbol == Context) && (currentMethod == fun.symbol)
- case _ => false
- }
-
- def applyTrivial(ctxValSym: Symbol, body: Tree) = {
-
- val body1 = (new TreeSymSubstituter(List(vd.symbol), List(ctxValSym)))(body)
-
- val body2 = localTyper.typedPos(vd.symbol.pos) { body1 }
-
- // in theory it would be nicer to look for an @cps annotation instead
- // of testing for Context
- if ((body2.tpe == null) || !(body2.tpe.typeSymbol == Context)) {
- //println(body2 + "/" + body2.tpe)
- unit.error(rhs.pos, "cannot compute type for CPS-transformed function result")
- }
- body2
- }
-
- def applyCombinatorFun(ctxR: Tree, body: Tree) = {
- val arg = currentOwner.newValueParameter(name, ctxR.pos).setInfo(tpe)
- val body1 = (new TreeSymSubstituter(List(vd.symbol), List(arg)))(body)
- val fun = localTyper.typedPos(vd.symbol.pos) { Function(List(ValDef(arg)), body1) } // types body as well
- arg.owner = fun.symbol
- body1.changeOwner(currentOwner -> fun.symbol)
-
- // see note about multiple traversals above
-
- debuglog("fun.symbol: "+fun.symbol)
- debuglog("fun.symbol.owner: "+fun.symbol.owner)
- debuglog("arg.owner: "+arg.owner)
-
- debuglog("fun.tpe:"+fun.tpe)
- debuglog("return type of fun:"+body1.tpe)
-
- var methodName = nme.map
-
- if (body1.tpe != null) {
- if (body1.tpe.typeSymbol == Context)
- methodName = nme.flatMap
- }
- else
- unit.error(rhs.pos, "cannot compute type for CPS-transformed function result")
-
- debuglog("will use method:"+methodName)
-
- localTyper.typedPos(vd.symbol.pos) {
- Apply(Select(ctxR, ctxR.tpe.member(methodName)), List(fun))
- }
- }
-
- // TODO use gen.mkBlock after 2.11.0-M6. Why wait? It allows us to still build in development
- // mode with `ant -DskipLocker=1`
- def mkBlock(stms: List[Tree], expr: Tree) = if (stms.nonEmpty) Block(stms, expr) else expr
-
- try {
- if (specialCaseTrivial) {
- debuglog("will optimize possible tail call: " + bodyExpr)
-
- // FIXME: flatMap impl has become more complicated due to
- // exceptions. do we need to put a try/catch in the then part??
-
- // val ctx = <rhs>
- // if (ctx.isTrivial)
- // val <lhs> = ctx.getTrivialValue; ... <--- TODO: try/catch ??? don't bother for the moment...
- // else
- // ctx.flatMap { <lhs> => ... }
- val ctxSym = currentOwner.newValue(newTermName("" + vd.symbol.name + cpsNames.shiftSuffix)).setInfo(rhs1.tpe)
- val ctxDef = localTyper.typed(ValDef(ctxSym, rhs1))
- def ctxRef = localTyper.typed(Ident(ctxSym))
- val argSym = currentOwner.newValue(vd.symbol.name.toTermName).setInfo(tpe)
- val argDef = localTyper.typed(ValDef(argSym, Select(ctxRef, ctxRef.tpe.member(cpsNames.getTrivialValue))))
- val switchExpr = localTyper.typedPos(vd.symbol.pos) {
- val body2 = mkBlock(bodyStms, bodyExpr).duplicate // dup before typing!
- If(Select(ctxRef, ctxSym.tpe.member(cpsNames.isTrivial)),
- applyTrivial(argSym, mkBlock(argDef::bodyStms, bodyExpr)),
- applyCombinatorFun(ctxRef, body2))
- }
- (List(ctxDef), switchExpr)
- } else {
- // ctx.flatMap { <lhs> => ... }
- // or
- // ctx.map { <lhs> => ... }
- (Nil, applyCombinatorFun(rhs1, mkBlock(bodyStms, bodyExpr)))
- }
- } catch {
- case ex:TypeError =>
- unit.error(ex.pos, ex.msg)
- (bodyStms, bodyExpr)
- }
-
- case _ =>
- val stm1 = transform(stm)
- val (a, b) = transBlock(rest, expr)
- (stm1::a, b)
- }
- }
- }
-
-
- }
-}
diff --git a/src/continuations/plugin/scalac-plugin.xml b/src/continuations/plugin/scalac-plugin.xml
deleted file mode 100644
index 04d42655c5..0000000000
--- a/src/continuations/plugin/scalac-plugin.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<!-- $Id$ -->
-<plugin>
- <name>continuations</name>
- <classname>scala.tools.selectivecps.SelectiveCPSPlugin</classname>
-</plugin>
diff --git a/src/eclipse/continuations-library/.classpath b/src/eclipse/continuations-library/.classpath
deleted file mode 100644
index 61cb3f060e..0000000000
--- a/src/eclipse/continuations-library/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="continuations-library"/>
- <classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
- <classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="build-quick-continuations-library"/>
-</classpath>
diff --git a/src/eclipse/continuations-library/.project b/src/eclipse/continuations-library/.project
deleted file mode 100644
index 33cc57d667..0000000000
--- a/src/eclipse/continuations-library/.project
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>continuations-library</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.scala-ide.sdt.core.scalabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.scala-ide.sdt.core.scalanature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
- <linkedResources>
- <link>
- <name>build-quick-continuations-library</name>
- <type>2</type>
- <locationURI>SCALA_BASEDIR/build/quick/classes/continuations/library</locationURI>
- </link>
- <link>
- <name>continuations-library</name>
- <type>2</type>
- <locationURI>SCALA_BASEDIR/src/continuations/library</locationURI>
- </link>
- </linkedResources>
-</projectDescription>
diff --git a/src/eclipse/continuations-library/.settings/org.scala-ide.sdt.core.prefs b/src/eclipse/continuations-library/.settings/org.scala-ide.sdt.core.prefs
deleted file mode 100644
index 63e1df247f..0000000000
--- a/src/eclipse/continuations-library/.settings/org.scala-ide.sdt.core.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
-P=continuations\:enable
-scala.compiler.useProjectSettings=true
diff --git a/src/eclipse/reflect/.classpath b/src/eclipse/reflect/.classpath
index 1eb37e3f5f..3f14621da7 100644
--- a/src/eclipse/reflect/.classpath
+++ b/src/eclipse/reflect/.classpath
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="src" path="reflect"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
- <classpathentry combineaccessrules="false" kind="src" path="/continuations-library"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build-quick-reflect"/>
</classpath>
diff --git a/src/eclipse/scala-compiler/.classpath b/src/eclipse/scala-compiler/.classpath
index c185bc5391..e81cacca26 100644
--- a/src/eclipse/scala-compiler/.classpath
+++ b/src/eclipse/scala-compiler/.classpath
@@ -4,7 +4,6 @@
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/asm"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/reflect"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scala-library"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/continuations-library"/>
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build-quick-compiler"/>
diff --git a/src/eclipse/test-junit/.classpath b/src/eclipse/test-junit/.classpath
index fe3c3e4f18..d028dcc21e 100644
--- a/src/eclipse/test-junit/.classpath
+++ b/src/eclipse/test-junit/.classpath
@@ -5,7 +5,6 @@
<classpathentry kind="var" path="M2_REPO/junit/junit/4.10/junit-4.10.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/reflect"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
- <classpathentry combineaccessrules="false" kind="src" path="/continuations-library"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
<classpathentry kind="output" path="build-test-junit"/>
diff --git a/src/intellij/continuations-library.iml.SAMPLE b/src/intellij/continuations-library.iml.SAMPLE
deleted file mode 100644
index 364cc3dcdb..0000000000
--- a/src/intellij/continuations-library.iml.SAMPLE
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="scala" name="Scala">
- <configuration>
- <option name="compilerLibraryLevel" value="Project" />
- <option name="compilerLibraryName" value="compiler-locker" />
- <option name="maximumHeapSize" value="1536" />
- <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$/../continuations/library">
- <sourceFolder url="file://$MODULE_DIR$/../continuations/library" isTestSource="false" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="module" module-name="library" />
- </component>
-</module>
-
diff --git a/src/intellij/continuations-plugin.iml.SAMPLE b/src/intellij/continuations-plugin.iml.SAMPLE
deleted file mode 100644
index 27213374b3..0000000000
--- a/src/intellij/continuations-plugin.iml.SAMPLE
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="scala" name="Scala">
- <configuration>
- <option name="compilerLibraryLevel" value="Project" />
- <option name="compilerLibraryName" value="compiler-locker" />
- <option name="maximumHeapSize" value="1536" />
- <option name="vmOptions" value="-Xms1536m -Xss1m -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseCompressedOops -XX:+UseParallelGC" />
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$/../continuations/plugin">
- <sourceFolder url="file://$MODULE_DIR$/../continuations/plugin" isTestSource="false" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="module" module-name="library" />
- <orderEntry type="module" module-name="compiler" />
- <orderEntry type="module" module-name="reflect" />
- </component>
-</module>
-
diff --git a/src/intellij/scala-lang.ipr.SAMPLE b/src/intellij/scala-lang.ipr.SAMPLE
index f91a346b75..975014cb6d 100644
--- a/src/intellij/scala-lang.ipr.SAMPLE
+++ b/src/intellij/scala-lang.ipr.SAMPLE
@@ -201,8 +201,6 @@
<module fileurl="file://$PROJECT_DIR$/actors.iml" filepath="$PROJECT_DIR$/actors.iml" />
<module fileurl="file://$PROJECT_DIR$/asm.iml" filepath="$PROJECT_DIR$/asm.iml" />
<module fileurl="file://$PROJECT_DIR$/compiler.iml" filepath="$PROJECT_DIR$/compiler.iml" />
- <module fileurl="file://$PROJECT_DIR$/continuations-library.iml" filepath="$PROJECT_DIR$/continuations-library.iml" />
- <module fileurl="file://$PROJECT_DIR$/continuations-plugin.iml" filepath="$PROJECT_DIR$/continuations-plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/forkjoin.iml" filepath="$PROJECT_DIR$/forkjoin.iml" />
<module fileurl="file://$PROJECT_DIR$/interactive.iml" filepath="$PROJECT_DIR$/interactive.iml" />
<module fileurl="file://$PROJECT_DIR$/library.iml" filepath="$PROJECT_DIR$/library.iml" />
diff --git a/test/disabled/continuations-neg/infer0.check b/test/disabled/continuations-neg/infer0.check
deleted file mode 100644
index 1dd072ef09..0000000000
--- a/test/disabled/continuations-neg/infer0.check
+++ /dev/null
@@ -1,4 +0,0 @@
-infer0.scala:11: error: cannot cps-transform expression 8: type arguments [Int(8),String,Int] do not conform to method shiftUnit's type parameter bounds [A,B,C >: B]
- test(8)
- ^
-one error found
diff --git a/test/disabled/continuations-neg/infer0.scala b/test/disabled/continuations-neg/infer0.scala
deleted file mode 100644
index 6d97d7504d..0000000000
--- a/test/disabled/continuations-neg/infer0.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def test(x: => Int @cpsParam[String,Int]) = 7
-
- def main(args: Array[String]) {
- test(8)
- }
-}
diff --git a/test/files/continuations-neg/function0.check b/test/files/continuations-neg/function0.check
deleted file mode 100644
index 0a66763a0f..0000000000
--- a/test/files/continuations-neg/function0.check
+++ /dev/null
@@ -1,6 +0,0 @@
-function0.scala:11: error: type mismatch;
- found : () => Int @scala.util.continuations.cpsParam[Int,Int]
- required: () => Int
- val g: () => Int = f
- ^
-one error found
diff --git a/test/files/continuations-neg/function0.scala b/test/files/continuations-neg/function0.scala
deleted file mode 100644
index 4112ee3835..0000000000
--- a/test/files/continuations-neg/function0.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Any = {
-
- val f = () => shift { k: (Int=>Int) => k(7) }
- val g: () => Int = f
-
- println(reset(g()))
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/function2.check b/test/files/continuations-neg/function2.check
deleted file mode 100644
index 4b1a6227bc..0000000000
--- a/test/files/continuations-neg/function2.check
+++ /dev/null
@@ -1,6 +0,0 @@
-function2.scala:11: error: type mismatch;
- found : () => Int
- required: () => Int @scala.util.continuations.cpsParam[Int,Int]
- val g: () => Int @cps[Int] = f
- ^
-one error found
diff --git a/test/files/continuations-neg/function2.scala b/test/files/continuations-neg/function2.scala
deleted file mode 100644
index ae0fda509d..0000000000
--- a/test/files/continuations-neg/function2.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Any = {
-
- val f = () => 7
- val g: () => Int @cps[Int] = f
-
- println(reset(g()))
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/function3.check b/test/files/continuations-neg/function3.check
deleted file mode 100644
index 4705ad9ed9..0000000000
--- a/test/files/continuations-neg/function3.check
+++ /dev/null
@@ -1,6 +0,0 @@
-function3.scala:10: error: type mismatch;
- found : Int @scala.util.continuations.cpsParam[Int,Int]
- required: Int
- val g: () => Int = () => shift { k: (Int=>Int) => k(7) }
- ^
-one error found
diff --git a/test/files/continuations-neg/function3.scala b/test/files/continuations-neg/function3.scala
deleted file mode 100644
index 0c3f1667e5..0000000000
--- a/test/files/continuations-neg/function3.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Any = {
-
- val g: () => Int = () => shift { k: (Int=>Int) => k(7) }
-
- println(reset(g()))
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/infer2.check b/test/files/continuations-neg/infer2.check
deleted file mode 100644
index d92bc9c572..0000000000
--- a/test/files/continuations-neg/infer2.check
+++ /dev/null
@@ -1,4 +0,0 @@
-infer2.scala:14: error: illegal answer type modification: scala.util.continuations.cpsParam[String,Int] andThen scala.util.continuations.cpsParam[String,Int]
- test { sym(); sym() }
- ^
-one error found
diff --git a/test/files/continuations-neg/infer2.scala b/test/files/continuations-neg/infer2.scala
deleted file mode 100644
index a890ac1fc4..0000000000
--- a/test/files/continuations-neg/infer2.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x: => Int @cpsParam[String,Int]) = 7
-
- def sym() = shift { k: (Int => String) => 9 }
-
-
- def main(args: Array[String]): Any = {
- test { sym(); sym() }
- }
-
-}
-
-
diff --git a/test/files/continuations-neg/lazy.check b/test/files/continuations-neg/lazy.check
deleted file mode 100644
index 3c460546be..0000000000
--- a/test/files/continuations-neg/lazy.check
+++ /dev/null
@@ -1,4 +0,0 @@
-lazy.scala:6: error: implementation restriction: cps annotations not allowed on lazy value definitions
- lazy val x = shift((k:Unit=>Unit)=>k())
- ^
-one error found
diff --git a/test/files/continuations-neg/lazy.scala b/test/files/continuations-neg/lazy.scala
deleted file mode 100644
index 3c8169dd46..0000000000
--- a/test/files/continuations-neg/lazy.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-import scala.util.continuations._
-
-object Test {
-
- def foo() = {
- lazy val x = shift((k:Unit=>Unit)=>k())
- println(x)
- }
-
- def main(args: Array[String]) {
- reset {
- foo()
- }
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/t1929.check b/test/files/continuations-neg/t1929.check
deleted file mode 100644
index b04a5b977d..0000000000
--- a/test/files/continuations-neg/t1929.check
+++ /dev/null
@@ -1,6 +0,0 @@
-t1929.scala:8: error: type mismatch;
- found : Int @scala.util.continuations.cpsParam[String,String] @scala.util.continuations.cpsSynth
- required: Int @scala.util.continuations.cpsParam[Int,String]
- reset {
- ^
-one error found
diff --git a/test/files/continuations-neg/t1929.scala b/test/files/continuations-neg/t1929.scala
deleted file mode 100644
index 02eda9170d..0000000000
--- a/test/files/continuations-neg/t1929.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def main(args : Array[String]) {
- reset {
- println("up")
- val x = shift((k:Int=>String) => k(8) + k(2))
- println("down " + x)
- val y = shift((k:Int=>String) => k(3))
- println("down2 " + y)
- y + x
- }
- }
-} \ No newline at end of file
diff --git a/test/files/continuations-neg/t2285.check b/test/files/continuations-neg/t2285.check
deleted file mode 100644
index d5dff6a4f2..0000000000
--- a/test/files/continuations-neg/t2285.check
+++ /dev/null
@@ -1,6 +0,0 @@
-t2285.scala:9: error: type mismatch;
- found : Int @scala.util.continuations.cpsParam[String,String] @scala.util.continuations.cpsSynth
- required: Int @scala.util.continuations.cpsParam[Int,String]
- def foo() = reset { bar(); 7 }
- ^
-one error found
diff --git a/test/files/continuations-neg/t2285.scala b/test/files/continuations-neg/t2285.scala
deleted file mode 100644
index f3c7f4c89c..0000000000
--- a/test/files/continuations-neg/t2285.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def bar() = shift { k: (String => String) => k("1") }
-
- def foo() = reset { bar(); 7 }
-
-}
diff --git a/test/files/continuations-neg/t2949.check b/test/files/continuations-neg/t2949.check
deleted file mode 100644
index dd9768807c..0000000000
--- a/test/files/continuations-neg/t2949.check
+++ /dev/null
@@ -1,6 +0,0 @@
-t2949.scala:13: error: type mismatch;
- found : Int
- required: ? @scala.util.continuations.cpsParam[List[?],Any]
- x * y
- ^
-one error found
diff --git a/test/files/continuations-neg/t2949.scala b/test/files/continuations-neg/t2949.scala
deleted file mode 100644
index ce27c7c0e8..0000000000
--- a/test/files/continuations-neg/t2949.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def reflect[A,B](xs : List[A]) = shift{ xs.flatMap[B, List[B]] }
- def reify[A, B](x : A @cpsParam[List[A], B]) = reset{ List(x) }
-
- def main(args: Array[String]): Unit = println(reify {
- val x = reflect[Int, Int](List(1,2,3))
- val y = reflect[Int, Int](List(2,4,8))
- x * y
- })
-}
diff --git a/test/files/continuations-neg/t3628.check b/test/files/continuations-neg/t3628.check
deleted file mode 100644
index 6e390558ef..0000000000
--- a/test/files/continuations-neg/t3628.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t3628.scala:4: error: not found: type Actor
- val impl: Actor = actor {
- ^
-one error found
diff --git a/test/files/continuations-neg/t3628.scala b/test/files/continuations-neg/t3628.scala
deleted file mode 100644
index c56e7752c4..0000000000
--- a/test/files/continuations-neg/t3628.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-import scala.actors.Actor._
-
-object Test {
- val impl: Actor = actor {
- loop {
- react {
- case 1 => impl ! 2
- }
- }
- }
-}
diff --git a/test/files/continuations-neg/t3718.check b/test/files/continuations-neg/t3718.check
deleted file mode 100644
index 659104c1c6..0000000000
--- a/test/files/continuations-neg/t3718.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t3718.scala:2: error: cannot cps-transform malformed (possibly in shift/reset placement) expression
- scala.util.continuations.reset((_: Any).##)
- ^
-one error found
diff --git a/test/files/continuations-neg/t3718.scala b/test/files/continuations-neg/t3718.scala
deleted file mode 100644
index a0fcb9d869..0000000000
--- a/test/files/continuations-neg/t3718.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test {
- scala.util.continuations.reset((_: Any).##)
-}
diff --git a/test/files/continuations-neg/t5314-missing-result-type.check b/test/files/continuations-neg/t5314-missing-result-type.check
deleted file mode 100644
index 341e580cf3..0000000000
--- a/test/files/continuations-neg/t5314-missing-result-type.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t5314-missing-result-type.scala:6: error: method bar has return statement; needs result type
- def bar(x:Int) = return foo(x)
- ^
-one error found
diff --git a/test/files/continuations-neg/t5314-missing-result-type.scala b/test/files/continuations-neg/t5314-missing-result-type.scala
deleted file mode 100644
index d7c5043a86..0000000000
--- a/test/files/continuations-neg/t5314-missing-result-type.scala
+++ /dev/null
@@ -1,13 +0,0 @@
-import scala.util.continuations._
-
-object Test extends App {
- def foo(x:Int): Int @cps[Int] = x
-
- def bar(x:Int) = return foo(x)
-
- reset {
- val res = bar(8)
- println(res)
- res
- }
-}
diff --git a/test/files/continuations-neg/t5314-npe.check b/test/files/continuations-neg/t5314-npe.check
deleted file mode 100644
index b5f024aa89..0000000000
--- a/test/files/continuations-neg/t5314-npe.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t5314-npe.scala:2: error: method bar has return statement; needs result type
- def bar(x:Int) = { return x; x } // NPE
- ^
-one error found
diff --git a/test/files/continuations-neg/t5314-npe.scala b/test/files/continuations-neg/t5314-npe.scala
deleted file mode 100644
index 2b5966e07c..0000000000
--- a/test/files/continuations-neg/t5314-npe.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test extends App {
- def bar(x:Int) = { return x; x } // NPE
-}
diff --git a/test/files/continuations-neg/t5314-return-reset.check b/test/files/continuations-neg/t5314-return-reset.check
deleted file mode 100644
index 4c817ae14d..0000000000
--- a/test/files/continuations-neg/t5314-return-reset.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t5314-return-reset.scala:14: error: return expression not allowed, since method calls CPS method
- if (rnd.nextInt(100) > 50) return 5 // not allowed, since method is calling `reset`
- ^
-one error found
diff --git a/test/files/continuations-neg/t5314-return-reset.scala b/test/files/continuations-neg/t5314-return-reset.scala
deleted file mode 100644
index df9d58e4cb..0000000000
--- a/test/files/continuations-neg/t5314-return-reset.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-import scala.util.continuations._
-import scala.util.Random
-
-object Test extends App {
- val rnd = new Random
-
- def foo(x: Int): Int @cps[Int] = shift { k => k(x) }
-
- def bar(x: Int): Int @cps[Int] = return foo(x)
-
- def caller(): Int = {
- val v: Int = reset {
- val res: Int = bar(8)
- if (rnd.nextInt(100) > 50) return 5 // not allowed, since method is calling `reset`
- 42
- }
- v
- }
-
- caller()
-}
diff --git a/test/files/continuations-neg/t5314-type-error.check b/test/files/continuations-neg/t5314-type-error.check
deleted file mode 100644
index e66c9d833f..0000000000
--- a/test/files/continuations-neg/t5314-type-error.check
+++ /dev/null
@@ -1,6 +0,0 @@
-t5314-type-error.scala:7: error: type mismatch;
- found : Int @scala.util.continuations.cpsParam[Int,Int]
- required: Int @scala.util.continuations.cpsParam[String,String]
- def bar(x:Int): Int @cps[String] = return foo(x)
- ^
-one error found
diff --git a/test/files/continuations-neg/t5314-type-error.scala b/test/files/continuations-neg/t5314-type-error.scala
deleted file mode 100644
index e36ce6c203..0000000000
--- a/test/files/continuations-neg/t5314-type-error.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-import scala.util.continuations._
-
-object Test extends App {
- def foo(x:Int): Int @cps[Int] = shift { k => k(x) }
-
- // should be a type error
- def bar(x:Int): Int @cps[String] = return foo(x)
-
- def caller(): Unit = {
- val v: String = reset {
- val res: Int = bar(8)
- "hello"
- }
- }
-
- caller()
-}
diff --git a/test/files/continuations-neg/t5445.check b/test/files/continuations-neg/t5445.check
deleted file mode 100644
index eb2943b6a6..0000000000
--- a/test/files/continuations-neg/t5445.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t5445.scala:4: error: cps annotations not allowed on by-value parameters or value definitions
- def foo(block: Unit @suspendable ): Unit @suspendable = {}
- ^
-one error found
diff --git a/test/files/continuations-neg/t5445.scala b/test/files/continuations-neg/t5445.scala
deleted file mode 100644
index cb6f8f686d..0000000000
--- a/test/files/continuations-neg/t5445.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def foo(block: Unit @suspendable ): Unit @suspendable = {}
-}
diff --git a/test/files/continuations-neg/trycatch2.check b/test/files/continuations-neg/trycatch2.check
deleted file mode 100644
index 5ff2838bad..0000000000
--- a/test/files/continuations-neg/trycatch2.check
+++ /dev/null
@@ -1,7 +0,0 @@
-trycatch2.scala:11: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int])
- def foo1 = try {
- ^
-trycatch2.scala:19: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int])
- def foo2 = try {
- ^
-two errors found
diff --git a/test/files/continuations-neg/trycatch2.scala b/test/files/continuations-neg/trycatch2.scala
deleted file mode 100644
index ee0a180ed6..0000000000
--- a/test/files/continuations-neg/trycatch2.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def fatal[T]: T = throw new Exception
- def cpsIntStringInt = shift { k:(Int=>String) => k(3); 7 }
- def cpsIntIntString = shift { k:(Int=>Int) => k(3); "7" }
-
- def foo1 = try {
- fatal[Int]
- cpsIntStringInt
- } catch {
- case ex: Throwable =>
- cpsIntStringInt
- }
-
- def foo2 = try {
- fatal[Int]
- cpsIntStringInt
- } catch {
- case ex: Throwable =>
- cpsIntStringInt
- }
-
-
- def main(args: Array[String]): Unit = {
- println(reset { foo1; "3" })
- println(reset { foo2; "3" })
- }
-
-}
diff --git a/test/files/continuations-run/basics.check b/test/files/continuations-run/basics.check
deleted file mode 100755
index 54c059fdcb..0000000000
--- a/test/files/continuations-run/basics.check
+++ /dev/null
@@ -1,2 +0,0 @@
-28
-28 \ No newline at end of file
diff --git a/test/files/continuations-run/basics.scala b/test/files/continuations-run/basics.scala
deleted file mode 100755
index 07b3de5194..0000000000
--- a/test/files/continuations-run/basics.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def m0() = {
- shift((k:Int => Int) => k(k(7))) * 2
- }
-
- def m1() = {
- 2 * shift((k:Int => Int) => k(k(7)))
- }
-
- def main(args: Array[String]) {
-
- println(reset(m0()))
- println(reset(m1()))
-
- }
-
-}
diff --git a/test/files/continuations-run/function1.check b/test/files/continuations-run/function1.check
deleted file mode 100644
index 7f8f011eb7..0000000000
--- a/test/files/continuations-run/function1.check
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/test/files/continuations-run/function1.scala b/test/files/continuations-run/function1.scala
deleted file mode 100644
index 82dfe46c08..0000000000
--- a/test/files/continuations-run/function1.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Unit = {
-
- val f = () => shift { k: (Int=>Int) => k(7) }
- val g: () => Int @cps[Int] = f
-
- println(reset(g()))
- }
-
-}
diff --git a/test/files/continuations-run/function4.check b/test/files/continuations-run/function4.check
deleted file mode 100644
index c7930257df..0000000000
--- a/test/files/continuations-run/function4.check
+++ /dev/null
@@ -1 +0,0 @@
-7 \ No newline at end of file
diff --git a/test/files/continuations-run/function4.scala b/test/files/continuations-run/function4.scala
deleted file mode 100644
index ccb432fe93..0000000000
--- a/test/files/continuations-run/function4.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Unit = {
-
- val g: () => Int @cps[Int] = () => shift { k: (Int=>Int) => k(7) }
-
- println(reset(g()))
- }
-
-}
diff --git a/test/files/continuations-run/function5.check b/test/files/continuations-run/function5.check
deleted file mode 100644
index c7930257df..0000000000
--- a/test/files/continuations-run/function5.check
+++ /dev/null
@@ -1 +0,0 @@
-7 \ No newline at end of file
diff --git a/test/files/continuations-run/function5.scala b/test/files/continuations-run/function5.scala
deleted file mode 100644
index a83eb80d08..0000000000
--- a/test/files/continuations-run/function5.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Unit = {
-
- val g: () => Int @cps[Int] = () => 7
-
- println(reset(g()))
- }
-
-}
diff --git a/test/files/continuations-run/function6.check b/test/files/continuations-run/function6.check
deleted file mode 100644
index c7930257df..0000000000
--- a/test/files/continuations-run/function6.check
+++ /dev/null
@@ -1 +0,0 @@
-7 \ No newline at end of file
diff --git a/test/files/continuations-run/function6.scala b/test/files/continuations-run/function6.scala
deleted file mode 100644
index 13ef88bd9f..0000000000
--- a/test/files/continuations-run/function6.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def main(args: Array[String]): Unit = {
-
- val g: PartialFunction[Int, Int @cps[Int]] = { case x => 7 }
-
- println(reset(g(2)))
-
- }
-
-}
diff --git a/test/files/continuations-run/ifelse0.check b/test/files/continuations-run/ifelse0.check
deleted file mode 100644
index f8bc79860d..0000000000
--- a/test/files/continuations-run/ifelse0.check
+++ /dev/null
@@ -1,2 +0,0 @@
-10
-9 \ No newline at end of file
diff --git a/test/files/continuations-run/ifelse0.scala b/test/files/continuations-run/ifelse0.scala
deleted file mode 100644
index cbff72c77c..0000000000
--- a/test/files/continuations-run/ifelse0.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x:Int) = if (x <= 7)
- shift { k: (Int=>Int) => k(k(k(x))) }
- else
- shift { k: (Int=>Int) => k(x) }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test(7)))
- println(reset(1 + test(8)))
- }
-
-}
diff --git a/test/files/continuations-run/ifelse1.check b/test/files/continuations-run/ifelse1.check
deleted file mode 100644
index 86a3fbc0c1..0000000000
--- a/test/files/continuations-run/ifelse1.check
+++ /dev/null
@@ -1,4 +0,0 @@
-10
-9
-8
-11 \ No newline at end of file
diff --git a/test/files/continuations-run/ifelse1.scala b/test/files/continuations-run/ifelse1.scala
deleted file mode 100644
index f8e3cf2ca3..0000000000
--- a/test/files/continuations-run/ifelse1.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test1(x:Int) = if (x <= 7)
- shift { k: (Int=>Int) => k(k(k(x))) }
- else
- x
-
- def test2(x:Int) = if (x <= 7)
- x
- else
- shift { k: (Int=>Int) => k(k(k(x))) }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test1(7)))
- println(reset(1 + test1(8)))
- println(reset(1 + test2(7)))
- println(reset(1 + test2(8)))
- }
-
-}
diff --git a/test/files/continuations-run/ifelse2.check b/test/files/continuations-run/ifelse2.check
deleted file mode 100644
index f97a95b08d..0000000000
--- a/test/files/continuations-run/ifelse2.check
+++ /dev/null
@@ -1,4 +0,0 @@
-abort
-()
-alive
-()
diff --git a/test/files/continuations-run/ifelse2.scala b/test/files/continuations-run/ifelse2.scala
deleted file mode 100644
index f5ec864a06..0000000000
--- a/test/files/continuations-run/ifelse2.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x:Int) = if (x <= 7)
- shift { k: (Unit=>Unit) => println("abort") }
-
- def main(args: Array[String]): Unit = {
- println(reset{ test(7); println("alive") })
- println(reset{ test(8); println("alive") })
- }
-
-}
diff --git a/test/files/continuations-run/ifelse3.check b/test/files/continuations-run/ifelse3.check
deleted file mode 100644
index 95b562c8e6..0000000000
--- a/test/files/continuations-run/ifelse3.check
+++ /dev/null
@@ -1,2 +0,0 @@
-6
-9
diff --git a/test/files/continuations-run/ifelse3.scala b/test/files/continuations-run/ifelse3.scala
deleted file mode 100644
index 2c5b5765db..0000000000
--- a/test/files/continuations-run/ifelse3.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def util(x: Boolean) = shift { k: (Boolean=>Int) => k(x) }
-
- def test(x:Int) = if (util(x <= 7))
- x - 1
- else
- x + 1
-
-
- def main(args: Array[String]): Unit = {
- println(reset(test(7)))
- println(reset(test(8)))
- }
-
-}
diff --git a/test/files/continuations-run/ifelse4.check b/test/files/continuations-run/ifelse4.check
deleted file mode 100644
index 2545dd49a0..0000000000
--- a/test/files/continuations-run/ifelse4.check
+++ /dev/null
@@ -1,4 +0,0 @@
-10
-10
-10
-10
diff --git a/test/files/continuations-run/ifelse4.scala b/test/files/continuations-run/ifelse4.scala
deleted file mode 100644
index 46ec15365e..0000000000
--- a/test/files/continuations-run/ifelse4.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def sh(x1:Int) = shift( (k: Int => Int) => k(k(k(x1))))
-
- def testA(x1: Int): Int @cps[Int] = {
- sh(x1)
- if (x1==42) x1 else sh(x1)
- }
-
- def testB(x1: Int): Int @cps[Int] = {
- if (sh(x1)==43) x1 else x1
- }
-
- def testC(x1: Int): Int @cps[Int] = {
- sh(x1)
- if (sh(x1)==44) x1 else x1
- }
-
- def testD(x1: Int): Int @cps[Int] = {
- sh(x1)
- if (sh(x1)==45) x1 else sh(x1)
- }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + testA(7)))
- println(reset(1 + testB(9)))
- println(reset(1 + testC(9)))
- println(reset(1 + testD(7)))
- }
-}
diff --git a/test/files/continuations-run/implicit-infer-annotations.check b/test/files/continuations-run/implicit-infer-annotations.check
deleted file mode 100644
index e8206c4319..0000000000
--- a/test/files/continuations-run/implicit-infer-annotations.check
+++ /dev/null
@@ -1,5 +0,0 @@
-Range(5, 6, 7, 8, 9, 10)
-Range(5, 6, 7, 8, 9, 10)
-15
-List(10, 1, 2, 3)
-Range(5, 6, 7, 8, 9, 10)
diff --git a/test/files/continuations-run/implicit-infer-annotations.scala b/test/files/continuations-run/implicit-infer-annotations.scala
deleted file mode 100644
index 3f0e959f60..0000000000
--- a/test/files/continuations-run/implicit-infer-annotations.scala
+++ /dev/null
@@ -1,59 +0,0 @@
-import annotation._
-
-object A {
- class foo[-B,+C] extends StaticAnnotation with TypeConstraint
-
- def shift[A, B, C](fun: (A => B) => C): A @foo[B, C] = ???
- def reset[A, C](ctx: => (A @foo[A, C])): C = ???
-
- def m1 = reset { shift { f: (Int => Range) => f(5) }.to(10) }
-}
-
-object B {
- import scala.util.continuations._
-
- def m1 = reset { shift { f: (Int => Range) => f(5) }.to(10) }
- def m2 = reset { val a = shift { f: (Int => Range) => f(5) } ; a.to(10) }
-
- val x1 = reset{
- shift{ cont: (Int => Range) =>
- cont(5)
- }.to(10)
- }
-
- val x2 = reset{
- val a = shift{ cont: (Int => Range) =>
- cont(5)
- }
- a.to(10)
- } // x is now Range(5, 6, 7, 8, 9, 10)
-
- val x3 = reset{
- shift{ cont: (Int => Int) =>
- cont(5)
- } + 10
- } // x is now 15
-
- val x4 = reset{
- 10 :: shift{ cont: (List[Int] => List[Int]) =>
- cont(List(1, 2, 3))
- }
- } // x is List(10, 1, 2, 3)
-
- val x5 = reset{
- new scala.runtime.RichInt(shift{ cont: (Int => Range) =>
- cont(5)
- }) to 10
- }
-}
-
-object Test {
- def main(args: Array[String]): Unit = {
- import B._
- println(x1)
- println(x2)
- println(x3)
- println(x4)
- println(x5)
- }
-}
diff --git a/test/files/continuations-run/infer1.scala b/test/files/continuations-run/infer1.scala
deleted file mode 100644
index 76f746da57..0000000000
--- a/test/files/continuations-run/infer1.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x: => Int @cpsParam[String,Int]) = 7
-
- def test2() = {
- val x = shift { k: (Int => String) => 9 }
- x
- }
-
- def test3(x: => Int @cpsParam[Int,Int]) = 7
-
-
- def util() = shift { k: (String => String) => "7" }
-
- def main(args: Array[String]): Unit = {
- test { shift { k: (Int => String) => 9 } }
- test { shift { k: (Int => String) => 9 }; 2 }
-// test { shift { k: (Int => String) => 9 }; util() } <-- doesn't work
- test { shift { k: (Int => String) => 9 }; util(); 2 }
-
-
- test { shift { k: (Int => String) => 9 }; { test3(0); 2 } }
-
- test3 { { test3(0); 2 } }
-
- }
-
-}
diff --git a/test/files/continuations-run/match0.check b/test/files/continuations-run/match0.check
deleted file mode 100644
index f8bc79860d..0000000000
--- a/test/files/continuations-run/match0.check
+++ /dev/null
@@ -1,2 +0,0 @@
-10
-9 \ No newline at end of file
diff --git a/test/files/continuations-run/match0.scala b/test/files/continuations-run/match0.scala
deleted file mode 100644
index 8769ed9fcb..0000000000
--- a/test/files/continuations-run/match0.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x:Int) = x match {
- case 7 => shift { k: (Int=>Int) => k(k(k(x))) }
- case 8 => shift { k: (Int=>Int) => k(x) }
- }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test(7)))
- println(reset(1 + test(8)))
- }
-
-}
diff --git a/test/files/continuations-run/match1.check b/test/files/continuations-run/match1.check
deleted file mode 100644
index 73053d3f4f..0000000000
--- a/test/files/continuations-run/match1.check
+++ /dev/null
@@ -1,2 +0,0 @@
-10
-9
diff --git a/test/files/continuations-run/match1.scala b/test/files/continuations-run/match1.scala
deleted file mode 100644
index b89fb706b0..0000000000
--- a/test/files/continuations-run/match1.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test(x:Int) = x match {
- case 7 => shift { k: (Int=>Int) => k(k(k(x))) }
- case _ => x
- }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test(7)))
- println(reset(1 + test(8)))
- }
-
-}
diff --git a/test/files/continuations-run/match2.check b/test/files/continuations-run/match2.check
deleted file mode 100644
index cbf91349cc..0000000000
--- a/test/files/continuations-run/match2.check
+++ /dev/null
@@ -1,2 +0,0 @@
-B
-B
diff --git a/test/files/continuations-run/match2.scala b/test/files/continuations-run/match2.scala
deleted file mode 100644
index 002d9b52dd..0000000000
--- a/test/files/continuations-run/match2.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def test1() = {
- val (a, b) = shift { k: (((String,String)) => String) => k("A","B") }
- b
- }
-
- case class Elem[T,U](a: T, b: U)
-
- def test2() = {
- val Elem(a,b) = shift { k: (Elem[String,String] => String) => k(Elem("A","B")) }
- b
- }
-
-
- def main(args: Array[String]): Unit = {
- println(reset(test1()))
- println(reset(test2()))
- }
-
-} \ No newline at end of file
diff --git a/test/files/continuations-run/patvirt.check b/test/files/continuations-run/patvirt.check
deleted file mode 100644
index b5fa014ad3..0000000000
--- a/test/files/continuations-run/patvirt.check
+++ /dev/null
@@ -1,2 +0,0 @@
-10
-11
diff --git a/test/files/continuations-run/patvirt.scala b/test/files/continuations-run/patvirt.scala
deleted file mode 100644
index cfbdda538d..0000000000
--- a/test/files/continuations-run/patvirt.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def sh(x1:Int) = shift( (k: Int => Int) => k(k(k(x1))))
-
- def test(x1: Int) = {
- val o7 = {
- val o6 = {
- val o3 =
- if (7 == x1) Some(x1)
- else None
-
- if (o3.isEmpty) None
- else Some(sh(x1))
- }
- if (o6.isEmpty) {
- val o5 =
- if (8 == x1) Some(x1)
- else None
-
- if (o5.isEmpty) None
- else Some(sh(x1))
- } else o6
- }
- o7.get
- }
-
- def main(args: Array[String]): Unit = {
- println(reset(1 + test(7)))
- println(reset(1 + test(8)))
- }
-}
diff --git a/test/files/continuations-run/shift-pct.check b/test/files/continuations-run/shift-pct.check
deleted file mode 100644
index fb190e770a..0000000000
--- a/test/files/continuations-run/shift-pct.check
+++ /dev/null
@@ -1,25 +0,0 @@
-d = 1, d2 = 1.0, pct = 1.000
-d = 2, d2 = 4.0, pct = 0.500
-d = 3, d2 = 9.0, pct = 0.333
-d = 4, d2 = 16.0, pct = 0.250
-d = 5, d2 = 25.0, pct = 0.200
-d = 6, d2 = 36.0, pct = 0.167
-d = 7, d2 = 49.0, pct = 0.143
-d = 8, d2 = 64.0, pct = 0.125
-d = 9, d2 = 81.0, pct = 0.111
-d = 10, d2 = 100.0, pct = 0.100
-d = 11, d2 = 121.0, pct = 0.091
-d = 12, d2 = 144.0, pct = 0.083
-d = 13, d2 = 169.0, pct = 0.077
-d = 14, d2 = 196.0, pct = 0.071
-d = 15, d2 = 225.0, pct = 0.067
-d = 16, d2 = 256.0, pct = 0.063
-d = 17, d2 = 289.0, pct = 0.059
-d = 18, d2 = 324.0, pct = 0.056
-d = 19, d2 = 361.0, pct = 0.053
-d = 20, d2 = 400.0, pct = 0.050
-d = 21, d2 = 441.0, pct = 0.048
-d = 22, d2 = 484.0, pct = 0.045
-d = 23, d2 = 529.0, pct = 0.043
-d = 24, d2 = 576.0, pct = 0.042
-d = 25, d2 = 625.0, pct = 0.040
diff --git a/test/files/continuations-run/shift-pct.scala b/test/files/continuations-run/shift-pct.scala
deleted file mode 100644
index 7ef9922168..0000000000
--- a/test/files/continuations-run/shift-pct.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- abstract class IfReturnRepro {
- def s1: Double @cpsParam[Any, Unit]
- def s2: Double @cpsParam[Any, Unit]
-
- def p(i: Int): Double @cpsParam[Unit, Any] = {
- val px = s1
- val pct = if (px > 100) px else px / s2
- println("pct = %.3f".format(pct))
- pct
- }
- }
-
- def main(args: Array[String]) : Unit = {
- var d: Double = 0d
- def d2 = d * d
-
- val irr = new IfReturnRepro {
- def s1 = shift(f => f(d))
- def s2 = shift(f => f(d2))
- }
- 1 to 25 foreach { i =>
- d = i
- print("d = " + i + ", d2 = " + d2 + ", ")
- run(irr p i)
- }
- }
-}
diff --git a/test/files/continuations-run/t1807.check b/test/files/continuations-run/t1807.check
deleted file mode 100644
index 56a6051ca2..0000000000
--- a/test/files/continuations-run/t1807.check
+++ /dev/null
@@ -1 +0,0 @@
-1 \ No newline at end of file
diff --git a/test/files/continuations-run/t1807.scala b/test/files/continuations-run/t1807.scala
deleted file mode 100644
index 278b3a9936..0000000000
--- a/test/files/continuations-run/t1807.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def main(args: Array[String]): Unit = {
- val z = reset {
- val f: (() => Int @cps[Int]) = () => 1
- f()
- }
- println(z)
- }
-} \ No newline at end of file
diff --git a/test/files/continuations-run/t1808.scala b/test/files/continuations-run/t1808.scala
deleted file mode 100644
index 125c7c1cdf..0000000000
--- a/test/files/continuations-run/t1808.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def main(args: Array[String]): Unit = {
- reset0 { 0 }
- }
-} \ No newline at end of file
diff --git a/test/files/continuations-run/t1820.scala b/test/files/continuations-run/t1820.scala
deleted file mode 100644
index 7de6ccabef..0000000000
--- a/test/files/continuations-run/t1820.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def shifted: Unit @suspendable = shift { (k: Unit => Unit) => () }
- def test1(b: => Boolean) = {
- reset {
- if (b) shifted
- }
- }
- def main(args: Array[String]): Unit = test1(true)
-}
diff --git a/test/files/continuations-run/t1821.check b/test/files/continuations-run/t1821.check
deleted file mode 100644
index f7b76115db..0000000000
--- a/test/files/continuations-run/t1821.check
+++ /dev/null
@@ -1,4 +0,0 @@
-()
-()
-()
-() \ No newline at end of file
diff --git a/test/files/continuations-run/t1821.scala b/test/files/continuations-run/t1821.scala
deleted file mode 100644
index 55bf7b6f12..0000000000
--- a/test/files/continuations-run/t1821.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
- def suspended[A](x: A): A @suspendable = x
- def test1[A](x: A): A @suspendable = suspended(x) match { case x => x }
- def test2[A](x: List[A]): A @suspendable = suspended(x) match { case List(x) => x }
-
- def test3[A](x: A): A @suspendable = x match { case x => x }
- def test4[A](x: List[A]): A @suspendable = x match { case List(x) => x }
-
- def main(args: Array[String]) {
- println(reset(test1()))
- println(reset(test2(List(()))))
- println(reset(test3()))
- println(reset(test4(List(()))))
- }
-}
diff --git a/test/files/continuations-run/t2864.check b/test/files/continuations-run/t2864.check
deleted file mode 100644
index d411bb7c1a..0000000000
--- a/test/files/continuations-run/t2864.check
+++ /dev/null
@@ -1 +0,0 @@
-400
diff --git a/test/files/continuations-run/t2864.scala b/test/files/continuations-run/t2864.scala
deleted file mode 100644
index 7a2579e45c..0000000000
--- a/test/files/continuations-run/t2864.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-import scala.util.continuations._
-object Test {
-
- def double[B](n : Int)(k : Int => B) : B = k(n * 2)
-
- def main(args : Array[String]) {
- reset {
- val result1 = shift(double[Unit](100))
- val result2 = shift(double[Unit](result1))
- println(result2)
- }
- }
-
- def foo: Int @cps[Int] = {
- val a0 = shift((k:Int=>Int) => k(0))
- val x0 = 2
- val a1 = shift((k:Int=>Int) => x0)
- 0
- }
-
-/*
- def bar: ControlContext[Int,Int,Int] = {
- shiftR((k:Int=>Int) => k(0)).flatMap { a0 =>
- val x0 = 2
- shiftR((k:Int=>Int) => x0).map { a1 =>
- 0
- }}
- }
-*/
-} \ No newline at end of file
diff --git a/test/files/continuations-run/t2934.check b/test/files/continuations-run/t2934.check
deleted file mode 100644
index a92586538e..0000000000
--- a/test/files/continuations-run/t2934.check
+++ /dev/null
@@ -1 +0,0 @@
-List(3, 4, 5)
diff --git a/test/files/continuations-run/t2934.scala b/test/files/continuations-run/t2934.scala
deleted file mode 100644
index a1b8ca9e04..0000000000
--- a/test/files/continuations-run/t2934.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def main(args : Array[String]) {
- println(reset {
- val x = shift(List(1,2,3).flatMap[Int, List[Int]])
- List(x + 2)
- })
- }
-}
diff --git a/test/files/continuations-run/t3199.check b/test/files/continuations-run/t3199.check
deleted file mode 100644
index a065247b8c..0000000000
--- a/test/files/continuations-run/t3199.check
+++ /dev/null
@@ -1 +0,0 @@
-Right(7)
diff --git a/test/files/continuations-run/t3199.scala b/test/files/continuations-run/t3199.scala
deleted file mode 100644
index 2cb73c005a..0000000000
--- a/test/files/continuations-run/t3199.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-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/t3223.check b/test/files/continuations-run/t3223.check
deleted file mode 100644
index ec635144f6..0000000000
--- a/test/files/continuations-run/t3223.check
+++ /dev/null
@@ -1 +0,0 @@
-9
diff --git a/test/files/continuations-run/t3223.scala b/test/files/continuations-run/t3223.scala
deleted file mode 100644
index 75613fe5c7..0000000000
--- a/test/files/continuations-run/t3223.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-import scala.util.continuations._
-object Test {
-
- def foo(x:Int) = {
- try {
- throw new Exception
- shiftUnit0[Int,Int](7)
- } catch {
- case ex: Throwable =>
- val g = (a:Int)=>a
- 9
- }
- }
-
- def main(args: Array[String]) {
- println(reset(foo(0)))
- }
-
-}
diff --git a/test/files/continuations-run/t3225.check b/test/files/continuations-run/t3225.check
deleted file mode 100644
index df1a8a9ce4..0000000000
--- a/test/files/continuations-run/t3225.check
+++ /dev/null
@@ -1,12 +0,0 @@
-8
-8
-9
-9
-8
-9
-8
-8
-9
-9
-8
-9
diff --git a/test/files/continuations-run/t3225.scala b/test/files/continuations-run/t3225.scala
deleted file mode 100644
index a0c9c91985..0000000000
--- a/test/files/continuations-run/t3225.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- class Bla {
- val x = 8
- def y[T] = 9
- }
-
-/*
- def bla[A] = shift { k:(Bla=>A) => k(new Bla) }
-*/
-
- def bla1 = shift { k:(Bla=>Bla) => k(new Bla) }
- def bla2 = shift { k:(Bla=>Int) => k(new Bla) }
-
- def fooA = bla2.x
- def fooB[T] = bla2.y[T]
-
- def testMono() = {
- println(reset(bla1).x)
- println(reset(bla2.x))
- println(reset(bla2.y[Int]))
- println(reset(bla2.y))
- println(reset(fooA))
- println(reset(fooB))
- 0
- }
-
- def blaX[A] = shift { k:(Bla=>A) => k(new Bla) }
-
- def fooX[A] = blaX[A].x
- def fooY[A] = blaX[A].y[A]
-
- def testPoly() = {
- println(reset(blaX[Bla]).x)
- println(reset(blaX[Int].x))
- println(reset(blaX[Int].y[Int]))
- println(reset(blaX[Int].y))
- println(reset(fooX[Int]))
- println(reset(fooY[Int]))
- 0
- }
-
-
- // TODO: check whether this also applies to a::shift { k => ... }
-
- def main(args: Array[String]) {
- testMono()
- testPoly()
- }
-
-}
diff --git a/test/files/continuations-run/t3501.check b/test/files/continuations-run/t3501.check
deleted file mode 100644
index 08adcfe27a..0000000000
--- a/test/files/continuations-run/t3501.check
+++ /dev/null
@@ -1,5 +0,0 @@
-42
-42
-42
-42
-42
diff --git a/test/files/continuations-run/t3501.scala b/test/files/continuations-run/t3501.scala
deleted file mode 100644
index c43b3322be..0000000000
--- a/test/files/continuations-run/t3501.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-import scala.util.continuations._
-
-object Test {
- def capture(): Int @suspendable = 42
-
- def main(args: Array[String]): Unit = reset {
- var i = 0
- while (i < 5) {
- i += 1
- val y = capture()
- val s = y
- println(s)
- }
- }
-}
diff --git a/test/files/continuations-run/t5314-2.check b/test/files/continuations-run/t5314-2.check
deleted file mode 100644
index 35b3c93780..0000000000
--- a/test/files/continuations-run/t5314-2.check
+++ /dev/null
@@ -1,5 +0,0 @@
-8
-hi
-8
-from try
-8
diff --git a/test/files/continuations-run/t5314-2.scala b/test/files/continuations-run/t5314-2.scala
deleted file mode 100644
index e7e5d46f03..0000000000
--- a/test/files/continuations-run/t5314-2.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-import scala.util.continuations._
-
-class ReturnRepro {
- def s1: Int @cps[Any] = shift { k => k(5) }
- def caller = reset { println(p(3)) }
- def caller2 = reset { println(p2(3)) }
- def caller3 = reset { println(p3(3)) }
-
- def p(i: Int): Int @cps[Any] = {
- val v= s1 + 3
- return v
- }
-
- def p2(i: Int): Int @cps[Any] = {
- val v = s1 + 3
- if (v > 0) {
- println("hi")
- return v
- } else {
- println("hi")
- return 8
- }
- }
-
- def p3(i: Int): Int @cps[Any] = {
- val v = s1 + 3
- try {
- println("from try")
- return v
- } catch {
- case e: Exception =>
- println("from catch")
- return 7
- }
- }
-
-}
-
-object Test extends App {
- val repro = new ReturnRepro
- repro.caller
- repro.caller2
- repro.caller3
-}
diff --git a/test/files/continuations-run/t5314-3.check b/test/files/continuations-run/t5314-3.check
deleted file mode 100644
index 71489f097c..0000000000
--- a/test/files/continuations-run/t5314-3.check
+++ /dev/null
@@ -1,4 +0,0 @@
-enter return expr
-8
-hi
-8
diff --git a/test/files/continuations-run/t5314-3.scala b/test/files/continuations-run/t5314-3.scala
deleted file mode 100644
index c2fe8f6f87..0000000000
--- a/test/files/continuations-run/t5314-3.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-import scala.util.continuations._
-
-class ReturnRepro {
- def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) }
- def caller = reset { println(p(3)) }
- def caller2 = reset { println(p2(3)) }
-
- def p(i: Int): Int @cpsParam[Unit, Any] = {
- val v= s1 + 3
- return { println("enter return expr"); v }
- }
-
- def p2(i: Int): Int @cpsParam[Unit, Any] = {
- val v = s1 + 3
- if (v > 0) {
- return { println("hi"); v }
- } else {
- return { println("hi"); 8 }
- }
- }
-}
-
-object Test extends App {
- val repro = new ReturnRepro
- repro.caller
- repro.caller2
-}
diff --git a/test/files/continuations-run/t5314-with-if.check b/test/files/continuations-run/t5314-with-if.check
deleted file mode 100644
index 7f8f011eb7..0000000000
--- a/test/files/continuations-run/t5314-with-if.check
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/test/files/continuations-run/t5314-with-if.scala b/test/files/continuations-run/t5314-with-if.scala
deleted file mode 100644
index 5840199a3c..0000000000
--- a/test/files/continuations-run/t5314-with-if.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-import scala.util.continuations._
-
-object Test extends App {
-
- def foo(x:Int): Int @cps[Int] = 7
-
- def bar(x:Int): Int @cps[Int] = {
- val v = foo(x)
- if (v > 0)
- return v
- else
- return 10
- }
-
- println(reset { bar(10) })
-
-}
diff --git a/test/files/continuations-run/t5314.check b/test/files/continuations-run/t5314.check
deleted file mode 100644
index 61f5b25dc7..0000000000
--- a/test/files/continuations-run/t5314.check
+++ /dev/null
@@ -1,14 +0,0 @@
-t5314.scala:34: warning: expression 7 is cps-transformed unexpectedly
- def bar3(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else return foo2(x) }
- ^
-t5314.scala:35: warning: expression 7 is cps-transformed unexpectedly
- def bar4(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else foo2(x) }
- ^
-7
-7
-7
-8
-8
-hi
-8
-8
diff --git a/test/files/continuations-run/t5314.scala b/test/files/continuations-run/t5314.scala
deleted file mode 100644
index e448d8558d..0000000000
--- a/test/files/continuations-run/t5314.scala
+++ /dev/null
@@ -1,52 +0,0 @@
-import scala.util.continuations._
-
-class ReturnRepro {
- def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) }
- def caller = reset { println(p(3)) }
- def caller2 = reset { println(p2(3)) }
-
- def p(i: Int): Int @cpsParam[Unit, Any] = {
- val v= s1 + 3
- return v
- }
-
- def p2(i: Int): Int @cpsParam[Unit, Any] = {
- val v = s1 + 3
- if (v > 0) {
- println("hi")
- return v
- } else {
- println("hi")
- return 8
- }
- }
-}
-
-object Test extends App {
- def foo(x:Int): Int @cps[Int] = shift { k => k(x) }
-
- def bar(x:Int): Int @cps[Int] = return foo(x)
-
- def nocps(x: Int): Int = { return x; x }
-
- def foo2(x:Int): Int @cps[Int] = 7
- def bar2(x:Int): Int @cps[Int] = { foo2(x); return 7 }
- def bar3(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else return foo2(x) }
- def bar4(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else foo2(x) }
- def bar5(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else 8 }
- println(reset { bar2(10) })
- println(reset { bar3(10) })
- println(reset { bar4(10) })
- println(reset { bar5(10) })
-
- /* original test case */
- val repro = new ReturnRepro
- repro.caller
- repro.caller2
-
- reset {
- val res = bar(8)
- println(res)
- res
- }
-}
diff --git a/test/files/continuations-run/t5472.check b/test/files/continuations-run/t5472.check
deleted file mode 100644
index 2468b6b27d..0000000000
--- a/test/files/continuations-run/t5472.check
+++ /dev/null
@@ -1,25 +0,0 @@
-t5472.scala:12: warning: expression case4(){
- if (x1.ne(null))
- matchEnd3(true)
- else
- case5()
-} is cps-transformed unexpectedly
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- ^
-t5472.scala:12: warning: expression case5(){
- matchEnd3(false)
-} is cps-transformed unexpectedly
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- ^
-t5472.scala:12: warning: expression matchEnd3(x: Boolean){
- x
-} is cps-transformed unexpectedly
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- ^
-t5472.scala:12: warning: expression matchEnd3(x: Int){
- x
-} is cps-transformed unexpectedly
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- ^
-warning: there were 1 deprecation warning(s); re-run with -deprecation for details
-List(23, 23)
diff --git a/test/files/continuations-run/t5472.scala b/test/files/continuations-run/t5472.scala
deleted file mode 100644
index 060d267544..0000000000
--- a/test/files/continuations-run/t5472.scala
+++ /dev/null
@@ -1,91 +0,0 @@
-import scala.annotation._
-import scala.util.continuations._
-import java.util.concurrent.atomic._
-
-@deprecated("Suppress warnings", since="2.11")
-object Test {
- def main(args: Array[String]) {
- val map = Map("foo" -> 1, "bar" -> 2)
- reset {
- val mapped =
- for {
- (location, accessors) <- new ContinuationizedParallelIterable(map)
- } yield {
- shiftUnit0[Int, Unit](23)
- }
- println(mapped.toList)
- }
- }
-
-final class ContinuationizedParallelIterable[+A](protected val underline: Iterable[A]) {
- def toList = underline.toList.sortBy(_.toString)
-
- final def filter(p: A => Boolean @suspendable): ContinuationizedParallelIterable[A] @suspendable =
- shift(
- new AtomicInteger(1) with ((ContinuationizedParallelIterable[A] => Unit) => Unit) {
- private val results = new AtomicReference[List[A]](Nil)
-
- @tailrec
- private def add(element: A) {
- val old = results.get
- if (!results.compareAndSet(old, element :: old)) {
- add(element)
- }
- }
-
- override final def apply(continue: ContinuationizedParallelIterable[A] => Unit) {
- for (element <- underline) {
- super.incrementAndGet()
- reset {
- val pass = p(element)
- if (pass) {
- add(element)
- }
- if (super.decrementAndGet() == 0) {
- continue(new ContinuationizedParallelIterable(results.get))
- }
- }
- }
- if (super.decrementAndGet() == 0) {
- continue(new ContinuationizedParallelIterable(results.get))
- }
- }
- })
-
- final def foreach[U](f: A => U @suspendable): Unit @suspendable =
- shift(
- new AtomicInteger(1) with ((Unit => Unit) => Unit) {
- override final def apply(continue: Unit => Unit) {
- for (element <- underline) {
- super.incrementAndGet()
- reset {
- f(element)
- if (super.decrementAndGet() == 0) {
- continue()
- }
- }
- }
- if (super.decrementAndGet() == 0) {
- continue()
- }
- }
- })
-
- final def map[B: Manifest](f: A => B @suspendable): ContinuationizedParallelIterable[B] @suspendable =
- shift(
- new AtomicInteger(underline.size) with ((ContinuationizedParallelIterable[B] => Unit) => Unit) {
- override final def apply(continue: ContinuationizedParallelIterable[B] => Unit) {
- val results = new Array[B](super.get)
- for ((element, i) <- underline.view.zipWithIndex) {
- reset {
- val result = f(element)
- results(i) = result
- if (super.decrementAndGet() == 0) {
- continue(new ContinuationizedParallelIterable(results))
- }
- }
- }
- }
- })
-}
-}
diff --git a/test/files/continuations-run/t5506.check b/test/files/continuations-run/t5506.check
deleted file mode 100644
index 38b76c63f1..0000000000
--- a/test/files/continuations-run/t5506.check
+++ /dev/null
@@ -1,7 +0,0 @@
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
-List(1, 2, 3)
diff --git a/test/files/continuations-run/t5506.scala b/test/files/continuations-run/t5506.scala
deleted file mode 100644
index 08f64c9db1..0000000000
--- a/test/files/continuations-run/t5506.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-import scala.util.continuations._
-
-object Test {
-
-def g: List[Int] @suspendable = List(1,2,3)
-
-def fp10: List[Int] @suspendable = {
-g.map(x => x)
-}
-
-def fp11: List[Int] @suspendable = {
-val z = g.map(x => x)
-z
-}
-
-
-def fp12: List[Int] @suspendable = {
-val z = List(1,2,3)
-z.map(x => x)
-}
-
-
-
-def fp20: List[Int] @suspendable = {
-g.map[Int,List[Int]](x => x)
-}
-
-
-def fp21: List[Int] @suspendable = {
-val z = g.map[Int,List[Int]](x => x)
-z
-}
-
-def fp22: List[Int] @suspendable = {
-val z = g.map[Int,List[Int]](x => x)(List.canBuildFrom[Int])
-z
-}
-
-def fp23: List[Int] @suspendable = {
-val z = g.map(x => x)(List.canBuildFrom[Int])
-z
-}
-
-
-def main(args: Array[String]) {
- reset {
- println(fp10)
- println(fp11)
- println(fp12)
-
- println(fp20)
- println(fp21)
- println(fp22)
- println(fp23)
- }
-}
-
-}
diff --git a/test/files/continuations-run/t5538.check b/test/files/continuations-run/t5538.check
deleted file mode 100644
index d9d873663d..0000000000
--- a/test/files/continuations-run/t5538.check
+++ /dev/null
@@ -1,2 +0,0 @@
-warning: there were 1 feature warning(s); re-run with -feature for details
-Future(Future(Future(Future(Future(List(1, 2, 3, 4, 5))))))
diff --git a/test/files/continuations-run/t5538.scala b/test/files/continuations-run/t5538.scala
deleted file mode 100644
index 9f01624da1..0000000000
--- a/test/files/continuations-run/t5538.scala
+++ /dev/null
@@ -1,52 +0,0 @@
-import scala.util.continuations._
-import scala.collection.generic.CanBuildFrom
-
-import scala.language.{ implicitConversions }
-
-object Test {
-
- class ExecutionContext
-
- implicit def defaultExecutionContext = new ExecutionContext
-
- case class Future[+T](x:T) {
- final def map[A](f: T => A): Future[A] = new Future[A](f(x))
- final def flatMap[A](f: T => Future[A]): Future[A] = f(x)
- }
-
- class PromiseStream[A] {
- override def toString = xs.toString
-
- var xs: List[A] = Nil
-
- final def +=(elem: A): this.type = { xs :+= elem; this }
-
- final def ++=(elem: Traversable[A]): this.type = { xs ++= elem; this }
-
- final def <<(elem: Future[A]): PromiseStream[A] @cps[Future[Any]] =
- shift { cont: (PromiseStream[A] => Future[Any]) => elem map (a => cont(this += a)) }
-
- final def <<(elem1: Future[A], elem2: Future[A], elems: Future[A]*): PromiseStream[A] @cps[Future[Any]] =
- shift { cont: (PromiseStream[A] => Future[Any]) => Future.flow(this << elem1 << elem2 <<< Future.sequence(elems.toSeq)) map cont }
-
- final def <<<(elems: Traversable[A]): PromiseStream[A] @cps[Future[Any]] =
- shift { cont: (PromiseStream[A] => Future[Any]) => cont(this ++= elems) }
-
- final def <<<(elems: Future[Traversable[A]]): PromiseStream[A] @cps[Future[Any]] =
- shift { cont: (PromiseStream[A] => Future[Any]) => elems map (as => cont(this ++= as)) }
- }
-
- object Future {
-
- def sequence[A, M[_] <: Traversable[_]](in: M[Future[A]])(implicit cbf: CanBuildFrom[M[Future[A]], A, M[A]], executor: ExecutionContext): Future[M[A]] =
- new Future(in.asInstanceOf[Traversable[Future[A]]].map((f:Future[A])=>f.x)(cbf.asInstanceOf[CanBuildFrom[Traversable[Future[A]], A, M[A]]]))
-
- def flow[A](body: => A @cps[Future[Any]])(implicit executor: ExecutionContext): Future[A] = reset(Future(body)).asInstanceOf[Future[A]]
-
- }
-
- def main(args: Array[String]) {
- val p = new PromiseStream[Int]
- println(Future.flow(p << (Future(1), Future(2), Future(3), Future(4), Future(5))))
- }
-}
diff --git a/test/files/continuations-run/trycatch0.check b/test/files/continuations-run/trycatch0.check
deleted file mode 100644
index 36806909d0..0000000000
--- a/test/files/continuations-run/trycatch0.check
+++ /dev/null
@@ -1,2 +0,0 @@
-10
-10 \ No newline at end of file
diff --git a/test/files/continuations-run/trycatch0.scala b/test/files/continuations-run/trycatch0.scala
deleted file mode 100644
index d0b4a52a30..0000000000
--- a/test/files/continuations-run/trycatch0.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def foo = try {
- shift((k: Int=>Int) => k(7))
- } catch {
- case ex: Throwable =>
- 9
- }
-
- def bar = try {
- 7
- } catch {
- case ex: Throwable =>
- shiftUnit0[Int,Int](9)
- }
-
- def main(args: Array[String]): Unit = {
- println(reset { foo + 3 })
- println(reset { bar + 3 })
- }
-}
diff --git a/test/files/continuations-run/trycatch1.check b/test/files/continuations-run/trycatch1.check
deleted file mode 100644
index 061ecdcd54..0000000000
--- a/test/files/continuations-run/trycatch1.check
+++ /dev/null
@@ -1,10 +0,0 @@
-trycatch1.scala:34: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
- 7
- ^
-trycatch1.scala:18: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
- shift((k: Int=>Int) => k(7))
- ^
-12
-12
-12
-12
diff --git a/test/files/continuations-run/trycatch1.scala b/test/files/continuations-run/trycatch1.scala
deleted file mode 100644
index 2a8db72a8b..0000000000
--- a/test/files/continuations-run/trycatch1.scala
+++ /dev/null
@@ -1,48 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-object Test {
-
- def fatal: Int = throw new Exception()
-
- def foo1 = try {
- fatal
- shift((k: Int=>Int) => k(7))
- } catch {
- case ex: Throwable =>
- 9
- }
-
- def foo2 = try {
- shift((k: Int=>Int) => k(7))
- fatal
- } catch {
- case ex: Throwable =>
- 9
- }
-
- def bar1 = try {
- fatal
- 7
- } catch {
- case ex: Throwable =>
- shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner
- }
-
- def bar2 = try {
- 7
- fatal
- } catch {
- case ex: Throwable =>
- shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner
- }
-
- def main(args: Array[String]): Unit = {
- println(reset { foo1 + 3 })
- println(reset { foo2 + 3 })
- println(reset { bar1 + 3 })
- println(reset { bar2 + 3 })
- }
-
-}
diff --git a/test/files/continuations-run/while0.check b/test/files/continuations-run/while0.check
deleted file mode 100644
index d58c55a31d..0000000000
--- a/test/files/continuations-run/while0.check
+++ /dev/null
@@ -1 +0,0 @@
-9000
diff --git a/test/files/continuations-run/while0.scala b/test/files/continuations-run/while0.scala
deleted file mode 100644
index e21745374e..0000000000
--- a/test/files/continuations-run/while0.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def foo(): Int @cps[Unit] = 2
-
- def test(): Unit @cps[Unit] = {
- var x = 0
- while (x < 9000) { // pick number large enough to require tail-call opt
- x += foo()
- }
- println(x)
- }
-
- def main(args: Array[String]): Unit = {
- reset(test())
- }
-
-}
diff --git a/test/files/continuations-run/while1.check b/test/files/continuations-run/while1.check
deleted file mode 100644
index 3d5f0b9a46..0000000000
--- a/test/files/continuations-run/while1.check
+++ /dev/null
@@ -1,11 +0,0 @@
-up
-up
-up
-up
-up
-10
-down
-down
-down
-down
-down
diff --git a/test/files/continuations-run/while1.scala b/test/files/continuations-run/while1.scala
deleted file mode 100644
index 7ba9f94881..0000000000
--- a/test/files/continuations-run/while1.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def foo(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") }
-
- def test(): Unit @cps[Unit] = {
- var x = 0
- while (x < 9) {
- x += foo()
- }
- println(x)
- }
-
- def main(args: Array[String]): Unit = {
- reset(test())
- }
-
-}
diff --git a/test/files/continuations-run/while2.check b/test/files/continuations-run/while2.check
deleted file mode 100644
index 9fe515181b..0000000000
--- a/test/files/continuations-run/while2.check
+++ /dev/null
@@ -1,19 +0,0 @@
-up
-up
-up
-up
-up
-up
-up
-up
-up
-9000
-down
-down
-down
-down
-down
-down
-down
-down
-down
diff --git a/test/files/continuations-run/while2.scala b/test/files/continuations-run/while2.scala
deleted file mode 100644
index 3dbf2ad2fe..0000000000
--- a/test/files/continuations-run/while2.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-
-object Test {
-
- def foo1(): Int @cps[Unit] = 2
- def foo2(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") }
-
- def test(): Unit @cps[Unit] = {
- var x = 0
- while (x < 9000) { // pick number large enough to require tail-call opt
- x += (if (x % 1000 != 0) foo1() else foo2())
- }
- println(x)
- }
-
- def main(args: Array[String]): Unit = {
- reset(test())
- }
-
-}
diff --git a/test/files/continuations-run/z1673.scala b/test/files/continuations-run/z1673.scala
deleted file mode 100644
index 716b374860..0000000000
--- a/test/files/continuations-run/z1673.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-import scala.util.continuations._
-
-class MatchRepro {
- def s: String @cps[Any] = shift { k => k("foo") }
-
- def p = {
- val k = s
- s match { case lit0 => }
- }
-
- def q = {
- val k = s
- k match { case lit1 => }
- }
-
- def r = {
- s match { case "FOO" => }
- }
-
- def t = {
- val k = s
- k match { case "FOO" => }
- }
-}
-
-object Test {
- def main(args: Array[String]): Unit = {
- val m = new MatchRepro
- ()
- }
-}
diff --git a/test/files/continuations-run/t3199b.check b/test/files/run/t3199b.check
index b5d8bb58d9..b5d8bb58d9 100644
--- a/test/files/continuations-run/t3199b.check
+++ b/test/files/run/t3199b.check
diff --git a/test/files/continuations-run/t3199b.scala b/test/files/run/t3199b.scala
index 5010f2b085..5010f2b085 100644
--- a/test/files/continuations-run/t3199b.scala
+++ b/test/files/run/t3199b.scala
diff --git a/test/pending/continuations-pos/t3620.scala b/test/pending/continuations-pos/t3620.scala
deleted file mode 100644
index 8496ae2858..0000000000
--- a/test/pending/continuations-pos/t3620.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-import scala.collection.mutable.HashMap
-import scala.util.continuations._
-
-object Test extends Application {
-
- class Store[K,V] {
-
- trait Waiting {
- def key: K
- def inform(value: V): Unit
- }
-
- private val map = new HashMap[K, V]
- private var waiting: List[Waiting] = Nil
-
- def waitFor(k: K, f: (V => Unit)) {
- map.get(k) match {
- case Some(v) => f(v)
- case None => {
- val w = new Waiting {
- def key = k
- def inform(v: V) = f(v)
- }
- waiting = w :: waiting
- }
- }
- }
-
-
- def add(key: K, value: V) {
- map(key) = value
- val p = waiting.partition(_.key == key)
- waiting = p._2
- p._1.foreach(_.inform(value))
- }
-
- def required(key: K) = {
- shift {
- c: (V => Unit) => {
- waitFor(key, c)
- }
- }
- }
-
- def option(key: Option[K]) = {
- shift {
- c: (Option[V] => Unit) => {
- key match {
- case Some(key) => waitFor(key, (v: V) => c(Some(v)))
- case None => c(None)
- }
-
- }
- }
- }
-
- }
-
- val store = new Store[String, Int]
-
- def test(p: Option[String]): Unit = {
- reset {
- // uncommenting the following two lines makes the compiler happy!
-// val o = store.option(p)
-// println(o)
- val i = store.option(p).getOrElse(1)
- println(i)
- }
- }
-
- test(Some("a"))
-
-}
diff --git a/test/pending/continuations-run/example0.scala b/test/pending/continuations-run/example0.scala
deleted file mode 100644
index de5ea54e9d..0000000000
--- a/test/pending/continuations-run/example0.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test0.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example1.scala b/test/pending/continuations-run/example1.scala
deleted file mode 100644
index e31d6af88c..0000000000
--- a/test/pending/continuations-run/example1.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test1.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example16.scala b/test/pending/continuations-run/example16.scala
deleted file mode 100644
index 561f0ab0eb..0000000000
--- a/test/pending/continuations-run/example16.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test16Printf.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example2.scala b/test/pending/continuations-run/example2.scala
deleted file mode 100644
index 730f7cc63e..0000000000
--- a/test/pending/continuations-run/example2.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test2.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example3.scala b/test/pending/continuations-run/example3.scala
deleted file mode 100644
index 41cf1cce0c..0000000000
--- a/test/pending/continuations-run/example3.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test3.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example4.scala b/test/pending/continuations-run/example4.scala
deleted file mode 100644
index adcc7aa90e..0000000000
--- a/test/pending/continuations-run/example4.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test4.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example5.scala b/test/pending/continuations-run/example5.scala
deleted file mode 100644
index 241e8cd069..0000000000
--- a/test/pending/continuations-run/example5.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test5.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example6.scala b/test/pending/continuations-run/example6.scala
deleted file mode 100644
index 00f84fcd6c..0000000000
--- a/test/pending/continuations-run/example6.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test6.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example7.scala b/test/pending/continuations-run/example7.scala
deleted file mode 100644
index 64abc6d9a6..0000000000
--- a/test/pending/continuations-run/example7.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test7.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example8.scala b/test/pending/continuations-run/example8.scala
deleted file mode 100644
index a5f953d3fc..0000000000
--- a/test/pending/continuations-run/example8.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test8.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/example9.scala b/test/pending/continuations-run/example9.scala
deleted file mode 100644
index 09d792c427..0000000000
--- a/test/pending/continuations-run/example9.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// $Id$
-
-object Test {
-
- def main(args: Array[String]): Any = {
- examples.continuations.Test9Monads.main(args)
- }
-
-} \ No newline at end of file
diff --git a/test/pending/continuations-run/foreach.check b/test/pending/continuations-run/foreach.check
deleted file mode 100644
index 9bab7a2eed..0000000000
--- a/test/pending/continuations-run/foreach.check
+++ /dev/null
@@ -1,4 +0,0 @@
-1
-2
-3
-enough is enough \ No newline at end of file
diff --git a/test/pending/continuations-run/foreach.scala b/test/pending/continuations-run/foreach.scala
deleted file mode 100644
index 76823e7604..0000000000
--- a/test/pending/continuations-run/foreach.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-// $Id$
-
-import scala.util.continuations._
-
-import scala.util.continuations.Loops._
-
-object Test {
-
- def main(args: Array[String]): Any = {
-
-
- reset {
-
- val list = List(1,2,3,4,5)
-
- for (x <- list.suspendable) {
-
- shift { k: (Unit => Unit) =>
- println(x)
- if (x < 3)
- k()
- else
- println("enough is enough")
- }
-
- }
-
- }
-
-
- }
-
-} \ No newline at end of file
diff --git a/versions.properties b/versions.properties
index 76eea52681..d72a1e9d83 100644
--- a/versions.properties
+++ b/versions.properties
@@ -4,9 +4,15 @@ starr.use.released=1
# These are the versions of the modules that go with this release.
# These properties are used during PR validation and in dbuild builds.
scala.binary.version=2.11.0-M7
-partest.version.number=1.0.0-RC8
+
+# external modules shipped with distribution:
scala-xml.version.number=1.0.0-RC7
scala-parser-combinators.version.number=1.0.0-RC5
+scala-continuations-plugin.version.number=1.0.0-RC2
+scala-continuations-library.version.number=1.0.0-RC2
+
+# external modules, used internally (not shipped)
+partest.version.number=1.0.0-RC8
scalacheck.version.number=1.11.1
# TODO: modularize the compiler