Skip to content

Commit cd0a9ce

Browse files
nicolasstuckiliufengyun
authored andcommitted
Fix reflect-inline test
1 parent 463aa7b commit cd0a9ce

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
}

0 commit comments

Comments
 (0)