summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-12-12 20:18:50 -0800
committerPaul Phillips <paulp@improving.org>2012-12-12 20:18:50 -0800
commitef8ff600041bc1627ebe972259d109cf421c0672 (patch)
tree9f109e09d3c2a79d9a7299029fa8fe8a0b06af21
parentdf78f76682145c805a487e2b939e0844a6623ece (diff)
parentdfa4e23bf8af721a4361567aef9aed672e39d4f8 (diff)
downloadscala-ef8ff600041bc1627ebe972259d109cf421c0672.tar.gz
scala-ef8ff600041bc1627ebe972259d109cf421c0672.tar.bz2
scala-ef8ff600041bc1627ebe972259d109cf421c0672.zip
Merge pull request #1742 from scalamacros/ticket/4044
prevents spurious kind bound errors
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala32
-rw-r--r--test/files/neg/t4044.check7
2 files changed, 17 insertions, 22 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 {
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