Skip to content

Commit e2701f8

Browse files
committed
Also check definitions inside package objects
# Conflicts: # compiler/src/dotty/tools/dotc/typer/Checking.scala
1 parent 00f77aa commit e2701f8

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -725,15 +725,20 @@ object Checking {
725725
* all statements are @experimental definitions.
726726
*/
727727
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 || stat.symbol.is(Synthetic)
731-
case _ => false
728+
def onlyExperimentalDefs(trees: List[Tree]): Boolean = trees.forall {
729+
case _: Import | EmptyTree =>
730+
true
731+
case tree @ TypeDef(_, impl: Template) if tree.symbol.isPackageObject =>
732+
onlyExperimentalDefs(impl.body)
733+
case stat: MemberDef =>
734+
stat.symbol.isExperimental || stat.symbol.is(Synthetic)
735+
case _ =>
736+
false
732737
}
733738
for case imp @ Import(qual, selectors) <- trees do
734739
languageImport(qual) match
735740
case Some(nme.experimental)
736-
if !ctx.owner.isInExperimentalScope && !onlyExperimentalDefs
741+
if !ctx.owner.isInExperimentalScope && !onlyExperimentalDefs(trees)
737742
&& selectors.exists(sel => experimental(sel.name) != scala2macros) =>
738743
checkExperimentalFeature("features", imp.srcPos)
739744
case _ =>

0 commit comments

Comments
 (0)