Skip to content

Commit b1a0b1f

Browse files
som-snytttgodzik
authored andcommitted
Remove obsolete unused options
1 parent 92d1387 commit b1a0b1f

File tree

5 files changed

+18
-43
lines changed

5 files changed

+18
-43
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,6 @@ private sealed trait WarningSettings:
193193
ChoiceWithHelp("patvars","Warn if a variable bound in a pattern is unused"),
194194
//ChoiceWithHelp("inlined", "Apply -Wunused to inlined expansions"), // TODO
195195
ChoiceWithHelp("linted", "Enable -Wunused:imports,privates,locals,implicits"),
196-
ChoiceWithHelp(
197-
name = "strict-no-implicit-warn",
198-
description = """Same as -Wunused:imports, only for imports of explicit named members.
199-
|NOTE : This overrides -Wunused:imports and NOT set by -Wunused:all""".stripMargin
200-
),
201-
ChoiceWithHelp("unsafe-warn-patvars", "Deprecated alias for `patvars`"),
202196
),
203197
default = Nil
204198
)

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,6 @@ object CheckUnused:
568568
|| m.is(Synthetic)
569569
|| m.hasAnnotation(dd.UnusedAnnot) // param of unused method
570570
|| sym.owner.name.isContextFunction // a ubiquitous parameter
571-
|| sym.isCanEqual
572571
|| sym.info.dealias.typeSymbol.match // more ubiquity
573572
case dd.DummyImplicitClass | dd.SubTypeClass | dd.SameTypeClass => true
574573
case tps =>
@@ -600,7 +599,6 @@ object CheckUnused:
600599
def checkLocal(sym: Symbol, pos: SrcPos) =
601600
if ctx.settings.WunusedHas.locals
602601
&& !sym.is(InlineProxy)
603-
&& !sym.isCanEqual
604602
then
605603
if sym.is(Mutable) && infos.asss(sym) then
606604
warnAt(pos)(UnusedSymbol.localVars)
@@ -632,8 +630,9 @@ object CheckUnused:
632630
import scala.jdk.CollectionConverters.given
633631
import Rewrites.ActionPatch
634632
type ImpSel = (Import, ImportSelector)
633+
// true if used or might be used, to imply don't warn about it
635634
def isUsable(imp: Import, sel: ImportSelector): Boolean =
636-
sel.isImportExclusion || infos.sels.containsKey(sel) || imp.isLoose(sel)
635+
sel.isImportExclusion || infos.sels.containsKey(sel)
637636
def warnImport(warnable: ImpSel, actions: List[CodeAction] = Nil): Unit =
638637
val (imp, sel) = warnable
639638
val msg = UnusedSymbol.imports(actions)
@@ -908,8 +907,6 @@ object CheckUnused:
908907
def isSerializationSupport: Boolean =
909908
sym.is(Method) && serializationNames(sym.name.toTermName) && sym.owner.isClass
910909
&& sym.owner.derivesFrom(defn.JavaSerializableClass)
911-
def isCanEqual: Boolean =
912-
sym.isOneOf(GivenOrImplicit) && sym.info.finalResultType.baseClasses.exists(_.derivesFrom(defn.CanEqualClass))
913910
def isMarkerTrait: Boolean =
914911
sym.info.hiBound.resultType.allMembers.forall: d =>
915912
val m = d.symbol
@@ -949,21 +946,6 @@ object CheckUnused:
949946
def isGeneratedByEnum: Boolean =
950947
imp.symbol.exists && imp.symbol.owner.is(Enum, butNot = Case)
951948

952-
/** Under -Wunused:strict-no-implicit-warn, avoid false positives
953-
* if this selector is a wildcard that might import implicits or
954-
* specifically does import an implicit.
955-
* Similarly, import of CanEqual must not warn, as it is always witness.
956-
*/
957-
def isLoose(sel: ImportSelector): Boolean =
958-
if ctx.settings.WunusedHas.strictNoImplicitWarn then
959-
if sel.isWildcard
960-
|| imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit))
961-
|| imp.expr.tpe.member(sel.name.toTypeName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit))
962-
then return true
963-
if sel.isWildcard && sel.isGiven
964-
then imp.expr.tpe.allMembers.exists(_.symbol.isCanEqual)
965-
else imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isCanEqual)
966-
967949
extension (pos: SrcPos)
968950
def isZeroExtentSynthetic: Boolean = pos.span.isSynthetic && pos.span.isZeroExtent
969951
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:imports
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/pos/i17762.scala renamed to tests/warn/i17762.scala

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

33
class SomeType
44

@@ -16,6 +16,5 @@ object UsesCanEqual:
1616

1717
object UsesCanEqual2:
1818
import HasCanEqual.f
19-
2019
def testIt(st1: SomeType, st2: SomeType): Boolean =
21-
st1 == st2
20+
st1 != st2

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)