Skip to content

Commit 77642b9

Browse files
committed
Two more tests
Unrelated to other commits but useful to get in.
1 parent c87c030 commit 77642b9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/pos/chan.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
trait Comparator {
2+
type T // abstract type member, to be filled in by concrete classes
3+
def ordering: Ordering[T]
4+
def compare(a: T, b: T): Int = ordering.compare(a, b)
5+
}
6+
7+
object IntComparator extends Comparator {
8+
type T = Int
9+
def ordering: Ordering[Int] = Ordering.Int
10+
}
11+
object Test {
12+
def process(c: Comparator)(items: Seq[c.T]): Int = {
13+
c.compare(items(0), items(1))
14+
}
15+
}
16+
class Processor[K](c: Comparator { type T = K }) {
17+
def process(items: Seq[K]): Int = {
18+
c.compare(items(0), items(1))
19+
}
20+
}

tests/run/t7685-class-simple.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Test {
2+
final class Foo(val x: String) extends AnyVal { override def toString = "" + x }
3+
final class Bar(val f: Foo) extends AnyVal { override def toString = "" + f }
4+
def main(args: Array[String]) = {
5+
val x = "abc"
6+
val f = new Foo(x)
7+
val b = new Bar(f)
8+
assert(b.toString == "abc")
9+
}
10+
}

0 commit comments

Comments
 (0)