Skip to content

Commit

Permalink
remove [this] if scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed May 14, 2024
1 parent f756898 commit 0c002c6
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala-3/org/wartremover/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Plugin extends StandardPlugin {

override def description = "wartremover"

private[this] val initialLog = new AtomicBoolean(true)
private val initialLog = new AtomicBoolean(true)

override def init(options: List[String]): List[PluginPhase] = {
val excluded = options.collect { case s"excluded:${path}" =>
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala-3/org/wartremover/WartUniverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class WartUniverse(onlyWarning: Boolean, logLevel: LogLevel) { self =>
abstract class Traverser(traverser: WartTraverser) extends TreeTraverser {
final implicit val q: self.quotes.type = self.quotes

private[this] def withPrefix(name: String): String = s"[wartremover:${name}] "
private def withPrefix(name: String): String = s"[wartremover:${name}] "

protected final def warning(pos: Position, message: String): Unit =
onWarn(msg = withPrefix(traverser.simpleName) + message, pos = pos)
Expand All @@ -57,7 +57,7 @@ abstract class WartUniverse(onlyWarning: Boolean, logLevel: LogLevel) { self =>
.exists(hasWartAnnotationSymbol)
}

protected[this] def hasWartAnnotationSymbol(s: Symbol): Boolean = {
protected def hasWartAnnotationSymbol(s: Symbol): Boolean = {
val SuppressWarningsSymbol = TypeTree.of[SuppressWarnings].symbol

val args: Set[String] = s
Expand All @@ -80,7 +80,7 @@ abstract class WartUniverse(onlyWarning: Boolean, logLevel: LogLevel) { self =>
args(traverser.fullName) || args("org.wartremover.warts.All") || hasScalaAnnotationNowarn(s)
}

private[this] def hasScalaAnnotationNowarn(s: Symbol): Boolean = {
private def hasScalaAnnotationNowarn(s: Symbol): Boolean = {
val nowarnSymbol = TypeTree.of[scala.annotation.nowarn].symbol

s.getAnnotation(nowarnSymbol).exists {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import scala.quoted.runtime.impl.QuotesImpl
import scala.reflect.NameTransformer

class WartReporter extends Reporter {
private[this] val lock = new Object
private[this] val values = ListBuffer.empty[Diagnostic]
private val lock = new Object
private val values = ListBuffer.empty[Diagnostic]
override def doReport(diagnostic: Diagnostic)(using Context): Unit = {
lock.synchronized {
values += diagnostic
Expand Down Expand Up @@ -46,7 +46,7 @@ object WartTestTraverser {

inline def apply[A <: WartTraverser](inline t: A)(inline a: Any): Result = ${ applyImpl[A]('t, 'a) }

private[this] def applyImpl[A <: WartTraverser: Type](t: Expr[A], expr: Expr[Any])(using q1: Quotes): Expr[Result] = {
private def applyImpl[A <: WartTraverser: Type](t: Expr[A], expr: Expr[Any])(using q1: Quotes): Expr[Result] = {
val q2 = q1.asInstanceOf[QuotesImpl]
val reporter = new WartReporter
q2.ctx.asInstanceOf[FreshContext].setReporter(reporter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package warts
object CaseClassPrivateApply extends WartTraverser {
def apply(u: WartUniverse): u.Traverser = {
new u.Traverser(this) {
private[this] var outerObjectNames: List[String] = Nil
private var outerObjectNames: List[String] = Nil

import q.reflect.*
override def traverseTree(tree: Tree)(owner: Symbol): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class ForbidInference[A](using getType: Quotes ?=> Type[A]) extends War
def apply(u: WartUniverse): u.Traverser = {
new u.Traverser(this) {
import q.reflect.*
private[this] val A: TypeRepr = TypeRepr.of[A]
private val A: TypeRepr = TypeRepr.of[A]
@nowarn("msg=cannot be checked at runtime")
override def traverseTree(tree: Tree)(owner: Symbol): Unit = {
tree match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abstract class ForbidType[A <: AnyKind](message: String)(using getType: Quotes ?
def apply(u: WartUniverse): u.Traverser = {
new u.Traverser(this) {
import q.reflect.*
private[this] val A: TypeRepr = TypeRepr.of[A]
private val A: TypeRepr = TypeRepr.of[A]
override def traverseTree(tree: Tree)(owner: Symbol): Unit = {
tree match {
case t if hasWartAnnotation(t) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract class OrTypeLeastUpperBound[A <: NonEmptyTuple](using getType: Quotes ?
}
}

private[this] var currentPosition: Option[Position] = None
private var currentPosition: Option[Position] = None

override def traverseTree(tree: Tree)(owner: Symbol): Unit = {
tree match {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-3/org/wartremover/warts/Recursion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ object Recursion extends WartTraverser {
def apply(u: WartUniverse): u.Traverser = {
new u.Traverser(this) {
import q.reflect.*
private[this] val Tailrec = TypeRepr.of[scala.annotation.tailrec]
private[this] var open: Set[Symbol] = Set.empty[Symbol]
private val Tailrec = TypeRepr.of[scala.annotation.tailrec]
private var open: Set[Symbol] = Set.empty[Symbol]
private def inside[A](sym: Symbol)(expr: => A): A = {
open = open + sym
try expr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ object WartRemoverInspector {
}

final class WartRemoverInspector {
private[this] implicit val inspectParamInstance: DecodeJson[InspectParam] =
private implicit val inspectParamInstance: DecodeJson[InspectParam] =
DecodeJson.derive[InspectParam]

private[this] implicit val inspectResultInstance: EncodeJson[InspectResult] = {
private implicit val inspectResultInstance: EncodeJson[InspectResult] = {
implicit val positionInstance: EncodeJson[Position] =
EncodeJson.derive[Position]
implicit val diagnosticInstance: EncodeJson[Diagnostic] =
Expand Down Expand Up @@ -93,7 +93,7 @@ final class WartRemoverInspector {
}
}

private[this] def run0(
private def run0(
errorTraversers: List[WartTraverser],
warningTraversers: List[WartTraverser],
tastyFiles: List[String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ object IsInstanceOfTestMacros {

inline def is[A, B]: A => Boolean = ${ is_impl[A, B] }

private[this] def is_impl[A: Type, B: Type](using Quotes): Expr[A => Boolean] =
private def is_impl[A: Type, B: Type](using Quotes): Expr[A => Boolean] =
'{ (a: A) => a.isInstanceOf[B] }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object PublicInferenceTestMacros {

inline def define: Int = ${ define_impl }

private[this] def define_impl(using Quotes): Expr[Int] = '{
private def define_impl(using Quotes): Expr[Int] = '{
class generated {
val a_val = 2
var a_var = 2
Expand Down

0 comments on commit 0c002c6

Please sign in to comment.