Skip to content

Commit abe1879

Browse files
committed
Fix condition in checking if method is private in CHeckUnused
1 parent 799f225 commit abe1879

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
118118

119119
override def prepareForDefDef(tree: tpd.DefDef)(using Context): Context =
120120
unusedDataApply{ ud =>
121-
if !tree.rawMods.is(Private) then
121+
if !tree.symbol.is(Private) then
122122
tree.termParamss.flatten.foreach { p =>
123123
ud.addIgnoredParam(p.symbol)
124124
}

tests/neg-custom-args/fatal-warnings/i15503e.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Foo {
88
private def f2(a: Int) = default_val // error
99
private def f3(a: Int)(using Int) = a // OK
1010
private def f4(a: Int)(using Int) = default_val // error
11-
private def f6(a: Int)(using Int) = summon[Int] // ok
11+
private def f6(a: Int)(using Int) = summon[Int] // error
1212
private def f7(a: Int)(using Int) = summon[Int] + a // OK
1313
}
1414

@@ -49,7 +49,7 @@ package foo.test.trivial:
4949
private def f6(x: Int) = X // OK
5050
private def f7(x: Int) = Y // OK
5151
private def f8(x: Int): List[C] = Nil // OK
52-
private def f9(x: Int): List[Int] = List(1,2,3,4) // ok
52+
private def f9(x: Int): List[Int] = List(1,2,3,4) // error
5353
private def foo:Int = 32 // OK
5454
private def f77(x: Int) = foo // error
5555
}

tests/neg-custom-args/fatal-warnings/i15503f.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Xd {
88
private def f2(a: Int) = 1 // OK
99
private def f3(a: Int)(using Int) = a // OK
1010
private def f4(a: Int)(using Int) = default_int // OK
11-
private def f6(a: Int)(using Int) = summon[Int] // OK
11+
private def f6(a: Int)(using Int) = summon[Int] // error
1212
private def f7(a: Int)(using Int) = summon[Int] + a // OK
1313
private def f8(a: Int)(using foo: Int) = a // error
1414
}

tests/neg-custom-args/fatal-warnings/i15503g.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Foo {
88
private def f2(a: Int) = default_int // error
99
private def f3(a: Int)(using Int) = a // OK
1010
private def f4(a: Int)(using Int) = default_int // error
11-
private def f6(a: Int)(using Int) = summon[Int] // ok
11+
private def f6(a: Int)(using Int) = summon[Int] // error
1212
private def f7(a: Int)(using Int) = summon[Int] + a // OK
1313
/* --- Trivial method check --- */
1414
private def g1(x: Int) = 1 // OK

0 commit comments

Comments
 (0)