File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ object Feature:
60
60
def dependentEnabled (using Context ) =
61
61
enabled(nme.dependent, defn.LanguageExperimentalModule .moduleClass)
62
62
63
+ def scala2ExperimentalMacroEnabled (using Context ) =
64
+ enabled(" macros" .toTermName, defn.LanguageExperimentalModule .moduleClass)
65
+
63
66
def sourceVersionSetting (using Context ): SourceVersion =
64
67
SourceVersion .valueOf(ctx.settings.source.value)
65
68
Original file line number Diff line number Diff line change @@ -3581,6 +3581,13 @@ class Typer extends Namer
3581
3581
}
3582
3582
}
3583
3583
if ctx.phase.isTyper then
3584
+ if ! config.Feature .scala2ExperimentalMacroEnabled then
3585
+ ctx.error(
3586
+ """ Scala 2 macro definition needs to be enabled
3587
+ |by making the implicit value scala.language.experimental.macros visible.
3588
+ |This can be achieved by adding the import clause 'import scala.language.experimental.macros'
3589
+ |or by setting the compiler option -language:experimental.macros.
3590
+ """ .stripMargin, call.sourcePos)
3584
3591
call match
3585
3592
case call : untpd.Ident =>
3586
3593
typedIdent(call, defn.AnyType )
Original file line number Diff line number Diff line change
1
+ object FooMacros {
2
+ def foo [T ]: String = macro Foo .fooImpl[T ] // error: Scala 2 macro definition needs to be enabled
3
+ }
Original file line number Diff line number Diff line change
1
+ import scala .language .experimental .macros
1
2
class A {
2
3
def foo : Int = macro ???
3
4
inline def foo : Int = ???
You can’t perform that action at this time.
0 commit comments