@@ -3222,21 +3222,23 @@ class Typer extends Namer
3222
3222
if ((inlined ne tree) && errorCount == ctx.reporter.errorCount) readaptSimplified(inlined)
3223
3223
else inlined
3224
3224
}
3225
+ else if tree.symbol.name == nme.f && tree.symbol == defn.StringContext_f then
3226
+ // To avoid forcing StringContext_f when compiling StingContex
3227
+ // we test the name before accession symbol StringContext_f.
3228
+
3229
+ // As scala.StringContext.f is defined in the standard library which
3230
+ // we currently do not bootstrap we cannot implement the macro in the library.
3231
+ // To overcome the current limitation we intercept the call and rewrite it into
3232
+ // a call to dotty.internal.StringContext.f which we can implement using the new macros.
3233
+ // As the macro is implemented in the bootstrapped library, it can only be used from the bootstrapped compiler.
3234
+ val Apply (TypeApply (Select (sc, _), _), args) = tree
3235
+ val newCall = ref(defn.InternalStringContextMacroModule_f ).appliedTo(sc).appliedToArgs(args).withSpan(tree.span)
3236
+ readaptSimplified(Inliner .inlineCall(newCall))
3225
3237
else if (tree.symbol.isScala2Macro &&
3226
3238
// raw and s are eliminated by the StringInterpolatorOpt phase
3227
3239
tree.symbol != defn.StringContext_raw &&
3228
3240
tree.symbol != defn.StringContext_s )
3229
- if (tree.symbol eq defn.StringContext_f ) {
3230
- // As scala.StringContext.f is defined in the standard library which
3231
- // we currently do not bootstrap we cannot implement the macro in the library.
3232
- // To overcome the current limitation we intercept the call and rewrite it into
3233
- // a call to dotty.internal.StringContext.f which we can implement using the new macros.
3234
- // As the macro is implemented in the bootstrapped library, it can only be used from the bootstrapped compiler.
3235
- val Apply (TypeApply (Select (sc, _), _), args) = tree
3236
- val newCall = ref(defn.InternalStringContextMacroModule_f ).appliedTo(sc).appliedToArgs(args).withSpan(tree.span)
3237
- readaptSimplified(Inliner .inlineCall(newCall))
3238
- }
3239
- else if (ctx.settings.XignoreScala2Macros .value) {
3241
+ if (ctx.settings.XignoreScala2Macros .value) {
3240
3242
report.warning(" Scala 2 macro cannot be used in Dotty, this call will crash at runtime. See https://dotty.epfl.ch/docs/reference/dropped-features/macros.html" , tree.sourcePos.startPos)
3241
3243
Throw (New (defn.MatchErrorClass .typeRef, Literal (Constant (s " Reached unexpanded Scala 2 macro call to ${tree.symbol.showFullName} compiled with -Xignore-scala2-macros. " )) :: Nil ))
3242
3244
.withType(tree.tpe)
0 commit comments