-
Notifications
You must be signed in to change notification settings - Fork 22
-Xlint:infer-any doesn't catch all scenarios where a type is inferred to be Any #12320
Copy link
Copy link
Closed
scala/scala
#9452Description
Reproduction steps
using Scala 2.13.3,
Run scala with scala -Xlint:infer-any -Wconf:cat=lint-infer-any:error
scala> Option.empty[Int].contains("") // this errors as expected
^
error: a type was inferred to be `Any`; this may indicate a programming error.
scala> Option.empty[Int].contains("") || false // this does not throw an error, even though a type was inferred to be `Any`
val res1: Boolean = falseor, to see type information:
This fails as expected:
scalac -Xlint:infer-any -Wconf:cat=lint-infer-any:error -Xprint:typer /dev/stdin <<<'object Main { Option.empty[Int].contains("") }'
This doesn't fail (even though it should, according to the typer output):
scalac -Xlint:infer-any -Wconf:cat=lint-infer-any:error -Xprint:typer /dev/stdin <<<'object Main { Option.empty[Int].contains("") || ??? }'
Problem
Expectation: The linter reports all instances of Any being inferred when -Xlint:infer-any is enabled
Actual: The linter sometimes doesn't report instances of Any being inferred with -Xlint:infer-any enabled
Reactions are currently unavailable