diff --git a/tests/run-with-compiler/reflect-inline/assert_1.scala b/tests/run-with-compiler/reflect-inline/assert_1.scala new file mode 100644 index 000000000000..029b7261dd99 --- /dev/null +++ b/tests/run-with-compiler/reflect-inline/assert_1.scala @@ -0,0 +1,18 @@ +import scala.quoted._ +import scala.tasty._ + +object api { + inline def (inline x: String) strip <: String = + ${ stripImpl(x) } + + private def stripImpl(x: String)(implicit refl: Reflection): Expr[String] = + x.stripMargin.toExpr + + inline def typeChecks(inline x: String): Boolean = + ${ typeChecksImpl(x) } + + private def typeChecksImpl(x: String)(implicit refl: Reflection): Expr[Boolean] = { + import refl._ + if (refl.typing.typeChecks(x)) true.toExpr else false.toExpr + } +} diff --git a/tests/run-with-compiler/reflect-inline/test_2.scala b/tests/run-with-compiler/reflect-inline/test_2.scala new file mode 100644 index 000000000000..e2c09036de0d --- /dev/null +++ b/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)) + } +} \ No newline at end of file