Permalink
Browse files

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.
  • Loading branch information...
1 parent 0acb8a3 commit a0cd0f81be9ab9ffdb1ecd09aebf43f4d7e738a8 @xeno-by xeno-by committed Dec 9, 2012
Showing with 9 additions and 8 deletions.
  1. +8 −2 src/compiler/scala/tools/nsc/typechecker/Infer.scala
  2. +1 −6 test/files/neg/t4044.check
@@ -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
@@ -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

0 comments on commit a0cd0f8

Please sign in to comment.