HairyFotr / linter

Static Analysis Compiler Plugin for Scala
Apache License 2.0
268 stars 34 forks source link

ContainsTypeMismatch false positive when contains is used as predicate function #46

Open levinson opened 8 years ago

levinson commented 8 years ago

I've found a false positive with the ContainsTypeMismatch:

val foo = Some("foo")
val bar = Some("bar")

fails with the following:

foo.exists(bar.contains(_))
foo.exists(bar.contains)

... but works with:

foo.exists(str => bar.contains(str))
HairyFotr commented 8 years ago

For me foo.exists(bar.contains) gives a false positive (because Any is inferred by the compiler instead of String - am investigating why), but the other two work as expected.

levinson commented 8 years ago

Ah, my bad, it seems that foo.exists(bar.contains(_)) does indeed work. Thanks for looking into the issue. :+1: