We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5163b70 + d45e50c commit f62e286Copy full SHA for f62e286
tests/run-with-compiler/reflect-inline/assert_1.scala
@@ -0,0 +1,18 @@
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
+}
tests/run-with-compiler/reflect-inline/test_2.scala
@@ -0,0 +1,8 @@
+import api._
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(typeChecks("1 + 1".strip))
+ assert(scala.testing.typeChecks("1 + 1".strip))
0 commit comments