@@ -804,23 +804,21 @@ object Checking {
804804 *
805805 */
806806 def checkAndAdaptExperimentalImports (trees : List [Tree ])(using Context ): Unit =
807- def nonExperimentalTopLevelDefs (): Iterator [Symbol ] =
807+ def nonExperimentalTopLevelDefs (): List [Symbol ] =
808808 new TreeAccumulator [List [Symbol ]] {
809809 override def apply (x : List [Symbol ], tree : tpd.Tree )(using Context ): List [Symbol ] =
810- def addIfExperimental (sym : Symbol ) =
811- if ! sym.isExperimental then sym :: x
812- else x
813- tree match {
814- case tpd.PackageDef (_, contents) =>
815- super .apply(x, contents)
816- case defdef : tpd.DefDef => addIfExperimental(defdef.symbol)
817- case valdef : tpd.ValDef => addIfExperimental(valdef.symbol)
818- case typeDef @ tpd.TypeDef (_, temp : Template ) if typeDef.symbol.isPackageObject =>
819- super .apply(x, temp.body)
820- case typeDef @ tpd.TypeDef (_, Template (_, _, _, _)) => addIfExperimental(typeDef.symbol)
821- case _ => x
822- }
823- }.apply(Nil , ctx.compilationUnit.tpdTree).iterator
810+ def addIfNotExperimental (sym : Symbol ) =
811+ if ! sym.isExperimental then sym :: x
812+ else x
813+ tree match {
814+ case tpd.PackageDef (_, contents) => apply(x, contents)
815+ case typeDef @ tpd.TypeDef (_, temp : Template ) if typeDef.symbol.isPackageObject =>
816+ apply(x, temp.body)
817+ case vdef : tpd.ValDef if vdef.symbol.isPackageObject => x // ValDef(new PackageObject)
818+ case mdef : tpd.MemberDef => addIfNotExperimental(mdef.symbol)
819+ case _ => x
820+ }
821+ }.apply(Nil , ctx.compilationUnit.tpdTree)
824822
825823 def unitExperimentalLanguageImports =
826824 def isAllowedImport (sel : untpd.ImportSelector ) =
0 commit comments