Skip to content

Commit 4c9066c

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

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,15 @@ 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

0 commit comments

Comments
 (0)