diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index 4e0b7d09e95f..d18a2ddc7db0 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -141,7 +141,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint |""" val enableXprintSuspensionHint = if ctx.settings.XprintSuspension.value then "" - else "\n\nCompiling with -Xprint-suspension gives more information." + else "\n\nCompile with -Xprint-suspension for information." report.error(em"""Cyclic macro dependencies $where |Compilation stopped since no further progress can be made. | diff --git a/tests/neg-macros/annot-suspend-cycle.check b/tests/neg-macros/annot-suspend-cycle.check index e3ecea7345fd..437398f1d668 100644 --- a/tests/neg-macros/annot-suspend-cycle.check +++ b/tests/neg-macros/annot-suspend-cycle.check @@ -9,4 +9,4 @@ Compilation stopped since no further progress can be made. To fix this, place macros in one set of files and their callers in another. -Compiling with -Xprint-suspension gives more information. +Compile with -Xprint-suspension for information. diff --git a/tests/neg-macros/i19526.check b/tests/neg-macros/i19526.check new file mode 100644 index 000000000000..2ad0a7aa2199 --- /dev/null +++ b/tests/neg-macros/i19526.check @@ -0,0 +1,6 @@ +Cyclic macro dependencies in tests/neg-macros/i19526/Test.scala. +Compilation stopped since no further progress can be made. + +To fix this, place macros in one set of files and their callers in another. + +Compile with -Xprint-suspension for information. diff --git a/tests/neg-macros/i19526/Macro.scala b/tests/neg-macros/i19526/Macro.scala new file mode 100644 index 000000000000..e6861c1986ef --- /dev/null +++ b/tests/neg-macros/i19526/Macro.scala @@ -0,0 +1,15 @@ +package crash.test + +import scala.language.dynamics + +import scala.quoted.* + +object Export extends Dynamic: + inline def applyDynamic(name: "apply")(inline args: Any*): Stack = ${ + applyDynamicImpl('args) + } + + def applyDynamicImpl(args: Expr[Seq[Any]])(using Quotes): Expr[Stack] = + import quotes.reflect.* + + '{ Stack("", Vector.empty) } diff --git a/tests/neg-macros/i19526/Test.scala b/tests/neg-macros/i19526/Test.scala new file mode 100644 index 000000000000..45ae51b664dd --- /dev/null +++ b/tests/neg-macros/i19526/Test.scala @@ -0,0 +1,14 @@ +package crash.test + +case class Stack private[crash] ( + exports: String, + dependsOn: Vector[Int] +) + +trait StackFactory: + val exports: Export.type = Export + + def apply(dependsOn: Int*): Stack = + Export().copy(dependsOn = dependsOn.toVector) + +// nopos-error diff --git a/tests/neg-macros/macros-in-same-project-4.check b/tests/neg-macros/macros-in-same-project-4.check index 79c78fd0fb7f..f027f57637f4 100644 --- a/tests/neg-macros/macros-in-same-project-4.check +++ b/tests/neg-macros/macros-in-same-project-4.check @@ -3,4 +3,4 @@ Compilation stopped since no further progress can be made. To fix this, place macros in one set of files and their callers in another. -Compiling with -Xprint-suspension gives more information. +Compile with -Xprint-suspension for information. diff --git a/tests/pos-macros/i19526b/Macro.scala b/tests/pos-macros/i19526b/Macro.scala new file mode 100644 index 000000000000..e6861c1986ef --- /dev/null +++ b/tests/pos-macros/i19526b/Macro.scala @@ -0,0 +1,15 @@ +package crash.test + +import scala.language.dynamics + +import scala.quoted.* + +object Export extends Dynamic: + inline def applyDynamic(name: "apply")(inline args: Any*): Stack = ${ + applyDynamicImpl('args) + } + + def applyDynamicImpl(args: Expr[Seq[Any]])(using Quotes): Expr[Stack] = + import quotes.reflect.* + + '{ Stack("", Vector.empty) } diff --git a/tests/pos-macros/i19526b/Test.scala b/tests/pos-macros/i19526b/Test.scala new file mode 100644 index 000000000000..1cc037298e01 --- /dev/null +++ b/tests/pos-macros/i19526b/Test.scala @@ -0,0 +1,16 @@ +package crash.test + +case class Stack private[crash] ( + exports: String, + dependsOn: Vector[Int] +) + +object Stack: + @annotation.publicInBinary + private[crash] def apply(exports: String, dependsOn: Vector[Int]): Stack = new Stack(exports, dependsOn) + +trait StackFactory: + val exports: Export.type = Export + + def apply(dependsOn: Int*): Stack = + Export().copy(dependsOn = dependsOn.toVector)