summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-09-16 17:29:25 +1000
committerJason Zaugg <jzaugg@gmail.com>2014-09-16 17:29:25 +1000
commiteb5d0a6b31e2f2c5c8a7505232cfc648f581af71 (patch)
treeb6b3ff256dd858b5ab30a3ce9144d0d5891b5f32 /src/compiler/scala/tools
parent3307e44a9d980eef5a442a688ef22765556f609f (diff)
parentc9ec916f20c4f06a0aebe0a9929443c1c8b60c5c (diff)
downloadscala-eb5d0a6b31e2f2c5c8a7505232cfc648f581af71.tar.gz
scala-eb5d0a6b31e2f2c5c8a7505232cfc648f581af71.tar.bz2
scala-eb5d0a6b31e2f2c5c8a7505232cfc648f581af71.zip
Merge pull request #3936 from som-snytt/issue/8806
SI-8806 Add lower bound check to Any lint
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 421021163e..ee2775ee26 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -544,7 +544,14 @@ trait Infer extends Checkable {
val targs = solvedTypes(tvars, tparams, tparams map varianceInTypes(formals), upper = false, lubDepth(formals) max lubDepth(argtpes))
// Can warn about inferring Any/AnyVal as long as they don't appear
// explicitly anywhere amongst the formal, argument, result, or expected type.
- def canWarnAboutAny = !(pt :: restpe :: formals ::: argtpes exists (t => (t contains AnyClass) || (t contains AnyValClass)))
+ // ...or lower bound of a type param, since they're asking for it.
+ def canWarnAboutAny = {
+ val loBounds = tparams map (_.info.bounds.lo)
+ val hasAny = pt :: restpe :: formals ::: argtpes ::: loBounds exists (t =>
+ (t contains AnyClass) || (t contains AnyValClass)
+ )
+ !hasAny
+ }
def argumentPosition(idx: Int): Position = context.tree match {
case x: ValOrDefDef => x.rhs match {
case Apply(fn, args) if idx < args.size => args(idx).pos