Skip to content

Commit 5146353

Browse files
nicolasstuckiWojciechMazur
authored andcommitted
Add regression test
Closes #19526 [Cherry-picked 2c32436]
1 parent acc8ef6 commit 5146353

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

Diff for: 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.

Diff for: 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) }

Diff for: 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

Diff for: 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) }

Diff for: 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)