diff options
author | Martin Odersky <odersky@gmail.com> | 2015-07-21 18:42:17 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-09-18 18:12:17 +0200 |
commit | e8aecfa4d48383321549aa8f1ec8d1edb0ccaf06 (patch) | |
tree | 07b68f223127eff223adbbe4602c05b4a04339c6 /tests | |
parent | 4148970a984de945c69f345381f0f03e84d7d6c2 (diff) | |
download | dotty-e8aecfa4d48383321549aa8f1ec8d1edb0ccaf06.tar.gz dotty-e8aecfa4d48383321549aa8f1ec8d1edb0ccaf06.tar.bz2 dotty-e8aecfa4d48383321549aa8f1ec8d1edb0ccaf06.zip |
Disallow wildcard arguments to higher-kinded types...
...unless the HK type can be eta-reduced to a class type.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/partialApplications.scala | 11 | ||||
-rw-r--r-- | tests/pos/partialApplications.scala | 35 |
2 files changed, 45 insertions, 1 deletions
diff --git a/tests/neg/partialApplications.scala b/tests/neg/partialApplications.scala new file mode 100644 index 000000000..67f6cf059 --- /dev/null +++ b/tests/neg/partialApplications.scala @@ -0,0 +1,11 @@ +object Test { + + type RMap[X, Y] = Map[Y, X] + val m = Map[Int, String]() + val ts: RMap[_, Int] = m // erorr // error + val us: RMap[String, _] = m // error // error + val vs: RMap[_, _] = m // error // error // error + val zz: RMap = m // error + +} + diff --git a/tests/pos/partialApplications.scala b/tests/pos/partialApplications.scala index c1df1dee2..285dc8661 100644 --- a/tests/pos/partialApplications.scala +++ b/tests/pos/partialApplications.scala @@ -8,6 +8,39 @@ object Test { val ys: StringlyHistogram[String] = xs - val zs: StringlyHistogram = xs + def e = xs + + val zs: StringlyHistogram[_] = e + + type IntMap[Y] = Map[Int, Y] + + val is = Map[Int, Boolean]() + + val js: IntMap[Boolean] = is + + val ks: IntMap[_] = is + + type RMap[X, Y] = Map[Y, X] + + val rs = Map[Int, Float]() + + val ss: RMap[Float, Int] = rs + +} + +object Test2 { + type Histogram = Map[_, Int] + + type StringlyHistogram = Histogram[_ >: String] // error + + val xs: Histogram[String] = Map[String, Int]() // error + + val ys: StringlyHistogram[String] = xs // error + + val zs: StringlyHistogram = xs // error + + val xs1 = xs + val ys1 = ys + val zs1 = zs } |