File tree 4 files changed +19
-11
lines changed
compiler/src/dotty/tools/dotc
tests/neg-custom-args/fatal-warnings
4 files changed +19
-11
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 @@ -312,7 +312,6 @@ private sealed trait XSettings:
312
312
helpArg = " advanced warning" ,
313
313
descr = " Enable or disable specific `lint` warnings" ,
314
314
choices = List (
315
- ChoiceWithHelp (" nowarn" , " " ),
316
315
ChoiceWithHelp (" all" , " " ),
317
316
ChoiceWithHelp (" private-shadow" , " Warn if a private field or class parameter shadows a superclass field" ),
318
317
ChoiceWithHelp (" type-parameter-shadow" , " Warn when a type parameter shadows a type already in the scope" ),
@@ -321,10 +320,8 @@ private sealed trait XSettings:
321
320
)
322
321
323
322
object XlintHas :
324
- def isChoiceSet (s : String )(using Context ) = Xlint .value.pipe(us => us.contains(s))
325
- def allOr (s : String )(using Context ) = Xlint .value.pipe(us => us.contains(" all" ) || us.contains(s))
326
- def nowarn (using Context ) = allOr(" nowarn" )
327
-
323
+ def allOr (s : String )(using Context ) =
324
+ Xlint .value.pipe(us => us.contains(" all" ) || us.contains(s))
328
325
def privateShadow (using Context ) =
329
326
allOr(" private-shadow" )
330
327
def typeParameterShadow (using Context ) =
Original file line number Diff line number Diff line change @@ -633,6 +633,19 @@ object CheckUnused:
633
633
imp.expr.tpe.member(sel.name.toTypeName).alternatives.exists(_.symbol.isOneOf(GivenOrImplicit ))
634
634
)
635
635
636
+ /** Returns some inherited symbol with the same type and name as the given "symDecl" */
637
+ private def lookForInheritedDecl (symDecl : Symbol )(using Context ): Option [Symbol ] =
638
+ val symDeclType = symDecl.info
639
+ val bClasses = symDecl.owner.info.baseClasses
640
+ bClasses match
641
+ case _ :: inherited =>
642
+ inherited
643
+ .map(classSymbol => symDecl.denot.matchingDecl(classSymbol, symDeclType))
644
+ .find(sym => sym.name == symDecl.name)
645
+ case Nil =>
646
+ None
647
+
648
+
636
649
extension (tree : ImportSelector )
637
650
def boundTpe : Type = tree.bound match {
638
651
case untpd.TypedSplice (tree1) => tree1.tpe
@@ -705,8 +718,7 @@ object CheckUnused:
705
718
706
719
/** A function is overriden. Either has `override flags` or parent has a matching member (type and name) */
707
720
private def isOverriden (using Context ): Boolean =
708
- sym.is(Flags .Override ) ||
709
- (sym.exists && sym.owner.thisType.parents.exists(p => sym.matchingMember(p).exists))
721
+ sym.is(Flags .Override ) || lookForInheritedDecl(sym).isDefined
710
722
711
723
end extension
712
724
Original file line number Diff line number Diff line change @@ -26,11 +26,11 @@ trait Bing
26
26
trait Accessors {
27
27
private var v1 : Int = 0 // error warn
28
28
private var v2 : Int = 0 // error warn, never set
29
- private var v3 : Int = 0 // warn, never got /Dotty: no warn even if not used
29
+ private var v3 : Int = 0
30
30
private var v4 : Int = 0 // no warn
31
31
32
32
private [this ] var v5 = 0 // error warn, never set
33
- private [this ] var v6 = 0 // warn, never got /Dotty: no warn even if not used
33
+ private [this ] var v6 = 0
34
34
private [this ] var v7 = 0 // no warn
35
35
36
36
def bippy (): Int = {
You can’t perform that action at this time.
0 commit comments