Skip to content

Commit e440974

Browse files
committed
Add regression tests
1 parent bcc074d commit e440974

File tree

7 files changed

+66
-0
lines changed

7 files changed

+66
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import scala.quoted._
3+
4+
object Bar {
5+
6+
myMacro() // error
7+
8+
inline def myMacro(): Unit = ${ aMacroImplementation }
9+
10+
def aMacroImplementation(given QuoteContext): Expr[Unit] = '{}
11+
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
import scala.quoted._
3+
4+
object Bar {
5+
6+
myMacro()
7+
8+
inline def myMacro(): Unit = myMacro2() // error
9+
inline def myMacro2(): Unit = ${ aMacroImplementation }
10+
11+
def aMacroImplementation(given QuoteContext): Expr[Unit] = '{}
12+
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/neg-macros/macros-in-same-project-6/Bar.scala:4:13 -----------------------------------------------------
2+
4 | Foo.myMacro() // error
3+
| ^^^^^^^^^^^^^
4+
| some error
5+
| This location is in code that was inlined at Bar.scala:4
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.quoted._
2+
3+
object Bar {
4+
Foo.myMacro() // error
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import scala.quoted._
2+
3+
object Foo {
4+
5+
inline def myMacro(): Unit = ${ aMacroImplementation }
6+
7+
def aMacroImplementation(given qctx: QuoteContext): Expr[Unit] = {
8+
import qctx.tasty._
9+
error("some error", rootPosition)
10+
throw new NoClassDefFoundError("Bar$")
11+
}
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.quoted._
2+
3+
object Bar {
4+
5+
inline def eqMacro(x: Foo, y: Foo): Boolean = ${ eqMacroExpr('x, 'y) }
6+
def eqMacroExpr(x: Expr[Foo], y: Expr[Foo])(given QuoteContext): Expr[Boolean] = '{ $x == $y }
7+
8+
inline def plusMacro(x: Foo, y: Foo): Foo = ${ eqPlusExpr('x, 'y) }
9+
def eqPlusExpr(x: Expr[Foo], y: Expr[Foo])(given QuoteContext): Expr[Foo] = '{ new Foo($x.value + $y.value) }
10+
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
3+
object Foo {
4+
def eq(x: Foo, y: Foo): Boolean = Bar.eqMacro(x, y)
5+
def plus(x: Foo, y: Foo): Foo = Bar.plusMacro(x, y)
6+
}
7+
8+
class Foo(val value: Int)

0 commit comments

Comments
 (0)