diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-12-10 00:43:09 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-12-10 00:43:09 +0100 |
commit | a0cd0f81be9ab9ffdb1ecd09aebf43f4d7e738a8 (patch) | |
tree | 4b618b4ef55f841ba26bace73ac696b265623490 | |
parent | 0acb8a30c379f268e8a3e1340504530493a1a1dc (diff) | |
download | scala-a0cd0f81be9ab9ffdb1ecd09aebf43f4d7e738a8.tar.gz scala-a0cd0f81be9ab9ffdb1ecd09aebf43f4d7e738a8.tar.bz2 scala-a0cd0f81be9ab9ffdb1ecd09aebf43f4d7e738a8.zip |
prevents spurious kind bound errors
The patch adds a check which makes sure that the trees we're about to
report aren't already erroneous.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 10 | ||||
-rw-r--r-- | test/files/neg/t4044.check | 7 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 22daf13e33..96eb3e5c28 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1008,12 +1008,18 @@ trait Infer extends Checkable { //@M TODO: better place to check this? //@M TODO: errors for getters & setters are reported separately val kindErrors = checkKindBounds(tparams, targs, pre, owner) + def alreadyHasErrors = (targs exists (_.isErroneous)) || (tparams exists (_.isErroneous)) if(!kindErrors.isEmpty) { if (targs contains WildcardType) true - else { KindBoundErrors(tree, prefix, targs, tparams, kindErrors); false } + else { + if (!alreadyHasErrors) { + KindBoundErrors(tree, prefix, targs, tparams, kindErrors) + false + } else true + } } else if (!isWithinBounds(pre, owner, tparams, targs)) { - if (!(targs exists (_.isErroneous)) && !(tparams exists (_.isErroneous))) { + if (!alreadyHasErrors) { NotWithinBounds(tree, prefix, targs, tparams, kindErrors) false } else true diff --git a/test/files/neg/t4044.check b/test/files/neg/t4044.check index 41a04f69b9..0e1ea4f51d 100644 --- a/test/files/neg/t4044.check +++ b/test/files/neg/t4044.check @@ -1,11 +1,6 @@ t4044.scala:9: error: AnyRef takes no type parameters, expected: one M[AnyRef] // error, (AnyRef :: *) not kind-conformant to (N :: * -> * -> *) ^ -t4044.scala:9: error: kinds of the type arguments (<error>) do not conform to the expected kinds of the type parameters (type N). -<error>'s type parameters do not match type N's expected parameters: -<none> has no type parameters, but type N has one - M[AnyRef] // error, (AnyRef :: *) not kind-conformant to (N :: * -> * -> *) - ^ t4044.scala:11: error: kinds of the type arguments (Test.A) do not conform to the expected kinds of the type parameters (type N). Test.A's type parameters do not match type N's expected parameters: type _ has no type parameters, but type O has one @@ -16,4 +11,4 @@ Test.C's type parameters do not match type N's expected parameters: type _ has one type parameter, but type _ has none M[C] // error, (C :: (* -> * -> * -> *) not kind-conformant to (N :: * -> * -> *) ^ -four errors found +three errors found |