aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/pos/chan.scala20
-rw-r--r--tests/run/t7685-class-simple.scala10
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")
+ }
+}