Skip to content

Commit 5bd93b1

Browse files
Add regression test and imporve -Xprint-suspension message (#19688)
Closes #19526
2 parents 944e73e + 2c32436 commit 5bd93b1

File tree

8 files changed

+69
-3
lines changed

8 files changed

+69
-3
lines changed

compiler/src/dotty/tools/dotc/Run.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
141141
|"""
142142
val enableXprintSuspensionHint =
143143
if ctx.settings.XprintSuspension.value then ""
144-
else "\n\nCompiling with -Xprint-suspension gives more information."
144+
else "\n\nCompile with -Xprint-suspension for information."
145145
report.error(em"""Cyclic macro dependencies $where
146146
|Compilation stopped since no further progress can be made.
147147
|

tests/neg-macros/annot-suspend-cycle.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Compilation stopped since no further progress can be made.
99

1010
To fix this, place macros in one set of files and their callers in another.
1111

12-
Compiling with -Xprint-suspension gives more information.
12+
Compile with -Xprint-suspension for information.

tests/neg-macros/i19526.check

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Cyclic macro dependencies in tests/neg-macros/i19526/Test.scala.
2+
Compilation stopped since no further progress can be made.
3+
4+
To fix this, place macros in one set of files and their callers in another.
5+
6+
Compile with -Xprint-suspension for information.

tests/neg-macros/i19526/Macro.scala

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package crash.test
2+
3+
import scala.language.dynamics
4+
5+
import scala.quoted.*
6+
7+
object Export extends Dynamic:
8+
inline def applyDynamic(name: "apply")(inline args: Any*): Stack = ${
9+
applyDynamicImpl('args)
10+
}
11+
12+
def applyDynamicImpl(args: Expr[Seq[Any]])(using Quotes): Expr[Stack] =
13+
import quotes.reflect.*
14+
15+
'{ Stack("", Vector.empty) }

tests/neg-macros/i19526/Test.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package crash.test
2+
3+
case class Stack private[crash] (
4+
exports: String,
5+
dependsOn: Vector[Int]
6+
)
7+
8+
trait StackFactory:
9+
val exports: Export.type = Export
10+
11+
def apply(dependsOn: Int*): Stack =
12+
Export().copy(dependsOn = dependsOn.toVector)
13+
14+
// nopos-error

tests/neg-macros/macros-in-same-project-4.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Compilation stopped since no further progress can be made.
33

44
To fix this, place macros in one set of files and their callers in another.
55

6-
Compiling with -Xprint-suspension gives more information.
6+
Compile with -Xprint-suspension for information.

tests/pos-macros/i19526b/Macro.scala

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package crash.test
2+
3+
import scala.language.dynamics
4+
5+
import scala.quoted.*
6+
7+
object Export extends Dynamic:
8+
inline def applyDynamic(name: "apply")(inline args: Any*): Stack = ${
9+
applyDynamicImpl('args)
10+
}
11+
12+
def applyDynamicImpl(args: Expr[Seq[Any]])(using Quotes): Expr[Stack] =
13+
import quotes.reflect.*
14+
15+
'{ Stack("", Vector.empty) }

tests/pos-macros/i19526b/Test.scala

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package crash.test
2+
3+
case class Stack private[crash] (
4+
exports: String,
5+
dependsOn: Vector[Int]
6+
)
7+
8+
object Stack:
9+
@annotation.publicInBinary
10+
private[crash] def apply(exports: String, dependsOn: Vector[Int]): Stack = new Stack(exports, dependsOn)
11+
12+
trait StackFactory:
13+
val exports: Export.type = Export
14+
15+
def apply(dependsOn: Int*): Stack =
16+
Export().copy(dependsOn = dependsOn.toVector)

0 commit comments

Comments
 (0)