Skip to content

Commit ca57ff9

Browse files
nicolasstuckiliufengyun
authored andcommitted
Test incremental compilation with suspension
1 parent a4bdb4f commit ca57ff9

File tree

15 files changed

+131
-0
lines changed

15 files changed

+131
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Main extends App {
2+
Macro.f()
3+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.quoted._
2+
3+
object Macro {
4+
5+
inline def f(): Unit = ${ macroImplementation }
6+
7+
def macroImplementation(given QuoteContext): Expr[Unit] = {
8+
'{ println("Implementation in Macro") }
9+
}
10+
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import scala.quoted._
2+
3+
object Macro {
4+
5+
inline def f(): Unit = ${ macroImplementation }
6+
7+
def macroImplementation(given qctx: QuoteContext): Expr[Unit] = {
8+
import qctx.tasty._
9+
error("some error", rootPosition)
10+
'{ println("Implementation in MacroCompileError") }
11+
}
12+
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.quoted._
2+
3+
object Macro {
4+
5+
inline def f(): Unit = ${ macroImplementation }
6+
7+
def macroImplementation(given qctx: QuoteContext): Expr[Unit] = {
8+
'{ ??? }
9+
}
10+
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sbt._
2+
import Keys._
3+
4+
object DottyInjectedPlugin extends AutoPlugin {
5+
override def requires = plugins.JvmPlugin
6+
override def trigger = allRequirements
7+
8+
override val projectSettings = Seq(
9+
scalaVersion := sys.props("plugin.scalaVersion")
10+
)
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version"))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ copy-file changes/Macro.scala Macro.scala
2+
> run
3+
4+
# use an implemntation of the macro that emits a compile time error
5+
$ copy-file changes/MacroCompileError.scala Macro.scala
6+
-> compile
7+
8+
$ copy-file changes/Macro.scala Macro.scala
9+
> clean
10+
> compile
11+
12+
$ copy-file changes/MacroRuntimeError.scala Macro.scala
13+
-> run
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.quoted._
2+
3+
object Macro {
4+
5+
inline def f(): Unit = ${ macroImplementation }
6+
7+
def macroImplementation(given QuoteContext): Expr[Unit] =
8+
MacroRuntime.impl()
9+
10+
11+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Main extends App {
2+
Macro.f()
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import scala.quoted._
2+
3+
object MacroRuntime {
4+
5+
def impl()(given QuoteContext): Expr[Unit] = {
6+
'{ println("Implementation in Macro") }
7+
}
8+
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.quoted._
2+
3+
object MacroRuntime {
4+
5+
def impl()(given qctx: QuoteContext): Expr[Unit] = {
6+
import qctx.tasty._
7+
error("some error", rootPosition)
8+
'{ println("Implementation in MacroCompileError") }
9+
}
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import scala.quoted._
2+
3+
object MacroRuntime {
4+
5+
def impl()(given qctx: QuoteContext): Expr[Unit] = {
6+
'{ ??? }
7+
}
8+
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sbt._
2+
import Keys._
3+
4+
object DottyInjectedPlugin extends AutoPlugin {
5+
override def requires = plugins.JvmPlugin
6+
override def trigger = allRequirements
7+
8+
override val projectSettings = Seq(
9+
scalaVersion := sys.props("plugin.scalaVersion")
10+
)
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version"))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ copy-file changes/MacroRuntime.scala MacroRuntime.scala
2+
> run
3+
4+
# use an implemntation of the macro that emits a compile time error
5+
$ copy-file changes/MacroRuntimeCompileError.scala MacroRuntime.scala
6+
-> compile
7+
8+
$ copy-file changes/MacroRuntime.scala MacroRuntime.scala
9+
> clean
10+
> compile
11+
12+
$ copy-file changes/MacroRuntimeRuntimeError.scala MacroRuntime.scala
13+
-> run

0 commit comments

Comments
 (0)