diff options
author | Paul Phillips <paulp@improving.org> | 2012-12-12 20:18:50 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-12-12 20:18:50 -0800 |
commit | ef8ff600041bc1627ebe972259d109cf421c0672 (patch) | |
tree | 9f109e09d3c2a79d9a7299029fa8fe8a0b06af21 /src/compiler | |
parent | df78f76682145c805a487e2b939e0844a6623ece (diff) | |
parent | dfa4e23bf8af721a4361567aef9aed672e39d4f8 (diff) | |
download | scala-ef8ff600041bc1627ebe972259d109cf421c0672.tar.gz scala-ef8ff600041bc1627ebe972259d109cf421c0672.tar.bz2 scala-ef8ff600041bc1627ebe972259d109cf421c0672.zip |
Merge pull request #1742 from scalamacros/ticket/4044
prevents spurious kind bound errors
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 22daf13e33..7ae8923e43 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1003,22 +1003,22 @@ trait Infer extends Checkable { */ /** error if arguments not within bounds. */ def checkBounds(tree: Tree, pre: Type, owner: Symbol, - tparams: List[Symbol], targs: List[Type], prefix: String): Boolean = { - //@M validate variances & bounds of targs wrt variances & bounds of tparams - //@M TODO: better place to check this? - //@M TODO: errors for getters & setters are reported separately - val kindErrors = checkKindBounds(tparams, targs, pre, owner) - - if(!kindErrors.isEmpty) { - if (targs contains WildcardType) true - else { KindBoundErrors(tree, prefix, targs, tparams, kindErrors); false } - } else if (!isWithinBounds(pre, owner, tparams, targs)) { - if (!(targs exists (_.isErroneous)) && !(tparams exists (_.isErroneous))) { - NotWithinBounds(tree, prefix, targs, tparams, kindErrors) - false - } else true - } else true - } + tparams: List[Symbol], targs: List[Type], prefix: String): Boolean = + if ((targs exists (_.isErroneous)) || (tparams exists (_.isErroneous))) true + else { + //@M validate variances & bounds of targs wrt variances & bounds of tparams + //@M TODO: better place to check this? + //@M TODO: errors for getters & setters are reported separately + val kindErrors = checkKindBounds(tparams, targs, pre, owner) + kindErrors match { + case Nil => + def notWithinBounds() = NotWithinBounds(tree, prefix, targs, tparams, Nil) + isWithinBounds(pre, owner, tparams, targs) || {notWithinBounds(); false} + case errors => + def kindBoundErrors() = KindBoundErrors(tree, prefix, targs, tparams, errors) + (targs contains WildcardType) || {kindBoundErrors(); false} + } + } def checkKindBounds(tparams: List[Symbol], targs: List[Type], pre: Type, owner: Symbol): List[String] = { checkKindBounds0(tparams, targs, pre, owner, true) map { |