Skip to content

Commit b6902b9

Browse files
committed
Macros are not experimental
1 parent c6f250a commit b6902b9

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ object Feature:
3636
Properties.experimental && !ctx.settings.YnoExperimental.value
3737

3838
def isExperimental(feature: TermName): Boolean =
39-
feature match
39+
feature != scala2macros && feature.match
4040
case QualifiedName(nme.experimental, _) => true
41-
case _ => true
41+
case _ => false
4242

4343
/** Is `feature` enabled by by a command-line setting? The enabling setting is
4444
*
@@ -117,7 +117,9 @@ object Feature:
117117
/** Check that experimental compiler options are only set for snapshot or nightly compiler versions. */
118118
def checkExperimentalFlags(using Context): Unit =
119119
if !experimentalEnabled then
120-
val features = ctx.settings.language.value.filter(_.contains(nme.experimental.toString))
120+
val features = ctx.settings.language.value.filter { feature =>
121+
feature.contains(nme.experimental.toString) && !feature.contains("macros")
122+
}
121123
if features.nonEmpty then
122124
report.error(
123125
experimentalWarningMessage +

compiler/src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ object StdNames {
520520
val longHash: N = "longHash"
521521
val macroThis : N = "_this"
522522
val macroContext : N = "c"
523+
val macros: N = "macros"
523524
val main: N = "main"
524525
val manifest: N = "manifest"
525526
val ManifestFactory: N = "ManifestFactory"

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3080,7 +3080,10 @@ object Parsers {
30803080
val imp = Import(tree, selectors)
30813081
if isLanguageImport(tree) then
30823082
in.languageImportContext = in.languageImportContext.importContext(imp, NoSymbol)
3083-
if isExperimentalImport(tree) && !Feature.experimentalEnabled then
3083+
if isExperimentalImport(tree)
3084+
&& !Feature.experimentalEnabled
3085+
&& selectors.exists(_.name != nme.macros)
3086+
then
30843087
report.error(Feature.experimentalWarningMessage, imp.srcPos)
30853088
for
30863089
case ImportSelector(id @ Ident(imported), EmptyTree, _) <- selectors

0 commit comments

Comments
 (0)