diff options
author | Samuel Gruetter <samuel.gruetter@epfl.ch> | 2014-03-12 22:44:33 +0100 |
---|---|---|
committer | Samuel Gruetter <samuel.gruetter@epfl.ch> | 2014-03-12 22:44:33 +0100 |
commit | 9ef5f6817688f814a3450126aa7383b0928e80a0 (patch) | |
tree | 5727a2f7f7fd665cefdb312af2785c692f04377c /tests/untried/pos/gosh.scala | |
parent | 194be919664447631ba55446eb4874979c908d27 (diff) | |
download | dotty-9ef5f6817688f814a3450126aa7383b0928e80a0.tar.gz dotty-9ef5f6817688f814a3450126aa7383b0928e80a0.tar.bz2 dotty-9ef5f6817688f814a3450126aa7383b0928e80a0.zip |
add tests from scala/test/files/{pos,neg}
with explicit Unit return type
Diffstat (limited to 'tests/untried/pos/gosh.scala')
-rw-r--r-- | tests/untried/pos/gosh.scala | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/untried/pos/gosh.scala b/tests/untried/pos/gosh.scala new file mode 100644 index 000000000..81af14016 --- /dev/null +++ b/tests/untried/pos/gosh.scala @@ -0,0 +1,44 @@ +object ShapeTest extends App { + + class Point(x: Int, y: Int) { + override def toString() = "[" + x + "," + y + "]" + } + + abstract class Shape { + def draw(): Unit + } + + class Line(s: Point, e: Point) extends Shape { + def draw(): Unit = { Console.println("draw line " + s + "," + e) } + } + + abstract class Foo { + type T <: Object + + def show(o: T): Unit + def print(): Unit = { Console.println("in Foo") } + } + + abstract class ShapeFoo extends Foo { + type T <: Shape + def show(o: T): Unit = { o.draw() } + override def print(): Unit = { Console.println("in ShapeFoo") } + } + + class LineFoo extends ShapeFoo { + type T = Line + override def print(): Unit = { Console.println("in LineFoo") } + } + + val p1 = new Point(1,4) + val p2 = new Point(12, 28) + + val l1 = new Line(p1, p2) + + + val l = new ShapeFoo { // ** // + type T = Line // ** // + override def print(): Unit = { Console.println("in LineFoo") } // ** // + } + l.show(l1) // ** // +} |