Skip to content

Commit a57d148

Browse files
committed
Remove obsolete unused options
1 parent aea22ab commit a57d148

File tree

4 files changed

+16
-40
lines changed

4 files changed

+16
-40
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ private sealed trait WarningSettings:
185185
ChoiceWithHelp("patvars","Warn if a variable bound in a pattern is unused"),
186186
//ChoiceWithHelp("inlined", "Apply -Wunused to inlined expansions"), // TODO
187187
ChoiceWithHelp("linted", "Enable -Wunused:imports,privates,locals,implicits"),
188-
ChoiceWithHelp(
189-
name = "strict-no-implicit-warn",
190-
description = """Same as -Wunused:imports, only for imports of explicit named members.
191-
|NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all""".stripMargin
192-
),
193-
ChoiceWithHelp("unsafe-warn-patvars", "Deprecated alias for `patvars`"),
194188
),
195189
default = Nil
196190
)

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ object CheckUnused:
600600
|| m.is(Synthetic)
601601
|| m.hasAnnotation(dd.UnusedAnnot) // param of unused method
602602
|| sym.name.is(ContextFunctionParamName) // a ubiquitous parameter
603-
|| sym.isCanEqual
604603
|| sym.info.dealias.typeSymbol.match // more ubiquity
605604
case dd.DummyImplicitClass | dd.SubTypeClass | dd.SameTypeClass => true
606605
case tps =>
@@ -632,7 +631,6 @@ object CheckUnused:
632631
def checkLocal(sym: Symbol, pos: SrcPos) =
633632
if ctx.settings.WunusedHas.locals
634633
&& !sym.is(InlineProxy)
635-
&& !sym.isCanEqual
636634
then
637635
if sym.is(Mutable) && infos.asss(sym) then
638636
warnAt(pos)(UnusedSymbol.localVars)
@@ -664,8 +662,9 @@ object CheckUnused:
664662
import scala.jdk.CollectionConverters.given
665663
import Rewrites.ActionPatch
666664
type ImpSel = (Import, ImportSelector)
665+
// true if used or might be used, to imply don't warn about it
667666
def isUsable(imp: Import, sel: ImportSelector): Boolean =
668-
sel.isImportExclusion || infos.sels.containsKey(sel) || imp.isLoose(sel)
667+
sel.isImportExclusion || infos.sels.containsKey(sel)
669668
def warnImport(warnable: ImpSel, actions: List[CodeAction] = Nil): Unit =
670669
val (imp, sel) = warnable
671670
val msg = UnusedSymbol.imports(actions)
@@ -940,8 +939,6 @@ object CheckUnused:
940939
def isSerializationSupport: Boolean =
941940
sym.is(Method) && serializationNames(sym.name.toTermName) && sym.owner.isClass
942941
&& sym.owner.derivesFrom(defn.JavaSerializableClass)
943-
def isCanEqual: Boolean =
944-
sym.isOneOf(GivenOrImplicit) && sym.info.finalResultType.baseClasses.exists(_.derivesFrom(defn.CanEqualClass))
945942
def isMarkerTrait: Boolean =
946943
sym.info.hiBound.resultType.allMembers.forall: d =>
947944
val m = d.symbol
@@ -981,21 +978,6 @@ object CheckUnused:
981978
def isGeneratedByEnum: Boolean =
982979
imp.symbol.exists && imp.symbol.owner.is(Enum, butNot = Case)
983980

984-
/** Under -Wunused:strict-no-implicit-warn, avoid false positives
985-
* if this selector is a wildcard that might import implicits or
986-
* specifically does import an implicit.
987-
* Similarly, import of CanEqual must not warn, as it is always witness.
988-
*/
989-
def isLoose(sel: ImportSelector): Boolean =
990-
if ctx.settings.WunusedHas.strictNoImplicitWarn then
991-
if sel.isWildcard
992-
|| imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit))
993-
|| imp.expr.tpe.member(sel.name.toTypeName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit))
994-
then return true
995-
if sel.isWildcard && sel.isGiven
996-
then imp.expr.tpe.allMembers.exists(_.symbol.isCanEqual)
997-
else imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isCanEqual)
998-
999981
extension (pos: SrcPos)
1000982
def isZeroExtentSynthetic: Boolean = pos.span.isSynthetic && pos.span.isZeroExtent
1001983
def isSynthetic: Boolean = pos.span.isSynthetic && pos.span.exists

tests/warn/i15503j.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Wunused:strict-no-implicit-warn
1+
///> using options -Wunused:strict-no-implicit-warn
22

33
package foo.unused.strict.test:
44
package a:
@@ -7,15 +7,15 @@ package foo.unused.strict.test:
77
val z: Int = 2
88
def f: Int = 3
99
package b:
10-
import a.given // OK
11-
import a._ // OK
12-
import a.* // OK
13-
import a.x // OK
14-
import a.y // OK
10+
import a.given // warn
11+
import a._ // warn
12+
import a.* // warn
13+
import a.x // warn
14+
import a.y // warn
1515
import a.z // warn
1616
import a.f // warn
1717
package c:
18-
import a.given // OK
18+
import a.given // warn
1919
import a.x // OK
2020
import a.y // OK
2121
import a.z // OK
@@ -28,8 +28,8 @@ package foo.implicits.resolution:
2828
object A { implicit val x: X = new X }
2929
object B { implicit val y: Y = new Y }
3030
class C {
31-
import A._ // OK
32-
import B._ // OK
31+
import A.given // warn
32+
import B.given // OK
3333
def t = implicitly[X]
3434
}
3535

@@ -44,7 +44,7 @@ package foo.unused.summon.inlines:
4444
given willBeUsed: (A & B) = new A with B {}
4545

4646
package use:
47-
import lib.{A, B, C, willBeUnused, willBeUsed} //OK
47+
import lib.{A, B, C, willBeUnused, willBeUsed} // warn
4848
import compiletime.summonInline //OK
4949

5050
transparent inline given conflictInside: C =
@@ -56,4 +56,4 @@ package foo.unused.summon.inlines:
5656
???
5757

5858
val b: B = summon[B]
59-
val c: C = summon[C]
59+
val c: C = summon[C]

tests/warn/unused-can-equal.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
2-
//> using options -Werror -Wunused:all
1+
//> using options -Wunused:all
32

43
import scala.language.strictEquality
54

65
class Box[T](x: T) derives CanEqual:
76
def y = x
87

98
def f[A, B](a: A, b: B)(using CanEqual[A, B]) = a == b // no warn
9+
def z[A, B](a: A, b: B)(using ce: CanEqual[A, B]) = a.toString == b.toString // no warn
1010

1111
def g =
12-
import Box.given // no warn
12+
import Box.given // warn
1313
"42".length
1414

1515
@main def test() = println:

0 commit comments

Comments
 (0)