Skip to content

Commit 48b66ef

Browse files
committed
Avoid failing with macros in the community build
1 parent 70de4ec commit 48b66ef

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
@@ -77,6 +77,7 @@ class ScalaSettings extends Settings.SettingGroup {
7777
val XreplLineWidth: Setting[Int] = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output", 390)
7878
val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.")
7979
val XverifySignatures: Setting[Boolean] = BooleanSetting("-Xverify-signatures", "Verify generic signatures in generated bytecode.")
80+
val XignoreScala2Macros: Setting[Boolean] = BooleanSetting("-Xignore-scala2-macros", "Ignore errors when compiling code that calls Scala2 macros, these will fail at runtime.")
8081

8182
val XmixinForceForwarders = ChoiceSetting(
8283
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
@@ -2754,7 +2754,10 @@ class Typer extends Namer
27542754
readaptSimplified(Inliner.inlineCall(tree, pt))
27552755
}
27562756
else if (tree.symbol.is(Macro, butNot = Inline)) {
2757-
if (tree.symbol eq defn.StringContext_f) {
2757+
if (ctx.settings.XignoreScala2Macros.value) {
2758+
ctx.warning("Scala 2 macro cannot be used in Dotty. See http://dotty.epfl.ch/docs/reference/dropped-features/macros.html", tree.sourcePos)
2759+
tree
2760+
} else if (tree.symbol eq defn.StringContext_f) {
27582761
val Apply(TypeApply(Select(sc, _), _), args) = tree
27592762
val newCall = ref(defn.InternalStringContextModule_f).appliedTo(sc).appliedToArgs(args)
27602763
Inliner.inlineCall(newCall, pt)

0 commit comments

Comments
 (0)