File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ -- Error: tests/neg-macros/i11386/Test_2.scala:6:10 --------------------------------------------------------------------
3+ 6 | dummy(0) // error
4+ | ^
5+ | test
6+ | This location contains code that was inlined from Test_2.scala:6
7+ | This location contains code that was inlined from Macro_1.scala:7
8+ -- Error: tests/neg-macros/i11386/Test_2.scala:8:20 --------------------------------------------------------------------
9+ 8 | dummy(int2String(0)) // error
10+ | ^^^^^^^^^^^^^
11+ | test
12+ | This location contains code that was inlined from Test_2.scala:8
13+ | This location contains code that was inlined from Macro_1.scala:7
Original file line number Diff line number Diff line change 1+ import scala .language .implicitConversions
2+ import scala .quoted ._
3+
4+ object test {
5+
6+ inline implicit def int2String (inline i : Int ): String = {
7+ notNull(i)
8+ String .valueOf(i)
9+ }
10+
11+ inline def notNull (inline i : Int ): Unit = $ {notNullImpl(' i )}
12+
13+ def notNullImpl (expr : Expr [Int ])(using quotes : Quotes ): Expr [Unit ] = {
14+ println(expr.show)
15+ expr.value.foreach(i => if (i == 0 ) quotes.reflect.report.error(" test" ))
16+ ' {()}
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ import test ._
2+
3+ object Main {
4+
5+ @ main def dottyTest (): Unit = {
6+ dummy(0 ) // error
7+ dummy(1 )
8+ dummy(int2String(0 )) // error
9+ dummy(int2String(1 ))
10+ }
11+
12+ def dummy (msg : String ): Unit = println(msg) // A simple dummy method to call implicitly test.int2String
13+ }
You can’t perform that action at this time.
0 commit comments