From 231d13c21d47f81b69d03eb8c4c112d77eb377d2 Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Mon, 18 Nov 2024 17:36:25 +0100 Subject: [PATCH 1/3] Allow macro annotations to recover from suspension --- compiler/src/dotty/tools/dotc/transform/MacroAnnotations.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/src/dotty/tools/dotc/transform/MacroAnnotations.scala b/compiler/src/dotty/tools/dotc/transform/MacroAnnotations.scala index 3478efccd620..e1267b4aef68 100644 --- a/compiler/src/dotty/tools/dotc/transform/MacroAnnotations.scala +++ b/compiler/src/dotty/tools/dotc/transform/MacroAnnotations.scala @@ -60,6 +60,8 @@ class MacroAnnotations: // Replace this case with the nested cases. case ex0: InvocationTargetException => ex0.getCause match + case ex: CompilationUnit.SuspendException => + throw ex case ex: scala.quoted.runtime.StopMacroExpansion => if !ctx.reporter.hasErrors then report.error("Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users when aborting a macro expansion with StopMacroExpansion.", annot.tree) From 0faa5acc59601bc7657c42aa6011f899f4575536 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Sat, 8 Mar 2025 21:10:26 +0100 Subject: [PATCH 2/3] Allow macro annotations to recover from suspension [Cherry-picked c9badbc34b84a996d50d925470462109083e755f][modified] From 17bdc14846df6a19aeb37ec10ec1c8fc7a541efd Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Mon, 18 Nov 2024 22:01:53 +0100 Subject: [PATCH 3/3] update test suite [Cherry-picked 16c4a8231c7cef5568192f8feca34fd81219e9cf] --- tests/neg-macros/annot-crash.check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/neg-macros/annot-crash.check b/tests/neg-macros/annot-crash.check index 16eb0f68bc44..0a5d573d2c0d 100644 --- a/tests/neg-macros/annot-crash.check +++ b/tests/neg-macros/annot-crash.check @@ -2,7 +2,7 @@ -- Error: tests/neg-macros/annot-crash/Test_2.scala:1:0 ---------------------------------------------------------------- 1 |@crash // error |^^^^^^ - |Failed to evaluate macro. + |Failed to evaluate macro annotation '@crash'. | Caused by class scala.NotImplementedError: an implementation is missing | scala.Predef$.$qmark$qmark$qmark(Predef.scala:344) | crash.transform(Macro_1.scala:7)