diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-13 02:08:24 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-13 02:08:24 +0000 |
commit | 360f747c67006bc281ab28af3565eb602ed68b7c (patch) | |
tree | 18d1df3e1b39923cfa756d7429cfb4cce696b0e5 | |
parent | 0fac26971e78fbe79b2ba5aaa87bde63816ac028 (diff) | |
download | scala-360f747c67006bc281ab28af3565eb602ed68b7c.tar.gz scala-360f747c67006bc281ab28af3565eb602ed68b7c.tar.bz2 scala-360f747c67006bc281ab28af3565eb602ed68b7c.zip |
Suppressed an error in type constructor bounds ...
Suppressed an error in type constructor bounds checking which was
obscuring the meaningful error to follow. Review by moors.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 11 | ||||
-rw-r--r-- | test/files/neg/hk-bad-bounds.check | 4 | ||||
-rw-r--r-- | test/files/neg/hk-bad-bounds.scala | 5 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index a8c54d48e0..21401d39dd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1074,12 +1074,15 @@ trait Infer { //@M TODO: errors for getters & setters are reported separately val kindErrors = checkKindBounds(tparams, targs, pre, owner) - if(!kindErrors.isEmpty) { - error(pos, + if (!kindErrors.isEmpty) { + if (targs contains WildcardType) () + else error(pos, prefix + "kinds of the type arguments " + targs.mkString("(", ",", ")") + - " do not conform to the expected kinds of the type parameters "+ tparams.mkString("(", ",", ")") + tparams.head.locationString+ "." + + " do not conform to the expected kinds of the type parameters "+ + tparams.mkString("(", ",", ")") + tparams.head.locationString+ "." + kindErrors.toList.mkString("\n", ", ", "")) - } else if (!isWithinBounds(pre, owner, tparams, targs)) { + } + else if (!isWithinBounds(pre, owner, tparams, targs)) { if (!(targs exists (_.isErroneous)) && !(tparams exists (_.isErroneous))) { //val bounds = instantiatedBounds(pre, owner, tparams, targs)//DEBUG //println("bounds = "+bounds+", targs = "+targs+", targclasses = "+(targs map (_.getClass))+", parents = "+(targs map (_.parents))) diff --git a/test/files/neg/hk-bad-bounds.check b/test/files/neg/hk-bad-bounds.check new file mode 100644 index 0000000000..d6293993c1 --- /dev/null +++ b/test/files/neg/hk-bad-bounds.check @@ -0,0 +1,4 @@ +hk-bad-bounds.scala:4: error: type arguments [Set] do not conform to class SeqFactory's type parameter bounds [CC[X] <: Seq[X] with scala.collection.generic.GenericTraversableTemplate[X,CC]] + def f(x: Boolean) = if (x) (null: SeqFactory[List]) else (null: SeqFactory[Set]) + ^ +one error found diff --git a/test/files/neg/hk-bad-bounds.scala b/test/files/neg/hk-bad-bounds.scala new file mode 100644 index 0000000000..0ed0b4c385 --- /dev/null +++ b/test/files/neg/hk-bad-bounds.scala @@ -0,0 +1,5 @@ +import collection.generic.SeqFactory + +class A { + def f(x: Boolean) = if (x) (null: SeqFactory[List]) else (null: SeqFactory[Set]) +} |