Skip to content

Commit 072f12a

Browse files
authored
Merge pull request #6766 from dotty-staging/fix-f-macro
Support f"" macro when -Xignore-scala2-macros is on
2 parents 54da006 + 5474dd4 commit 072f12a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,20 +2817,20 @@ class Typer extends Namer
28172817
readaptSimplified(Inliner.inlineCall(tree))
28182818
}
28192819
else if (tree.symbol.isScala2Macro) {
2820-
if (ctx.settings.XignoreScala2Macros.value) {
2821-
ctx.warning("Scala 2 macro cannot be used in Dotty, this call will crash at runtime. See http://dotty.epfl.ch/docs/reference/dropped-features/macros.html", tree.sourcePos.startPos)
2822-
Throw(New(defn.MatchErrorType, Literal(Constant(s"Reached unexpanded Scala 2 macro call to ${tree.symbol.showFullName} compiled with -Xignore-scala2-macros.")) :: Nil))
2823-
.withType(tree.tpe)
2824-
.withSpan(tree.span)
2825-
} else if (tree.symbol eq defn.StringContext_f) {
2820+
if (tree.symbol eq defn.StringContext_f) {
28262821
// As scala.StringContext.f is defined in the standard library which
2827-
// we currently do not bootstrap we cannot implement the macro the library.
2822+
// we currently do not bootstrap we cannot implement the macro in the library.
28282823
// To overcome the current limitation we intercept the call and rewrite it into
28292824
// a call to dotty.internal.StringContext.f which we can implement using the new macros.
28302825
// As the macro is implemented in the bootstrapped library, it can only be used from the bootstrapped compiler.
28312826
val Apply(TypeApply(Select(sc, _), _), args) = tree
28322827
val newCall = ref(defn.InternalStringContextMacroModule_f).appliedTo(sc).appliedToArgs(args)
28332828
readaptSimplified(Inliner.inlineCall(newCall))
2829+
} else if (ctx.settings.XignoreScala2Macros.value) {
2830+
ctx.warning("Scala 2 macro cannot be used in Dotty, this call will crash at runtime. See http://dotty.epfl.ch/docs/reference/dropped-features/macros.html", tree.sourcePos.startPos)
2831+
Throw(New(defn.MatchErrorType, Literal(Constant(s"Reached unexpanded Scala 2 macro call to ${tree.symbol.showFullName} compiled with -Xignore-scala2-macros.")) :: Nil))
2832+
.withType(tree.tpe)
2833+
.withSpan(tree.span)
28342834
} else {
28352835
ctx.error(
28362836
"""Scala 2 macro cannot be used in Dotty. See http://dotty.epfl.ch/docs/reference/dropped-features/macros.html\n"

0 commit comments

Comments
 (0)