Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive with AnyVal and foreach #629

Open
cchafer opened this issue May 2, 2022 · 0 comments
Open

False positive with AnyVal and foreach #629

cchafer opened this issue May 2, 2022 · 0 comments

Comments

@cchafer
Copy link

cchafer commented May 2, 2022

  • Scala version: 2.13.8
  • wartremover version: 3.0.2

Signature of Iterable foreach function is like :

def foreach[U](f: A => U): Unit

Usually, this is used like this:

val someIterable: Seq[SomeType] = ???
someIterable.foreach {
   entry => // ...
}

WartRemover will complain with the following error:

[wartremover:AnyVal] Inferred type containing AnyVal: AnyVal

The only to prevent the error is to write the code like this :

val someIterable: Seq[SomeType] = ???
someIterable.foreach[SomeType] {
   entry => // ...
}

While "logical", this behaviour is quite unwanted for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants