diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index a71fc3d40e92..b652a49c0381 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1410,29 +1410,6 @@ object desugar { FunctionWithMods(params, body, Modifiers(mods)) } - /** Add annotation to tree: - * tree @fullName - * - * The annotation is usually represented as a TypeTree referring to the class - * with the given name `fullName`. However, if the annotation matches a file name - * that is still to be entered, the annotation is represented as a cascade of `Selects` - * following `fullName`. This is necessary so that we avoid reading an annotation from - * the classpath that is also compiled from source. - */ - def makeAnnotated(fullName: String, tree: Tree)(using Context): Annotated = { - val parts = fullName.split('.') - val ttree = typerPhase match { - case phase: TyperPhase if phase.stillToBeEntered(parts.last) => - val prefix = - parts.init.foldLeft(Ident(nme.ROOTPKG): Tree)((qual, name) => - Select(qual, name.toTermName)) - Select(prefix, parts.last.toTypeName) - case _ => - TypeTree(requiredClass(fullName).typeRef) - } - Annotated(tree, New(ttree, Nil)) - } - private def derivedValDef(original: Tree, named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(using Context) = { val vdef = ValDef(named.name.asTermName, tpt, rhs) .withMods(mods) diff --git a/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala b/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala index bb1bfbea28e5..a8a2ff95687a 100644 --- a/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala +++ b/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala @@ -31,15 +31,6 @@ class TyperPhase(addRootImports: Boolean = true) extends Phase { override def allowsImplicitSearch: Boolean = true - /** The contexts for compilation units that are parsed but not yet entered */ - private var remaining: List[Context] = Nil - - /** Does a source file ending with `.scala` belong to a compilation unit - * that is parsed but not yet entered? - */ - def stillToBeEntered(name: String): Boolean = - remaining.exists(_.compilationUnit.toString.endsWith(name + ".scala")) - // Run regardless of parsing errors override def isRunnable(implicit ctx: Context): Boolean = true @@ -68,13 +59,6 @@ class TyperPhase(addRootImports: Boolean = true) extends Phase { JavaChecks.check(unit.tpdTree) } - - private def firstTopLevelDef(trees: List[tpd.Tree])(using Context): Symbol = trees match - case PackageDef(_, defs) :: _ => firstTopLevelDef(defs) - case Import(_, _) :: defs => firstTopLevelDef(defs) - case (tree @ TypeDef(_, _)) :: _ => tree.symbol - case _ => NoSymbol - protected def discardAfterTyper(unit: CompilationUnit)(using Context): Boolean = unit.isJava || unit.suspended @@ -89,11 +73,9 @@ class TyperPhase(addRootImports: Boolean = true) extends Phase { else newCtx - remaining = unitContexts - while remaining.nonEmpty do - enterSyms(using remaining.head) - remaining = remaining.tail - val firstXmlPos = ctx.base.parserPhase match { + unitContexts.foreach(enterSyms(using _)) + + ctx.base.parserPhase match { case p: ParserPhase => if p.firstXmlPos.exists && !defn.ScalaXmlPackageClass.exists then report.error(