Skip to content

Missing "consider using immutable val" for private[this] var #12515

@som-snytt

Description

@som-snytt

reproduction steps

  scala -Xlint
Welcome to Scala 2.13.7 (OpenJDK 64-Bit Server VM, Java 17).
Type in expressions for evaluation. Or try :help.

scala> private var v = 0
                   ^
       warning: private var v in class $iw is never used

scala> private var v = 0 ; def f = v
                   ^
       warning: private var v in class $iw is never updated: consider using immutable val
def f: Int

scala> private[this] var v = 0
                         ^
       warning: private var v in class $iw is never used

scala> private[this] var v = 0 ; def f = v
def f: Int

scala>

problem

I didn't expect to lose my linting.

Noticed at scala/scala#9818 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions