Skip to content

Commit

Permalink
Fix condition in checking if method is private in CHeckUnused
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-rd committed Apr 14, 2023
1 parent 799f225 commit abe1879
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke

override def prepareForDefDef(tree: tpd.DefDef)(using Context): Context =
unusedDataApply{ ud =>
if !tree.rawMods.is(Private) then
if !tree.symbol.is(Private) then
tree.termParamss.flatten.foreach { p =>
ud.addIgnoredParam(p.symbol)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/neg-custom-args/fatal-warnings/i15503e.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Foo {
private def f2(a: Int) = default_val // error
private def f3(a: Int)(using Int) = a // OK
private def f4(a: Int)(using Int) = default_val // error
private def f6(a: Int)(using Int) = summon[Int] // ok
private def f6(a: Int)(using Int) = summon[Int] // error
private def f7(a: Int)(using Int) = summon[Int] + a // OK
}

Expand Down Expand Up @@ -49,7 +49,7 @@ package foo.test.trivial:
private def f6(x: Int) = X // OK
private def f7(x: Int) = Y // OK
private def f8(x: Int): List[C] = Nil // OK
private def f9(x: Int): List[Int] = List(1,2,3,4) // ok
private def f9(x: Int): List[Int] = List(1,2,3,4) // error
private def foo:Int = 32 // OK
private def f77(x: Int) = foo // error
}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/fatal-warnings/i15503f.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Xd {
private def f2(a: Int) = 1 // OK
private def f3(a: Int)(using Int) = a // OK
private def f4(a: Int)(using Int) = default_int // OK
private def f6(a: Int)(using Int) = summon[Int] // OK
private def f6(a: Int)(using Int) = summon[Int] // error
private def f7(a: Int)(using Int) = summon[Int] + a // OK
private def f8(a: Int)(using foo: Int) = a // error
}
2 changes: 1 addition & 1 deletion tests/neg-custom-args/fatal-warnings/i15503g.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Foo {
private def f2(a: Int) = default_int // error
private def f3(a: Int)(using Int) = a // OK
private def f4(a: Int)(using Int) = default_int // error
private def f6(a: Int)(using Int) = summon[Int] // ok
private def f6(a: Int)(using Int) = summon[Int] // error
private def f7(a: Int)(using Int) = summon[Int] + a // OK
/* --- Trivial method check --- */
private def g1(x: Int) = 1 // OK
Expand Down

0 comments on commit abe1879

Please sign in to comment.