aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-12-01 12:32:59 +0100
committerMartin Odersky <odersky@gmail.com>2015-12-06 16:09:19 +0100
commitdf00eb195d86a3d1425029f2f2436029a757ee5d (patch)
tree8ecba17ee7babf69f3dbe18f960c21abb95a412d /tests
parent4c8db87e499e3a0f56a89ed0824b27230db32997 (diff)
downloaddotty-df00eb195d86a3d1425029f2f2436029a757ee5d.tar.gz
dotty-df00eb195d86a3d1425029f2f2436029a757ee5d.tar.bz2
dotty-df00eb195d86a3d1425029f2f2436029a757ee5d.zip
Disallow existentially bound parameters as type parameters
Done in order to keep the basics as simple as possible. Treating existentially bound parameters as still instantiatable type parameters does not seem to add anything fundamental, and makes the type system less regular.
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/partialApplications.scala16
-rw-r--r--tests/pickling/partialApplications.scala24
-rw-r--r--tests/pos/collections.scala2
-rw-r--r--tests/pos/partialApplications.scala17
4 files changed, 37 insertions, 22 deletions
diff --git a/tests/neg/partialApplications.scala b/tests/neg/partialApplications.scala
new file mode 100644
index 000000000..d186273aa
--- /dev/null
+++ b/tests/neg/partialApplications.scala
@@ -0,0 +1,16 @@
+object Test2 {
+ type Histogram = Map[_, Int] // this is now an existential type!
+
+ type StringlyHistogram = Histogram[_ >: String] // Error: Test2.Histogram does not take type parameters
+
+ val xs: Histogram[String] = Map[String, Int]() // Error: Test2.Histogram does not take type parameters
+
+ val ys: StringlyHistogram[String] = xs // Error: Test2.StringlyHistogram does not take type parameters
+
+ val zs: StringlyHistogram = xs
+
+ val xs1 = xs
+ val ys1 = ys
+ val zs1 = zs
+
+}
diff --git a/tests/pickling/partialApplications.scala b/tests/pickling/partialApplications.scala
index f517011b9..c4c4328f6 100644
--- a/tests/pickling/partialApplications.scala
+++ b/tests/pickling/partialApplications.scala
@@ -1,13 +1,29 @@
-object PartialApplications {
+object partialApplications {
- type Histogram = Map[_, Int]
+ type Histogram[X] = Map[X, Int]
- type StringlyHistogram = Histogram[_ >: String]
+ type StringlyHistogram[X >: String] = Histogram[X]
val xs: Histogram[String] = Map[String, Int]()
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
}
diff --git a/tests/pos/collections.scala b/tests/pos/collections.scala
index 08c3010c8..5edcff986 100644
--- a/tests/pos/collections.scala
+++ b/tests/pos/collections.scala
@@ -10,7 +10,7 @@ object collections {
val s = Set(1, 2, 3)
val ss = s map (_ + 1)
- val cbf: CanBuildFrom[List, Int, List[Int]] = scala.collection.immutable.List.canBuildFrom
+ val cbf: CanBuildFrom[List[_], Int, List[Int]] = scala.collection.immutable.List.canBuildFrom
val nil = Nil
val ints1 = 1 :: Nil
diff --git a/tests/pos/partialApplications.scala b/tests/pos/partialApplications.scala
index 696c544e7..fae6849fc 100644
--- a/tests/pos/partialApplications.scala
+++ b/tests/pos/partialApplications.scala
@@ -27,20 +27,3 @@ object Test {
val ss: RMap[Float, Int] = rs
}
-
-object Test2 {
- type Histogram = Map[_, Int]
-
- type StringlyHistogram = Histogram[_ >: String]
-
- val xs: Histogram[String] = Map[String, Int]()
-
- val ys: StringlyHistogram[String] = xs
-
- val zs: StringlyHistogram = xs
-
- val xs1 = xs
- val ys1 = ys
- val zs1 = zs
-
-}