Skip to content

Commit 6c20869

Browse files
som-snytttgodzik
authored andcommitted
Remove obsolete unused options
1 parent fce6922 commit 6c20869

File tree

5 files changed

+19
-43
lines changed

5 files changed

+19
-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: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@ object CheckUnused:
639639
|| m.is(Synthetic)
640640
|| m.hasAnnotation(dd.UnusedAnnot) // param of unused method
641641
|| sym.owner.name.isContextFunction // a ubiquitous parameter
642-
|| sym.isCanEqual
643642
|| sym.info.dealias.typeSymbol.match // more ubiquity
644643
case dd.DummyImplicitClass | dd.SubTypeClass | dd.SameTypeClass => true
645644
case tps =>
@@ -671,7 +670,6 @@ object CheckUnused:
671670
def checkLocal(sym: Symbol, pos: SrcPos) =
672671
if ctx.settings.WunusedHas.locals
673672
&& !sym.is(InlineProxy)
674-
&& !sym.isCanEqual
675673
then
676674
if sym.is(Mutable) && infos.asss(sym) then
677675
warnAt(pos)(UnusedSymbol.localVars)
@@ -703,7 +701,9 @@ object CheckUnused:
703701
import scala.jdk.CollectionConverters.given
704702
import Rewrites.ActionPatch
705703
type ImpSel = (Import, ImportSelector)
706-
def isUsed(sel: ImportSelector): Boolean = infos.sels.containsKey(sel)
704+
// true if used or might be used, to imply don't warn about it
705+
def isUsable(imp: Import, sel: ImportSelector): Boolean =
706+
sel.isImportExclusion || infos.sels.containsKey(sel)
707707
def warnImport(warnable: ImpSel, actions: List[CodeAction] = Nil): Unit =
708708
val (imp, sel) = warnable
709709
val msg = UnusedSymbol.imports(actions)
@@ -978,8 +978,6 @@ object CheckUnused:
978978
def isSerializationSupport: Boolean =
979979
sym.is(Method) && serializationNames(sym.name.toTermName) && sym.owner.isClass
980980
&& sym.owner.derivesFrom(defn.JavaSerializableClass)
981-
def isCanEqual: Boolean =
982-
sym.isOneOf(GivenOrImplicit) && sym.info.finalResultType.baseClasses.exists(_.derivesFrom(defn.CanEqualClass))
983981
def isMarkerTrait: Boolean =
984982
sym.info.hiBound.resultType.allMembers.forall: d =>
985983
val m = d.symbol
@@ -1013,21 +1011,6 @@ object CheckUnused:
10131011
def isGeneratedByEnum: Boolean =
10141012
imp.symbol.exists && imp.symbol.owner.is(Enum, butNot = Case)
10151013

1016-
/** Under -Wunused:strict-no-implicit-warn, avoid false positives
1017-
* if this selector is a wildcard that might import implicits or
1018-
* specifically does import an implicit.
1019-
* Similarly, import of CanEqual must not warn, as it is always witness.
1020-
*/
1021-
def isLoose(sel: ImportSelector): Boolean =
1022-
if ctx.settings.WunusedHas.strictNoImplicitWarn then
1023-
if sel.isWildcard
1024-
|| imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit))
1025-
|| imp.expr.tpe.member(sel.name.toTypeName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit))
1026-
then return true
1027-
if sel.isWildcard && sel.isGiven
1028-
then imp.expr.tpe.allMembers.exists(_.symbol.isCanEqual)
1029-
else imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isCanEqual)
1030-
10311014
extension (pos: SrcPos)
10321015
def isZeroExtentSynthetic: Boolean = pos.span.isSynthetic && pos.span.isZeroExtent
10331016
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)