Skip to content

Commit a5452e8

Browse files
committed
Only compile quoted code in bootstrapped library
This will allow changing the internal representations without having incompatibilities while bootstrapping. Currently, each time one of those occurs we duplicate the file in src-bootstrapped and src-non-bootstrapped while losing the blame history.
1 parent 5d5a3dd commit a5452e8

File tree

20 files changed

+42
-7
lines changed

20 files changed

+42
-7
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package dotty.internal
2+
3+
import scala.quoted._
4+
5+
object CompileTimeMacros:
6+
def codeExpr(using qctx: QuoteContext)(sc: Expr[StringContext], args: Expr[Seq[Any]]): Expr[String] =
7+
(sc, args) match
8+
case (Expr.StringContext(Consts(parts)), Varargs(args2)) =>
9+
Expr(StringContext(parts: _*).s(args2.map(_.show): _*))
10+
case _ =>
11+
qctx.throwError("compiletime.code must be used as a string interpolator `code\"...\"`")

0 commit comments

Comments
 (0)