diff --git a/compiler/src/dotty/tools/dotc/Compiler.scala b/compiler/src/dotty/tools/dotc/Compiler.scala index 1383017b0e2a..126e54a7b49e 100644 --- a/compiler/src/dotty/tools/dotc/Compiler.scala +++ b/compiler/src/dotty/tools/dotc/Compiler.scala @@ -35,10 +35,11 @@ class Compiler { protected def frontendPhases: List[List[Phase]] = List(new Parser) :: // Compiler frontend: scanner, parser List(new TyperPhase) :: // Compiler frontend: namer, typer + List(new CheckUnused.PostTyper) :: // Check for unused elements + List(new CheckShadowing) :: // Check shadowing elements List(new YCheckPositions) :: // YCheck positions List(new sbt.ExtractDependencies) :: // Sends information on classes' dependencies to sbt via callbacks List(new semanticdb.ExtractSemanticDB) :: // Extract info into .semanticdb files - List(new CheckUnused.PostTyper, new CheckShadowing) :: // Check for unused elements and shadowing elements List(new PostTyper) :: // Additional checks and cleanups after type checking List(new sjs.PrepJSInterop) :: // Additional checks and transformations for Scala.js (Scala.js only) List(new sbt.ExtractAPI) :: // Sends a representation of the API of classes to sbt via callbacks diff --git a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala index b6831b01e612..8b91ec690e4f 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala @@ -645,17 +645,6 @@ object CheckUnused: imp.expr.tpe.member(sel.name.toTypeName).alternatives.exists(_.symbol.isOneOf(GivenOrImplicit)) ) - /** Returns some inherited symbol with the same type and name as the given "symDecl" */ - private def lookForInheritedDecl(symDecl: Symbol)(using Context): Option[Symbol] = - val symDeclType = symDecl.info - val bClasses = symDecl.owner.info.baseClasses - bClasses match - case _ :: inherited => - inherited - .map(classSymbol => symDecl.denot.matchingDecl(classSymbol, symDeclType)) - .find(sym => sym.name == symDecl.name) - case Nil => - None extension (tree: ImportSelector) @@ -730,7 +719,7 @@ object CheckUnused: /** A function is overriden. Either has `override flags` or parent has a matching member (type and name) */ private def isOverriden(using Context): Boolean = - sym.is(Flags.Override) || lookForInheritedDecl(sym).isDefined + sym.is(Flags.Override) || (sym.exists && sym.owner.thisType.parents.exists(p => sym.matchingMember(p).exists)) end extension