diff options
author | Martin Odersky <odersky@gmail.com> | 2016-05-19 17:15:51 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-05-19 17:15:57 +0200 |
commit | 77642b925cdea436755ce6e26e794e48c37b3b1a (patch) | |
tree | 2f5ede1459b07d30f18cc4ed20e4fa36289eb3b4 /tests | |
parent | c87c0303e40ef7e0103b2606c744bc7a2b61ece4 (diff) | |
download | dotty-77642b925cdea436755ce6e26e794e48c37b3b1a.tar.gz dotty-77642b925cdea436755ce6e26e794e48c37b3b1a.tar.bz2 dotty-77642b925cdea436755ce6e26e794e48c37b3b1a.zip |
Two more tests
Unrelated to other commits but useful to get in.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/chan.scala | 20 | ||||
-rw-r--r-- | tests/run/t7685-class-simple.scala | 10 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/pos/chan.scala b/tests/pos/chan.scala new file mode 100644 index 000000000..ea8eb2b54 --- /dev/null +++ b/tests/pos/chan.scala @@ -0,0 +1,20 @@ +trait Comparator { + type T // abstract type member, to be filled in by concrete classes + def ordering: Ordering[T] + def compare(a: T, b: T): Int = ordering.compare(a, b) +} + +object IntComparator extends Comparator { + type T = Int + def ordering: Ordering[Int] = Ordering.Int +} +object Test { + def process(c: Comparator)(items: Seq[c.T]): Int = { + c.compare(items(0), items(1)) + } +} +class Processor[K](c: Comparator { type T = K }) { + def process(items: Seq[K]): Int = { + c.compare(items(0), items(1)) + } +} diff --git a/tests/run/t7685-class-simple.scala b/tests/run/t7685-class-simple.scala new file mode 100644 index 000000000..5147a66c0 --- /dev/null +++ b/tests/run/t7685-class-simple.scala @@ -0,0 +1,10 @@ +object Test { + final class Foo(val x: String) extends AnyVal { override def toString = "" + x } + final class Bar(val f: Foo) extends AnyVal { override def toString = "" + f } + def main(args: Array[String]) = { + val x = "abc" + val f = new Foo(x) + val b = new Bar(f) + assert(b.toString == "abc") + } +} |