Skip to content

Commit 22f09a4

Browse files
committed
fix UnusedScalafixSuppression warnings on Scala 3 scalafix invocations
Since ExplicitResultTypes is unavailable in Scala 3, some silencers are rightfully detected as unused for that invocation. Qualifying these silencers by suffixing ExplicitResultTypes does not help, since EscapeHatch is not aware of which rules are executed, so we need to address the problem differently. - For the (v0) signature, this removes the silencer to be explicit about the type since there is no reason (except compatibility) to keep it this way. Since this is the old API and a very specific class, it's unlikely that will will cause linking errors when running community rules with existing versions. - For test suites where we DO want an explicit type, this turns private the terms that ExplicitResultTypes warns on to stop triggering it. However, this triggers RemoveUnused, but since it is now common to both Scala 2 and Scala 3 and, it does not trigger UnusedScalafixSuppression in any invocation.
1 parent 8bde76c commit 22f09a4

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

project/Mima.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Mima {
99
ProblemFilters.exclude[Problem]("scalafix.internal.*"),
1010
ProblemFilters.exclude[Problem]("scala.meta.internal.*"),
1111
// Exceptions
12-
ProblemFilters.exclude[DirectMissingMethodProblem]("scalafix.Versions.scala211")
12+
ProblemFilters.exclude[DirectMissingMethodProblem]("scalafix.v0.Signature#Self.syntax")
1313
)
1414
}
1515
}

scalafix-core/src/main/scala/scalafix/v0/Signature.scala

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ object Signature {
5050
}
5151

5252
final case class Self(name: String) extends Signature {
53-
override def syntax =
54-
throw new UnsupportedOperationException(
55-
"No longer supported."
56-
) // scalafix:ok
53+
override def syntax: String =
54+
throw new UnsupportedOperationException("No longer supported.")
5755
override def structure: String = s"""Signature.Self("$name")"""
5856
override def toString: String = syntax
5957
}

scalafix-tests/integration/src/main/scala/test/DenotationOpsTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ package test
44
object DenotationOpsTest {
55
def m(x: Int, y: String): List[String] = List(y)
66
var x = true
7-
val y = m(42, "hey")
7+
private val y = m(42, "hey")
88
}

scalafix-tests/integration/src/main/scala/test/TypesTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package test
33

44
class TypesTest {
55
val a = 42
6-
val b = List(42)
6+
private val b = List(42)
77
class Inner
88
val c = new TypesTest
99
val d = new c.Inner
10-
val e = null.asInstanceOf[TypesTest#Inner]
10+
private val e = null.asInstanceOf[TypesTest#Inner]
1111
val f: {
1212
def foo(a: Int): Int
1313
def bar(a: Int): Int

0 commit comments

Comments
 (0)