Skip to content

Commit b4a342a

Browse files
committed
enable continuations plugin and test
1 parent a1847e1 commit b4a342a

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

build.sbt

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,11 @@ scalaVersion := version.value
44

55
libraryDependencies += "org.scala-lang" % "scala-dist" % version.value
66

7-
// TODO: find out how to enable continuations plugin. also un-comment ContinuationsTest afterwards!
7+
// funky way to enable the continuations plugin.
88
// http://stackoverflow.com/questions/24755254/how-to-enable-compiler-plugin-from-librarydependencies
9-
10-
//autoCompilerPlugins := true
11-
12-
//val addContinuationsPlugin = taskKey[Unit]("Add continuations plugin")
13-
14-
//addContinuationsPlugin := {
15-
// println(update.value.allModules.find(_.name contains "continuations-plugin"))
16-
// compilerPlugin(update.value.allModules.find(_.name contains "continuations-plugin").get)
17-
//}
18-
19-
//libraryDependencies += compilerPlugin(update.value.allModules.find(_.name contains "continuations-plugin").get)
20-
21-
//scalacOptions += "-P:continuations:enable"
9+
scalacOptions ++= {
10+
val compileConfig = update.value.configurations.find(_.configuration == "compile").get
11+
val pluginModule = compileConfig.modules.find(_.module.name contains "continuations-plugin").get
12+
val pluginFile = pluginModule.artifacts.head._2
13+
Seq(s"-Xplugin:${pluginFile.getCanonicalPath}", "-P:continuations:enable")
14+
}

src/main/scala/scaladist/ContinuationsTest.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ package scaladist
33
import scala.util.continuations._
44

55
object ContinuationsTest {
6-
/*
7-
def foo(): Int @cps[Int] = { // could leave out return type
6+
def foo(): Int @cps[Int] = {
87
shift { k: (Int=>Int) =>
98
k(7)
109
} + 1
1110
}
12-
*/
1311
def test(): Unit = {
14-
// assert(reset(2 * foo()) == 16)
12+
assert(reset(2 * foo()) == 16)
1513
}
1614
}

0 commit comments

Comments
 (0)