Skip to content

Commit e7eb6fd

Browse files
committed
Avoid failing with macros in the community build
1 parent 3f1cb8a commit e7eb6fd

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class ScalaSettings extends Settings.SettingGroup {
7676
val XreplLineWidth: Setting[Int] = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output", 390)
7777
val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.")
7878
val XverifySignatures: Setting[Boolean] = BooleanSetting("-Xverify-signatures", "Verify generic signatures in generated bytecode.")
79+
val XignoreScala2Macros: Setting[Boolean] = BooleanSetting("-Xignore-scala2-macros", "Ignore errors when compiling code that calls Scala2 macros, these will fail at runtime.")
7980

8081
val XmixinForceForwarders = ChoiceSetting(
8182
name = "-Xmixin-force-forwarders",

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,10 @@ class Typer extends Namer
26562656
readaptSimplified(Inliner.inlineCall(tree, pt))
26572657
}
26582658
else if (tree.symbol.is(Macro, butNot = Inline)) {
2659-
if (tree.symbol eq defn.StringContext_f) {
2659+
if (ctx.settings.XignoreScala2Macros.value) {
2660+
ctx.warning("Scala 2 macro cannot be used in Dotty. See http://dotty.epfl.ch/docs/reference/dropped-features/macros.html", tree.sourcePos)
2661+
tree
2662+
} else if (tree.symbol eq defn.StringContext_f) {
26602663
val Apply(TypeApply(Select(sc, _), _), args) = tree
26612664
val newCall = ref(defn.InternalStringContextModule_f).appliedTo(sc).appliedToArgs(args)
26622665
Inliner.inlineCall(newCall, pt)

0 commit comments

Comments
 (0)