File tree 2 files changed +20
-21
lines changed
compiler/src/dotty/tools/dotc
2 files changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -449,30 +449,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
449
449
throw ex
450
450
}
451
451
452
- /** In addition to normal processing, check that experimental language
453
- * imports are done only in experimental scopes, or in scopes where
454
- * all statements are @experimental definitions.
455
- */
456
452
override def transformStats (trees : List [Tree ], exprOwner : Symbol )(using Context ): List [Tree ] =
457
453
458
- def onlyExperimentalDefs = trees.forall {
459
- case _ : Import | EmptyTree => true
460
- case stat : MemberDef => stat.symbol.isExperimental
461
- case _ => false
462
- }
463
-
464
- def checkExperimentalImports =
465
- for case imp @ Import (qual, selectors) <- trees do
466
- languageImport(qual) match
467
- case Some (nme.experimental)
468
- if ! ctx.owner.isInExperimentalScope && ! onlyExperimentalDefs
469
- && selectors.exists(sel => Feature .experimental(sel.name) != Feature .scala2macros) =>
470
- Feature .checkExperimentalFeature(" features" , imp.srcPos)
471
- case _ =>
472
-
473
454
try super .transformStats(trees, exprOwner)
474
- finally checkExperimentalImports
475
- end transformStats
455
+ finally Checking .checkExperimentalImports(trees)
476
456
477
457
/** Transforms the rhs tree into a its default tree if it is in an `erased` val/def.
478
458
* Performed to shrink the tree that is known to be erased later.
Original file line number Diff line number Diff line change @@ -719,6 +719,24 @@ object Checking {
719
719
checkValue(tree)
720
720
case _ =>
721
721
tree
722
+
723
+ /** Check that experimental language imports in `trees`
724
+ * are done only in experimental scopes, or in scopes where
725
+ * all statements are @experimental definitions.
726
+ */
727
+ def checkExperimentalImports (trees : List [Tree ])(using Context ): Unit =
728
+ def onlyExperimentalDefs = trees.forall {
729
+ case _ : Import | EmptyTree => true
730
+ case stat : MemberDef => stat.symbol.isExperimental
731
+ case _ => false
732
+ }
733
+ for case imp @ Import (qual, selectors) <- trees do
734
+ languageImport(qual) match
735
+ case Some (nme.experimental)
736
+ if ! ctx.owner.isInExperimentalScope && ! onlyExperimentalDefs
737
+ && selectors.exists(sel => experimental(sel.name) != scala2macros) =>
738
+ checkExperimentalFeature(" features" , imp.srcPos)
739
+ case _ =>
722
740
}
723
741
724
742
trait Checking {
@@ -830,6 +848,7 @@ trait Checking {
830
848
em " Implementation restriction: ${path.tpe.classSymbol} is not a valid prefix " +
831
849
" for a wildcard export, as it is a package." , path.srcPos)
832
850
851
+
833
852
/** Check that module `sym` does not clash with a class of the same name
834
853
* that is concurrently compiled in another source file.
835
854
*/
You can’t perform that action at this time.
0 commit comments