From 8b8bb339494d4d8bdc7be4163b89be8b2e0edd54 Mon Sep 17 00:00:00 2001 From: Jan Chyb Date: Fri, 25 Oct 2024 17:29:27 +0200 Subject: [PATCH] Address review comments --- .../src/dotty/tools/dotc/typer/Checking.scala | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 3561224679fb..b4abd35c765e 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -804,23 +804,22 @@ object Checking { * */ def checkAndAdaptExperimentalImports(trees: List[Tree])(using Context): Unit = - def nonExperimentalTopLevelDefs(): Iterator[Symbol] = + def nonExperimentalTopLevelDefs(): List[Symbol] = new TreeAccumulator[List[Symbol]] { override def apply(x: List[Symbol], tree: tpd.Tree)(using Context): List[Symbol] = - def addIfExperimental(sym: Symbol) = - if !sym.isExperimental then sym :: x - else x - tree match { - case tpd.PackageDef(_, contents) => - super.apply(x, contents) - case defdef: tpd.DefDef => addIfExperimental(defdef.symbol) - case valdef: tpd.ValDef => addIfExperimental(valdef.symbol) - case typeDef @ tpd.TypeDef(_, temp: Template) if typeDef.symbol.isPackageObject => - super.apply(x, temp.body) - case typeDef @ tpd.TypeDef(_, Template(_, _, _, _)) => addIfExperimental(typeDef.symbol) - case _ => x - } - }.apply(Nil, ctx.compilationUnit.tpdTree).iterator + def addIfNotExperimental(sym: Symbol) = + println(sym) + if !sym.isExperimental then sym :: x + else x + tree match { + case tpd.PackageDef(_, contents) => apply(x, contents) + case typeDef @ tpd.TypeDef(_, temp: Template) if typeDef.symbol.isPackageObject => + apply(x, temp.body) + case mdef: tpd.ValDef if mdef.symbol.isPackageObject => x // ValDef(new PackageObject) + case mdef: tpd.MemberDef => addIfNotExperimental(mdef.symbol) + case _ => x + } + }.apply(Nil, ctx.compilationUnit.tpdTree) def unitExperimentalLanguageImports = def isAllowedImport(sel: untpd.ImportSelector) =