diff options
author | Martin Odersky <odersky@gmail.com> | 2016-03-30 12:16:03 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-03-30 12:16:03 +0200 |
commit | f675ad9507089f8b912357fab86740653c1b8789 (patch) | |
tree | 66d8e6c3775795ed017a292accd6a4d146009e88 /tests | |
parent | d89767858c4e3a7ad37d9a98ea1e87f58bd0eb02 (diff) | |
download | dotty-f675ad9507089f8b912357fab86740653c1b8789.tar.gz dotty-f675ad9507089f8b912357fab86740653c1b8789.tar.bz2 dotty-f675ad9507089f8b912357fab86740653c1b8789.zip |
Domain checking for named type parameters
Now verifies that the named type parameters of an overriding
type or class are the same as the named type parameters of
an overridden type.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/named-params.scala | 3 | ||||
-rw-r--r-- | tests/pos/CollectionStrawMan3.scala | 20 |
2 files changed, 13 insertions, 10 deletions
diff --git a/tests/neg/named-params.scala b/tests/neg/named-params.scala index 9ef4ed066..5a2375b15 100644 --- a/tests/neg/named-params.scala +++ b/tests/neg/named-params.scala @@ -32,3 +32,6 @@ object Test { val z5 = d2[Elem = Int][Value = String](1) //error // error } + + + diff --git a/tests/pos/CollectionStrawMan3.scala b/tests/pos/CollectionStrawMan3.scala index 47d3b52d6..c21a73f00 100644 --- a/tests/pos/CollectionStrawMan3.scala +++ b/tests/pos/CollectionStrawMan3.scala @@ -114,13 +114,13 @@ object CollectionStrawMan1 { /* --------- Concrete collection types ------------------------------- */ /** Concrete collection type: List */ - sealed trait List[+A] extends Seq[A] with FromIterator[List] { + sealed trait List[type +Elem] extends Seq[Elem] with FromIterator[List] { def isEmpty: Boolean - def head: A - def tail: List[A] - def iterator = new ListIterator[A](this) + def head: Elem + def tail: List[Elem] + def iterator = new ListIterator[Elem](this) def fromIterator[B](it: Iterator[B]): List[B] = List.fromIterator(it) - def apply(i: Int): A = { + def apply(i: Int): Elem = { require(!isEmpty) if (i == 0) head else tail.apply(i - 1) } @@ -155,17 +155,17 @@ object CollectionStrawMan1 { } /** Concrete collection type: ArrayBuffer */ - class ArrayBuffer[A] private (initElems: Array[AnyRef], initLength: Int) extends Seq[A] with FromIterator[ArrayBuffer] { + class ArrayBuffer[type Elem] private (initElems: Array[AnyRef], initLength: Int) extends Seq[Elem] with FromIterator[ArrayBuffer] { def this() = this(new Array[AnyRef](16), 0) private var elems: Array[AnyRef] = initElems private var start = 0 private var limit = initLength - def apply(i: Int) = elems(start + i).asInstanceOf[A] + def apply(i: Int) = elems(start + i).asInstanceOf[Elem] def length = limit - start - def iterator = new ArrayBufferIterator[A](elems, start, length) + def iterator = new ArrayBufferIterator[Elem](elems, start, length) def fromIterator[B](it: Iterator[B]): ArrayBuffer[B] = ArrayBuffer.fromIterator(it) - def +=(elem: A): this.type = { + def +=(elem: Elem): this.type = { if (limit == elems.length) { if (start > 0) { Array.copy(elems, start, elems, 0, length) @@ -213,7 +213,7 @@ object CollectionStrawMan1 { } /** Concrete collection type: View */ - class View[+A](it: => Iterator[A]) extends CanIterate[A] { + class View[type +Elem](it: => Iterator[Elem]) extends CanIterate[Elem] { def iterator = it } |