File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,7 @@ class Compiler {
35
35
protected def frontendPhases : List [List [Phase ]] =
36
36
List (new Parser ) :: // Compiler frontend: scanner, parser
37
37
List (new TyperPhase ) :: // Compiler frontend: namer, typer
38
- List (new CheckUnused .PostTyper ) :: // Check for unused elements
39
- List (new CheckShadowing ) :: // Check for shadowing elements
38
+ List (new CheckShadowing , new CheckUnused .PostTyper ) :: // Check for unused elements // Check for shadowing elements
40
39
List (new YCheckPositions ) :: // YCheck positions
41
40
List (new sbt.ExtractDependencies ) :: // Sends information on classes' dependencies to sbt via callbacks
42
41
List (new semanticdb.ExtractSemanticDB ) :: // Extract info into .semanticdb files
Original file line number Diff line number Diff line change @@ -313,7 +313,6 @@ private sealed trait XSettings:
313
313
helpArg = " advanced warning" ,
314
314
descr = " Enable or disable specific `lint` warnings" ,
315
315
choices = List (
316
- ChoiceWithHelp (" nowarn" , " " ),
317
316
ChoiceWithHelp (" all" , " " ),
318
317
ChoiceWithHelp (" private-shadow" , " Warn if a private field or class parameter shadows a superclass field" ),
319
318
ChoiceWithHelp (" type-parameter-shadow" , " Warn when a type parameter shadows a type already in the scope" ),
@@ -322,10 +321,8 @@ private sealed trait XSettings:
322
321
)
323
322
324
323
object XlintHas :
325
- def isChoiceSet (s : String )(using Context ) = Xlint .value.pipe(us => us.contains(s))
326
- def allOr (s : String )(using Context ) = Xlint .value.pipe(us => us.contains(" all" ) || us.contains(s))
327
- def nowarn (using Context ) = allOr(" nowarn" )
328
-
324
+ def allOr (s : String )(using Context ) =
325
+ Xlint .value.pipe(us => us.contains(" all" ) || us.contains(s))
329
326
def privateShadow (using Context ) =
330
327
allOr(" private-shadow" )
331
328
def typeParameterShadow (using Context ) =
Original file line number Diff line number Diff line change @@ -645,6 +645,19 @@ object CheckUnused:
645
645
imp.expr.tpe.member(sel.name.toTypeName).alternatives.exists(_.symbol.isOneOf(GivenOrImplicit ))
646
646
)
647
647
648
+ /** Returns some inherited symbol with the same type and name as the given "symDecl" */
649
+ private def lookForInheritedDecl (symDecl : Symbol )(using Context ): Option [Symbol ] =
650
+ val symDeclType = symDecl.info
651
+ val bClasses = symDecl.owner.info.baseClasses
652
+ bClasses match
653
+ case _ :: inherited =>
654
+ inherited
655
+ .map(classSymbol => symDecl.denot.matchingDecl(classSymbol, symDeclType))
656
+ .find(sym => sym.name == symDecl.name)
657
+ case Nil =>
658
+ None
659
+
660
+
648
661
extension (tree : ImportSelector )
649
662
def boundTpe : Type = tree.bound match {
650
663
case untpd.TypedSplice (tree1) => tree1.tpe
@@ -719,8 +732,7 @@ object CheckUnused:
719
732
720
733
/** A function is overriden. Either has `override flags` or parent has a matching member (type and name) */
721
734
private def isOverriden (using Context ): Boolean =
722
- sym.is(Flags .Override ) ||
723
- (sym.exists && sym.owner.thisType.parents.exists(p => sym.matchingMember(p).exists))
735
+ sym.is(Flags .Override ) || lookForInheritedDecl(sym).isDefined
724
736
725
737
end extension
726
738
You can’t perform that action at this time.
0 commit comments