summaryrefslogtreecommitdiff
path: root/test/files/neg/warn-inferred-any.check
Commit message (Collapse)AuthorAgeFilesLines
* SI-9636 More precise error pos on apply inferenceSom Snytt2016-12-201-1/+1
| | | | | If a method type arg is inferred Any, warn about the function and not the innocent arg.
* SI-8806 Add lower bound check to Any lintSom Snytt2014-09-051-1/+4
| | | | | | | | | | | | | | | | | | We already exclude the lint check for infer-any if Any is somewhere explicit. This commit adds lower bounds of type params to the somewheres. Motivated by: ``` scala> f"${42}" <console>:8: warning: a type was inferred to be `Any`; this may indicate a programming error. f"${42}" ^ res0: String = 42 ```
* Made -Xfatal-warnings less immediately fatal.Paul Phillips2012-08-101-4/+6
| | | | | | | Instead of changing warnings to errors mid-stream, at the end of a run I check for condition "no errors, some warnings, and fatal warnings" and then generate an error at that point. This is necessary to test for some warnings which come from later stages.
* Warn when Any or AnyVal is inferred.Paul Phillips2012-08-091-0/+10
For the very small price of annotating types as Any/AnyVal in those cases where we wish to use them, we can obtain useful warnings. I made trunk clean against this warning and found several bugs or at least suboptimalities in the process. I put the warning behind -Xlint for the moment, but I think this belongs on by default, even for this alone: scala> List(1, 2, 3) contains "a" <console>:8: warning: a type was inferred to be `Any`; this may indicate a programming error. List(1, 2, 3) contains "a" ^ res0: Boolean = false Or this punishment meted out by SI-4042: scala> 1l to 5l contains 5 <console>:8: warning: a type was inferred to be `AnyVal`; this may indicate a programming error. 1l to 5l contains 5 ^ res0: Boolean = false A different situation where this arises, which I have seen variations of many times: scala> class A[T](default: T) { def get(x: => Option[T]) = x getOrElse Some(default) } <console>:7: warning: a type was inferred to be `Any`; this may indicate a programming error. class A[T](default: T) { def get(x: => Option[T]) = x getOrElse Some(default) } ^ // Oops, this was what I meant scala> class A[T](default: T) { def get(x: => Option[T]) = x getOrElse default } defined class A Harder to avoid spurious warnings when "Object" is inferred.