Skip to content

Commit 1cd4636

Browse files
committed
Adjust duplicate test, don't forgive anonfun
1 parent 90f06c5 commit 1cd4636

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ object CheckUnused:
473473
def forgiven =
474474
val dd = defn
475475
m.isDeprecated
476-
|| m.is(Synthetic)
476+
|| m.is(Synthetic) && !m.isAnonymousFunction
477477
|| m.hasAnnotation(defn.UnusedAnnot) // param of unused method
478478
|| sym.info.isSingleton
479479
|| m.isConstructor && m.owner.thisType.baseClasses.contains(defn.AnnotationClass)

tests/warn/i16639a.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class B3(msg0: String) extends A("msg") // warn /Dotty: unused explicit paramete
2424
trait Bing
2525

2626
trait Accessors {
27-
private var v1: Int = 0 // warn warn
28-
private var v2: Int = 0 // warn warn, never set
29-
private var v3: Int = 0
27+
private var v1: Int = 0 // warn
28+
private var v2: Int = 0 // warn, never set
29+
private var v3: Int = 0 // warn, never got
3030
private var v4: Int = 0 // no warn
3131

32-
private[this] var v5 = 0 // warn warn, never set
33-
private[this] var v6 = 0
32+
private[this] var v5 = 0 // warn, never set
33+
private[this] var v6 = 0 // warn, never got
3434
private[this] var v7 = 0 // no warn
3535

3636
def bippy(): Int = {
@@ -43,13 +43,13 @@ trait Accessors {
4343
}
4444

4545
class StableAccessors {
46-
private var s1: Int = 0 // warn warn
47-
private var s2: Int = 0 // warn warn, never set
48-
private var s3: Int = 0
46+
private var s1: Int = 0 // warn
47+
private var s2: Int = 0 // warn, never set
48+
private var s3: Int = 0 // warn, never got
4949
private var s4: Int = 0 // no warn
5050

51-
private[this] var s5 = 0 // warn warn, never set
52-
private[this] var s6 = 0 // no warn, limitation /Dotty: Why limitation ?
51+
private[this] var s5 = 0 // warn, never set
52+
private[this] var s6 = 0 // warn, never got
5353
private[this] var s7 = 0 // no warn
5454

5555
def bippy(): Int = {
@@ -62,7 +62,7 @@ class StableAccessors {
6262
}
6363

6464
trait DefaultArgs {
65-
private def bippy(x1: Int, x2: Int = 10, x3: Int = 15): Int = x1 + x2 + x3 // no more warn warn since #17061
65+
private def bippy(x1: Int, x2: Int = 10, x3: Int = 15): Int = x1 + x2 + x3 // warn // warn
6666

6767
def boppy() = bippy(5, 100, 200)
6868
}
@@ -124,9 +124,9 @@ trait Underwarn {
124124
}
125125

126126
class OtherNames {
127-
private def x_=(i: Int): Unit = () // no more warn since #17061
128-
private def x: Int = 42 // warn Dotty triggers unused private member : To investigate
129-
private def y_=(i: Int): Unit = () // // no more warn since #17061
127+
private def x_=(i: Int): Unit = () // warn
128+
private def x: Int = 42 // warn
129+
private def y_=(i: Int): Unit = () // warn
130130
private def y: Int = 42
131131

132132
def f = y
@@ -145,7 +145,7 @@ trait Forever {
145145
val t = Option((17, 42))
146146
for {
147147
ns <- t
148-
(i, j) = ns // no warn
148+
(i, j) = ns // warn // warn -Wunused:patvars is in -Wunused:all
149149
} yield 42 // val emitted only if needed, hence nothing unused
150150
}
151151
}
@@ -158,22 +158,22 @@ trait CaseyKasem {
158158
def f = 42 match {
159159
case x if x < 25 => "no warn"
160160
case y if toString.nonEmpty => "no warn" + y
161-
case z => "warn"
161+
case z => "warn" // warn patvar
162162
}
163163
}
164164
trait CaseyAtTheBat {
165165
def f = Option(42) match {
166166
case Some(x) if x < 25 => "no warn"
167-
case Some(y @ _) if toString.nonEmpty => "no warn"
168-
case Some(z) => "warn"
167+
case Some(y @ _) if toString.nonEmpty => "no warn" // warn todo whether to use name @ _ to suppress
168+
case Some(z) => "warn" // warn patvar
169169
case None => "no warn"
170170
}
171171
}
172172

173173
class `not even using companion privates`
174174

175175
object `not even using companion privates` {
176-
private implicit class `for your eyes only`(i: Int) { // no more warn since #17061
176+
private implicit class `for your eyes only`(i: Int) { // warn
177177
def f = i
178178
}
179179
}

tests/warn/unused-privates.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ trait CaseyAtTheBat {
209209
class `not even using companion privates`
210210

211211
object `not even using companion privates` {
212-
private implicit class `for your eyes only`(i: Int) { // warn no warn deprecated feature TODO
212+
private implicit class `for your eyes only`(i: Int) { // warn
213213
def f = i
214214
}
215215
}

0 commit comments

Comments
 (0)