Skip to content

Commit 04e2072

Browse files
jchybtgodzik
authored andcommitted
Rethrow SuspendExceptions in CodeGen phase
[Cherry-picked 8a5a93a]
1 parent 6cdbc77 commit 04e2072

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

Diff for: compiler/src/dotty/tools/backend/jvm/CodeGen.scala

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class CodeGen(val int: DottyBackendInterface, val primitives: DottyPrimitives)(
8383
registerGeneratedClass(mirrorClassNode, isArtifact = true)
8484
catch
8585
case ex: InterruptedException => throw ex
86+
case ex: CompilationUnit.SuspendException => throw ex
8687
case ex: Throwable =>
8788
ex.printStackTrace()
8889
report.error(s"Error while emitting ${unit.source}\n${ex.getMessage}", NoSourcePosition)

Diff for: tests/pos-macros/i21983/Test.scala

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package example
2+
3+
sealed trait Test
4+
5+
object Test {
6+
case object Foo extends Test
7+
8+
val visitorType = mkVisitorType[Test]
9+
10+
trait Visitor[A] {
11+
type V[a] = visitorType.Out[a]
12+
}
13+
}

Diff for: tests/pos-macros/i21983/UsesTest.scala

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package example
2+
3+
val _ = Test.Foo

Diff for: tests/pos-macros/i21983/VisitorMacros.scala

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package example
2+
3+
import scala.deriving.Mirror
4+
import scala.quoted.*
5+
6+
private def mkVisitorTypeImpl[T: Type](using q: Quotes): Expr[VisitorType[T]] =
7+
'{new VisitorType[T]{}}
8+
9+
transparent inline def mkVisitorType[T]: VisitorType[T] = ${ mkVisitorTypeImpl[T] }
10+
11+
trait VisitorType[T] {
12+
type Out[A]
13+
}

0 commit comments

Comments
 (0)