Skip to content

Commit 842f3ce

Browse files
committed
Workaround scala/scala3#11630
1 parent 7669878 commit 842f3ce

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package test.cask
2+
3+
import scala.language.experimental.macros
4+
5+
object VersionSpecific {
6+
7+
// See src-3/VersionSpecific for a comment on why we can't use
8+
// `utest.compileError` directly in Scala 3.
9+
def compileError(expr: String): utest.CompileError = macro utest.asserts.Asserts.compileError
10+
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package test.cask
2+
3+
import utest._
4+
5+
object VersionSpecific {
6+
7+
// This is a workaround for https://github.com/lampepfl/dotty/issues/11630.
8+
// The essence of the issue is that between Dotty 3.0.0-M3 and 3.0.0-RC1 the
9+
// inliner and typer phases were decoupled. Since utest defines
10+
// `compilerError` as `transparent` in order to propagate error position
11+
// information, it no can no longer catch compilation errors resulting from
12+
// inlines. However, since cask heavily uses macros, we need the old behavior
13+
// to check for error cases. Hence, to work around the issue, we forward to
14+
// utest, but this time without the `transparent` modifier.
15+
inline def compileError(inline expr: String): utest.CompileError = utest.compileError(expr)
16+
17+
}

cask/test/src/test/cask/FailureTests.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object FailureTests extends TestSuite {
1212

1313
val tests = Tests{
1414
"mismatchedDecorators" - {
15-
val m = utest.compileError("""
15+
val m = VersionSpecific.compileError("""
1616
object Decorated extends cask.MainRoutes{
1717
@myDecorator
1818
@cask.websocket("/hello/:world")
@@ -24,7 +24,7 @@ object FailureTests extends TestSuite {
2424
}
2525

2626
"noEndpoint" - {
27-
utest.compileError("""
27+
VersionSpecific.compileError("""
2828
object Decorated extends cask.MainRoutes{
2929
@cask.get("/hello/:world")
3030
@myDecorator()
@@ -36,7 +36,7 @@ object FailureTests extends TestSuite {
3636
}
3737

3838
"tooManyEndpoint" - {
39-
utest.compileError("""
39+
VersionSpecific.compileError("""
4040
object Decorated extends cask.MainRoutes{
4141
@cask.get("/hello/:world")
4242
@cask.get("/hello/:world")

0 commit comments

Comments
 (0)