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/spec.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/spec.scala')
-rw-r--r-- | tests/untried/pos/spec.scala | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/untried/pos/spec.scala b/tests/untried/pos/spec.scala new file mode 100644 index 000000000..f548e156f --- /dev/null +++ b/tests/untried/pos/spec.scala @@ -0,0 +1,64 @@ + + + + +class Bar[@specialized(Int, AnyRef) A](a: A) { + val memb = a +} + + +class WithInner[@specialized(Int, AnyRef) A](a: A) { + class Inner { + def meth = a + } +} + + +class Baz[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B] { + def ab(a: A, b: B) = (a, b) +} + + +trait Base[@specialized(Int, AnyRef) A] +class Concrete[@specialized(Int, AnyRef) A] extends Base[A] + + +class WithAnon[@specialized(Int, AnyRef) A](a: A) { + new AnyRef { + def foo = a + } +} + + +class Norm { + def id[@specialized(Int, AnyRef) A](a: A) = a +} + + +class Qux[@specialized(AnyRef) A] { + def memb[@specialized(AnyRef) B](a: A, b: B) = (a, b) +} + + +class Foo[@specialized(Int, AnyRef) A](val a: Array[A]) { + a(0) + + def id(elem: A) = a(0) = elem +} + + +// instantiation and selection +object Test { + def main(arg: Array[String]): Unit = { + val f = new Foo(new Array[String](5)) + f.id("") + + val z = new Baz[Int, Double] + z.ab(1, 1.0) + + testspec(new Array[String](5)) + testspec(new Array[Int](5)) + } + + def testspec[@specialized(Int, AnyRef) T](arr: Array[T]) = arr(0) +} |