File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
tests/run-macros/reflect-inline Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+
3
+ object api {
4
+ inline def (inline x : String ) stripMargin : String =
5
+ $ { stripImpl(x) }
6
+
7
+ private def stripImpl (x : String )(given qctx : QuoteContext ): Expr [String ] =
8
+ Expr (augmentString(x).stripMargin)
9
+
10
+ inline def typeChecks (inline x : String ): Boolean =
11
+ $ { typeChecksImpl(scala.compiletime.testing.typeChecks(x)) }
12
+
13
+ private def typeChecksImpl (b : Boolean )(given qctx : QuoteContext ): Expr [Boolean ] = {
14
+ if (b) Expr (true ) else Expr (false )
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ import api ._
2
+
3
+ object Test {
4
+ def main (args : Array [String ]): Unit = {
5
+ val a : String = " 5"
6
+ assert(typeChecks(" |1 + 1" .stripMargin))
7
+ assert(scala.compiletime.testing.typeChecks(" |1 + 1" .stripMargin))
8
+ assert((" |3 + " + a).stripMargin == " 3 + 5" )
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments