From 799f22592a88546780691207d16c07c243b6a6c9 Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Fri, 14 Apr 2023 12:58:37 +0200 Subject: [PATCH 1/4] Fix failing main due to wunused --- tests/neg-custom-args/fatal-warnings/i15503e.scala | 4 ++-- tests/neg-custom-args/fatal-warnings/i15503g.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/neg-custom-args/fatal-warnings/i15503e.scala b/tests/neg-custom-args/fatal-warnings/i15503e.scala index 57664cd08dcd..b1b2e73d51a8 100644 --- a/tests/neg-custom-args/fatal-warnings/i15503e.scala +++ b/tests/neg-custom-args/fatal-warnings/i15503e.scala @@ -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] // error + private def f6(a: Int)(using Int) = summon[Int] // ok private def f7(a: Int)(using Int) = summon[Int] + a // OK } @@ -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) // error + private def f9(x: Int): List[Int] = List(1,2,3,4) // ok private def foo:Int = 32 // OK private def f77(x: Int) = foo // error } diff --git a/tests/neg-custom-args/fatal-warnings/i15503g.scala b/tests/neg-custom-args/fatal-warnings/i15503g.scala index 2185bfed711d..da2921351519 100644 --- a/tests/neg-custom-args/fatal-warnings/i15503g.scala +++ b/tests/neg-custom-args/fatal-warnings/i15503g.scala @@ -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] // error + private def f6(a: Int)(using Int) = summon[Int] // ok private def f7(a: Int)(using Int) = summon[Int] + a // OK /* --- Trivial method check --- */ private def g1(x: Int) = 1 // OK From abe1879401d109b19907224fb489b10ce860b788 Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Fri, 14 Apr 2023 14:11:20 +0200 Subject: [PATCH 2/4] Fix condition in checking if method is private in CHeckUnused --- compiler/src/dotty/tools/dotc/transform/CheckUnused.scala | 2 +- tests/neg-custom-args/fatal-warnings/i15503e.scala | 4 ++-- tests/neg-custom-args/fatal-warnings/i15503f.scala | 2 +- tests/neg-custom-args/fatal-warnings/i15503g.scala | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala index df916fc76a3b..ce05e6c125de 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala @@ -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) } diff --git a/tests/neg-custom-args/fatal-warnings/i15503e.scala b/tests/neg-custom-args/fatal-warnings/i15503e.scala index b1b2e73d51a8..57664cd08dcd 100644 --- a/tests/neg-custom-args/fatal-warnings/i15503e.scala +++ b/tests/neg-custom-args/fatal-warnings/i15503e.scala @@ -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 } @@ -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 } diff --git a/tests/neg-custom-args/fatal-warnings/i15503f.scala b/tests/neg-custom-args/fatal-warnings/i15503f.scala index f909272af732..1dc16283caa8 100644 --- a/tests/neg-custom-args/fatal-warnings/i15503f.scala +++ b/tests/neg-custom-args/fatal-warnings/i15503f.scala @@ -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 } diff --git a/tests/neg-custom-args/fatal-warnings/i15503g.scala b/tests/neg-custom-args/fatal-warnings/i15503g.scala index da2921351519..2185bfed711d 100644 --- a/tests/neg-custom-args/fatal-warnings/i15503g.scala +++ b/tests/neg-custom-args/fatal-warnings/i15503g.scala @@ -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 From ffa268222a3c989229731cf33e901a2c9cc4edab Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Fri, 14 Apr 2023 18:14:51 +0200 Subject: [PATCH 3/4] Remove unnecessary test --- tests/neg-custom-args/fatal-warnings/i15503i.scala | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/neg-custom-args/fatal-warnings/i15503i.scala b/tests/neg-custom-args/fatal-warnings/i15503i.scala index 3b653bfadb0a..fefead7f01a3 100644 --- a/tests/neg-custom-args/fatal-warnings/i15503i.scala +++ b/tests/neg-custom-args/fatal-warnings/i15503i.scala @@ -46,9 +46,6 @@ package foo.test.scala.annotation: def a1(a: Int) = a // OK def a2(a: Int) = default_int // ok - private def a2_p(a: Int) = default_int // error - def a2_p_used = a2_p(3) - def a3(@unused a: Int) = default_int //OK def b1 = From 8fdd8d61e6ee9a22f1be7698813d55f37064950b Mon Sep 17 00:00:00 2001 From: Simon R Date: Sat, 15 Apr 2023 11:25:17 +0200 Subject: [PATCH 4/4] Adjust failing expectation in WUnused tests --- tests/neg-custom-args/fatal-warnings/i15503f.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/neg-custom-args/fatal-warnings/i15503f.scala b/tests/neg-custom-args/fatal-warnings/i15503f.scala index 1dc16283caa8..f909272af732 100644 --- a/tests/neg-custom-args/fatal-warnings/i15503f.scala +++ b/tests/neg-custom-args/fatal-warnings/i15503f.scala @@ -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] // error + private def f6(a: Int)(using Int) = summon[Int] // OK private def f7(a: Int)(using Int) = summon[Int] + a // OK private def f8(a: Int)(using foo: Int) = a // error }