Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test and imporve -Xprint-suspension message #19688

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
|
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/annot-suspend-cycle.check
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 6 additions & 0 deletions tests/neg-macros/i19526.check
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions tests/neg-macros/i19526/Macro.scala
Original file line number Diff line number Diff line change
@@ -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) }
14 changes: 14 additions & 0 deletions tests/neg-macros/i19526/Test.scala
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/neg-macros/macros-in-same-project-4.check
Original file line number Diff line number Diff line change
Expand Up @@ -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.
15 changes: 15 additions & 0 deletions tests/pos-macros/i19526b/Macro.scala
Original file line number Diff line number Diff line change
@@ -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) }
16 changes: 16 additions & 0 deletions tests/pos-macros/i19526b/Test.scala
Original file line number Diff line number Diff line change
@@ -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)
Loading