File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
tests/run-with-compiler/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
+ import scala .tasty ._
3
+
4
+ object api {
5
+ inline def (inline x : String ) strip <: String =
6
+ $ { stripImpl(x) }
7
+
8
+ private def stripImpl (x : String )(implicit refl : Reflection ): Expr [String ] =
9
+ x.stripMargin.toExpr
10
+
11
+ inline def typeChecks (inline x : String ): Boolean =
12
+ $ { typeChecksImpl(x) }
13
+
14
+ private def typeChecksImpl (x : String )(implicit refl : Reflection ): Expr [Boolean ] = {
15
+ import refl ._
16
+ if (refl.typing.typeChecks(x)) true .toExpr else false .toExpr
17
+ }
18
+ }
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
+ assert(typeChecks(" 1 + 1" .strip))
6
+ assert(scala.testing.typeChecks(" 1 + 1" .strip))
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments