aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-06-29 19:43:44 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-11 13:35:01 +0200
commit8e84fb013abeb613af4a3414b836f02140e2e866 (patch)
tree26b66d75631822c1190a5f6fb9adf74182427579 /tests
parent6a7e466fa2ff5d6d01a25bed0c685188c9a84a63 (diff)
downloaddotty-8e84fb013abeb613af4a3414b836f02140e2e866.tar.gz
dotty-8e84fb013abeb613af4a3414b836f02140e2e866.tar.bz2
dotty-8e84fb013abeb613af4a3414b836f02140e2e866.zip
Eta-expand unapplied types that have type parameters
We would like to change from a scheme where eta-expansion was prototype driven to one where unapplied parameterized types are always eta expanded. The reason is that we might miss some eta expansions due to cyclic references. run/colltest4 is an exmaple. Here, we missed an eta expansion in the type of Iterator. The class definition is: trait Iterable[+A] extends IterableOnce[A] with FromIterable[Iterable] { We'd expect that the second parent would expand to FromIterable[[X0] -> Iterable[X0]] But we miss the expansion because at the time we complete Iterable we have not completed FromIterable yet. In fact this happens in both the old and the new hk scheme. But in the old scheme we did not notice the error whereas in the new scheme we get an error in PostTyper that the type Iterable does not conform to its bound `[X0] -> Iterable[X0]`. With this commit, we change the scheme, so that eta-expansion depends on the type parameters of a type itself, instead of the expected type. We should investigate whether we can do a similar change for Scala2 classloading. Check kinds of type parameters Also, do not allow a hk type if the bound is a * type.
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/kinds.scala18
-rw-r--r--tests/pos/jon.scala2
-rw-r--r--tests/pos/range.scala4
-rw-r--r--tests/pos/t2613.scala2
-rw-r--r--tests/pos/tycons.scala22
5 files changed, 22 insertions, 26 deletions
diff --git a/tests/neg/kinds.scala b/tests/neg/kinds.scala
new file mode 100644
index 000000000..312c5d45e
--- /dev/null
+++ b/tests/neg/kinds.scala
@@ -0,0 +1,18 @@
+object Test {
+
+ class C[T]
+ class C2[T[X]]
+
+ class B
+
+ val x: C[C] = ??? // error: missing type parameter(s)
+ val y: C2[C] = ???
+
+ def f[T] = ???
+
+ def f2[T[X]] = ???
+
+ f[C] // error: missing type parameter(s)
+ f2[C]
+
+}
diff --git a/tests/pos/jon.scala b/tests/pos/jon.scala
index d4ea74f02..224486945 100644
--- a/tests/pos/jon.scala
+++ b/tests/pos/jon.scala
@@ -4,5 +4,5 @@ object Test {
val x = List(List, Vector)
- val y: List[scala.collection.generic.SeqFactory] = x
+ val y: List[scala.collection.generic.SeqFactory[_]] = x
}
diff --git a/tests/pos/range.scala b/tests/pos/range.scala
index 9e7b5d1c9..a33f7fcee 100644
--- a/tests/pos/range.scala
+++ b/tests/pos/range.scala
@@ -1,8 +1,8 @@
import scala.math._
import collection.immutable.NumericRange
object Test {
- val r1: scala.collection.immutable.Range.Partial = ???
- val r2: scala.Range.Partial = r1
+ val r1: scala.collection.immutable.Range.Partial[_, _] = ???
+ val r2: scala.Range.Partial[_, _] = r1
def until(d: BigDecimal, end: BigDecimal): Range.Partial[BigDecimal, NumericRange.Exclusive[BigDecimal]] =
new Range.Partial(until(d, end, _))
def until(d: BigDecimal, end: BigDecimal, step: BigDecimal) = Range.BigDecimal(d, end, step)
diff --git a/tests/pos/t2613.scala b/tests/pos/t2613.scala
index c234d4c0d..17ebe2d7e 100644
--- a/tests/pos/t2613.scala
+++ b/tests/pos/t2613.scala
@@ -5,7 +5,7 @@ object Test {
abstract class MyRelation [R <: Row, +Relation <: MyRelation[R, Relation]]
- type M = MyRelation[_ <: Row, _ <: MyRelation]
+ type M = MyRelation[_ <: Row, _ <: MyRelation[_, _]]
val (x,y): (String, M) = null
}
diff --git a/tests/pos/tycons.scala b/tests/pos/tycons.scala
deleted file mode 100644
index 1ed4d2855..000000000
--- a/tests/pos/tycons.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-class TypeConstructor {
- type TypeArg
-}
-
-trait List[+T] extends TypeConstructor { type TypeArg <: T }
-
-trait Set[T] extends TypeConstructor { type TypeArg <: T }
-
-object obj extends List[Number] with Set[Exception] {
- val x: TypeArg = ???
- val n: Number = x
- val e: Exception = x
-}
-
-abstract class Functor[F <: TypeConstructor] {
- def map[A, B](f: F { type TypeArg <: A }): F { type TypeArg <: B }
-}
-
-object ListFunctor extends Functor[List] {
- override def map[A, B](f: List { type TypeArg <: A }): List { type TypeArg <: B } = ???
-}
-