From 1f8b5691dabaae336c3c3f568b303eb24e783494 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 27 Jan 2015 12:46:48 +0100 Subject: Test reorg --- test/dotc/tests.scala | 2 +- .../disabled/not-representable/pos/t3498-old.scala | 15 ++++++++++ tests/disabled/structural-type/pos/t3175-pos.scala | 7 +++++ tests/disabled/structural-type/pos/t3363-new.scala | 20 ++++++++++++++ tests/disabled/structural-type/pos/t3363-old.scala | 18 ++++++++++++ tests/neg/overrides.scala | 21 ++++++++++++++ tests/pending/pos/sammy_poly.scala | 7 ----- tests/pending/pos/scoping1.scala | 12 -------- tests/pending/pos/sealed-final.scala | 14 ---------- tests/pending/pos/self-type-override.scala | 13 --------- tests/pending/pos/spec-sealed.scala | 32 ---------------------- tests/pending/pos/t3175-pos.scala | 7 ----- tests/pending/pos/t319.scala | 21 -------------- tests/pending/pos/t3278.scala | 15 ---------- tests/pending/pos/t3343.scala | 15 ---------- tests/pending/pos/t3363-new.scala | 20 -------------- tests/pending/pos/t3363-old.scala | 18 ------------ tests/pending/pos/t3411.scala | 8 ------ tests/pending/pos/t344.scala | 12 -------- tests/pending/pos/t3480.scala | 2 +- tests/pending/pos/t3498-old.scala | 15 ---------- tests/pos/sammy_poly.scala | 7 +++++ tests/pos/scoping1.scala | 12 ++++++++ tests/pos/sealed-final.scala | 14 ++++++++++ tests/pos/spec-sealed.scala | 32 ++++++++++++++++++++++ tests/pos/subtyping.scala | 29 +------------------- tests/pos/t319.scala | 22 +++++++++++++++ tests/pos/t3278.scala | 30 ++++++++++++++++++++ tests/pos/t3343.scala | 15 ++++++++++ tests/pos/t3411.scala | 8 ++++++ tests/pos/t344.scala | 12 ++++++++ 31 files changed, 236 insertions(+), 239 deletions(-) create mode 100644 tests/disabled/not-representable/pos/t3498-old.scala create mode 100644 tests/disabled/structural-type/pos/t3175-pos.scala create mode 100644 tests/disabled/structural-type/pos/t3363-new.scala create mode 100644 tests/disabled/structural-type/pos/t3363-old.scala delete mode 100644 tests/pending/pos/sammy_poly.scala delete mode 100644 tests/pending/pos/scoping1.scala delete mode 100644 tests/pending/pos/sealed-final.scala delete mode 100644 tests/pending/pos/self-type-override.scala delete mode 100644 tests/pending/pos/spec-sealed.scala delete mode 100644 tests/pending/pos/t3175-pos.scala delete mode 100644 tests/pending/pos/t319.scala delete mode 100644 tests/pending/pos/t3278.scala delete mode 100644 tests/pending/pos/t3343.scala delete mode 100644 tests/pending/pos/t3363-new.scala delete mode 100644 tests/pending/pos/t3363-old.scala delete mode 100644 tests/pending/pos/t3411.scala delete mode 100644 tests/pending/pos/t344.scala delete mode 100644 tests/pending/pos/t3498-old.scala create mode 100644 tests/pos/sammy_poly.scala create mode 100644 tests/pos/scoping1.scala create mode 100644 tests/pos/sealed-final.scala create mode 100644 tests/pos/spec-sealed.scala create mode 100644 tests/pos/t319.scala create mode 100644 tests/pos/t3278.scala create mode 100644 tests/pos/t3343.scala create mode 100644 tests/pos/t3411.scala create mode 100644 tests/pos/t344.scala diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 89ac2b6c4..3a863f013 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -83,7 +83,7 @@ class tests extends CompilerTest { @Test def neg_autoTupling2 = compileFile(negDir, "autoTuplingTest", xerrors = 4) @Test def neg_companions = compileFile(negDir, "companions", xerrors = 1) @Test def neg_over = compileFile(negDir, "over", xerrors = 1) - @Test def neg_overrides = compileFile(negDir, "overrides", xerrors = 7) + @Test def neg_overrides = compileFile(negDir, "overrides", xerrors = 8) @Test def neg_projections = compileFile(negDir, "projections", xerrors = 1) @Test def neg_i39 = compileFile(negDir, "i39", xerrors = 1) @Test def neg_i50_volatile = compileFile(negDir, "i50-volatile", xerrors = 4) diff --git a/tests/disabled/not-representable/pos/t3498-old.scala b/tests/disabled/not-representable/pos/t3498-old.scala new file mode 100644 index 000000000..118a8d849 --- /dev/null +++ b/tests/disabled/not-representable/pos/t3498-old.scala @@ -0,0 +1,15 @@ +abstract class A[T, @specialized(scala.Int) U : Manifest] { + def f(state: T): Array[U] +} + +abstract class B extends A[ Array[Byte], Int ] { + type T = Array[Byte] + type U = Int + + val N = 0 + + def f(state: T): Array[U] = + { + new Array[U](N + state(N)) + } +} diff --git a/tests/disabled/structural-type/pos/t3175-pos.scala b/tests/disabled/structural-type/pos/t3175-pos.scala new file mode 100644 index 000000000..89bbf8b5f --- /dev/null +++ b/tests/disabled/structural-type/pos/t3175-pos.scala @@ -0,0 +1,7 @@ +object Test { + def f(g:{val update:Unit}) = g.update + + def main(args: Array[String]): Unit = { + + } +} diff --git a/tests/disabled/structural-type/pos/t3363-new.scala b/tests/disabled/structural-type/pos/t3363-new.scala new file mode 100644 index 000000000..835d9471b --- /dev/null +++ b/tests/disabled/structural-type/pos/t3363-new.scala @@ -0,0 +1,20 @@ +import scala.reflect.runtime.universe._ + +object TestCase { + + //now matter if you put (abstract) class or trait it will fail in all cases + trait MapOps[T] + + //if fs was reduced to List (generic type with one parameter) then the code compiles + //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine + implicit def map2ops[T,F](fs: Map[T,F]): TestCase.MapOps[F]{val m: reflect.runtime.universe.TypeTag[T]; def is(xs: List[T]): List[List[T]]} = new MapOps[F] { + //if you remove this line, then code compiles + lazy val m: TypeTag[T] = sys.error("just something to make it compile") + def is(xs: List[T]) = List(xs) + } + + def main(args: Array[String]): Unit = { + println(Map(1 -> "2") is List(2)) + } + + } diff --git a/tests/disabled/structural-type/pos/t3363-old.scala b/tests/disabled/structural-type/pos/t3363-old.scala new file mode 100644 index 000000000..0088eff3d --- /dev/null +++ b/tests/disabled/structural-type/pos/t3363-old.scala @@ -0,0 +1,18 @@ +object TestCase { + + //now matter if you put (abstract) class or trait it will fail in all cases + trait MapOps[T] + + //if fs was reduced to List (generic type with one parameter) then the code compiles + //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine + implicit def map2ops[T,F](fs: Map[T,F]): TestCase.MapOps[F]{val m: Manifest[T]; def is(xs: List[T]): List[List[T]]} = new MapOps[F] { + //if you remove this line, then code compiles + lazy val m: Manifest[T] = sys.error("just something to make it compile") + def is(xs: List[T]) = List(xs) + } + + def main(args: Array[String]): Unit = { + println(Map(1 -> "2") is List(2)) + } + + } diff --git a/tests/neg/overrides.scala b/tests/neg/overrides.scala index 943cc8bc4..cffb5480a 100644 --- a/tests/neg/overrides.scala +++ b/tests/neg/overrides.scala @@ -79,3 +79,24 @@ class Y2 extends X2 { class X3 { override type T = A1 } + +package p3 { + +// Dotty change of rules: Toverrider#f does not +// override TCommon#f, hence the accidental override rule +// applies. +trait TCommon { + def f: String +} + +class C1 extends TCommon { + def f = "in C1" +} + +trait TOverrider { this: TCommon => + override def f = "in TOverrider" // The overridden self-type member... +} + +class C2 extends C1 with TOverrider // ... fails to override, here. + +} diff --git a/tests/pending/pos/sammy_poly.scala b/tests/pending/pos/sammy_poly.scala deleted file mode 100644 index f43fa292c..000000000 --- a/tests/pending/pos/sammy_poly.scala +++ /dev/null @@ -1,7 +0,0 @@ -// test synthesizeSAMFunction where the sam type is not fully defined -class T { - trait F[T, U] { def apply(x: T): U } - // NOTE: the f(x) desugaring for now assumes the single abstract method is called 'apply' - def app[T, U](x: T)(f: F[T, U]): U = f(x) - app(1)(x => List(x)) -} diff --git a/tests/pending/pos/scoping1.scala b/tests/pending/pos/scoping1.scala deleted file mode 100644 index 9fe1b5f3e..000000000 --- a/tests/pending/pos/scoping1.scala +++ /dev/null @@ -1,12 +0,0 @@ -object This extends App { - trait A { - def foo(): Unit - } - class C { self: A => - def bar() = this.foo() - } - class D extends C with A { - def foo() = () - } - val c: C = new D -} diff --git a/tests/pending/pos/sealed-final.scala b/tests/pending/pos/sealed-final.scala deleted file mode 100644 index bdedb5c1f..000000000 --- a/tests/pending/pos/sealed-final.scala +++ /dev/null @@ -1,14 +0,0 @@ -sealed abstract class Foo { - @inline def bar(x: Int) = x + 1 -} -object Foo { - def mkFoo(): Foo = new Baz2 -} - -object Baz1 extends Foo -final class Baz2 extends Foo - -object Test { - // bar should be inlined now - def f = Foo.mkFoo() bar 10 -} diff --git a/tests/pending/pos/self-type-override.scala b/tests/pending/pos/self-type-override.scala deleted file mode 100644 index 7c40ef37e..000000000 --- a/tests/pending/pos/self-type-override.scala +++ /dev/null @@ -1,13 +0,0 @@ -trait TCommon { - def f: String -} - -class C1 extends TCommon { - def f = "in C1" -} - -trait TOverrider { this: TCommon => - override def f = "in TOverrider" // The overridden self-type member... -} - -class C2 extends C1 with TOverrider // ... fails to override, here. diff --git a/tests/pending/pos/spec-sealed.scala b/tests/pending/pos/spec-sealed.scala deleted file mode 100644 index d7ecfaaab..000000000 --- a/tests/pending/pos/spec-sealed.scala +++ /dev/null @@ -1,32 +0,0 @@ -sealed abstract class MyList[@specialized +A] { - def head: A - def tail: MyList[A] - - def ::[@specialized B >: A](x: B): MyList[B] = - new Cons[B](x, this) -} - -case object MyNil extends MyList[Nothing] { - def head = sys.error("nil") - def tail = sys.error("nil") -} - -case class Cons[@specialized a](private val hd: a, tl: MyList[a]) extends MyList[a] { - def head = hd - def tail = tl -} - -abstract class IntList extends MyList[Int] - -object Main extends App { - val xs = 1 :: 2 :: 3 :: MyNil - println(xs) -} - -/* -final class ConsI(hd1: Int, tl1: MyList[Int]) extends Cons[Int](hd1, tl1) { - override val hd = hd1 - override val tl = tl1 -} -*/ -//class IntCons(_hd: Int, _tl: MyList[Int]) extends Cons[Int](_hd, _tl) diff --git a/tests/pending/pos/t3175-pos.scala b/tests/pending/pos/t3175-pos.scala deleted file mode 100644 index 89bbf8b5f..000000000 --- a/tests/pending/pos/t3175-pos.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test { - def f(g:{val update:Unit}) = g.update - - def main(args: Array[String]): Unit = { - - } -} diff --git a/tests/pending/pos/t319.scala b/tests/pending/pos/t319.scala deleted file mode 100644 index eed25eb84..000000000 --- a/tests/pending/pos/t319.scala +++ /dev/null @@ -1,21 +0,0 @@ -object test { - - trait A { type T; } - - trait B { type T; } - - /** def functor(x: A): B { type T = x.T } */ - abstract class functor() { - val arg: A; - val res: B { type T = arg.T } = - new B { type T = arg.T; }; - } - - val a = new A { type T = String }; - /** val b: B { type T = String } = functor(a) */ - val b: B { type T = String } = { - val tmp = new functor() { val arg = a }; - tmp.res - } - -} diff --git a/tests/pending/pos/t3278.scala b/tests/pending/pos/t3278.scala deleted file mode 100644 index 458070c5e..000000000 --- a/tests/pending/pos/t3278.scala +++ /dev/null @@ -1,15 +0,0 @@ -class Foo -class Test { - def update[B](x : B, b : Int): Unit = {} - def apply[B](x : B) = 1 -} - -object Test { - def main(a : Array[String]): Unit = { - val a = new Test - val f = new Foo - a(f) = 1 //works - a(f) = a(f) + 1 //works - a(f) += 1 //error: reassignment to val - } -} diff --git a/tests/pending/pos/t3343.scala b/tests/pending/pos/t3343.scala deleted file mode 100644 index 9d1bc9355..000000000 --- a/tests/pending/pos/t3343.scala +++ /dev/null @@ -1,15 +0,0 @@ -import scala.collection.mutable.{ Builder, ListBuffer } - -object Test { - class Converter[T] - object SimpleIntConverter extends Converter[Int] - - class TraversableConverter[T, Coll[X] <: Traversable[X]](converter: Converter[T], builder: Builder[T, Coll[T]]) extends Converter[Coll[T]] { - def convert(x: T): List[T] = List(x) - } - val tc: Converter[List[Int]] = new TraversableConverter(SimpleIntConverter, new ListBuffer[Int]) - val tc2 = new TraversableConverter(SimpleIntConverter, new ListBuffer[Int]) - - def main(args: Array[String]): Unit = { - } -} diff --git a/tests/pending/pos/t3363-new.scala b/tests/pending/pos/t3363-new.scala deleted file mode 100644 index f935cfe1a..000000000 --- a/tests/pending/pos/t3363-new.scala +++ /dev/null @@ -1,20 +0,0 @@ -import scala.reflect.runtime.universe._ - -object TestCase { - - //now matter if you put (abstract) class or trait it will fail in all cases - trait MapOps[T] - - //if fs was reduced to List (generic type with one parameter) then the code compiles - //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine - implicit def map2ops[T,F](fs: Map[T,F]): TestCase.MapOps[F]{lazy val m: reflect.runtime.universe.TypeTag[T]; def is(xs: List[T]): List[List[T]]} = new MapOps[F] { - //if you remove this line, then code compiles - lazy val m: TypeTag[T] = sys.error("just something to make it compile") - def is(xs: List[T]) = List(xs) - } - - def main(args: Array[String]): Unit = { - println(Map(1 -> "2") is List(2)) - } - - } diff --git a/tests/pending/pos/t3363-old.scala b/tests/pending/pos/t3363-old.scala deleted file mode 100644 index 8e54d4b4a..000000000 --- a/tests/pending/pos/t3363-old.scala +++ /dev/null @@ -1,18 +0,0 @@ -object TestCase { - - //now matter if you put (abstract) class or trait it will fail in all cases - trait MapOps[T] - - //if fs was reduced to List (generic type with one parameter) then the code compiles - //if you inherit from MapOps[T] instead of MapOps[F] then code compiles fine - implicit def map2ops[T,F](fs: Map[T,F]): TestCase.MapOps[F]{lazy val m: Manifest[T]; def is(xs: List[T]): List[List[T]]} = new MapOps[F] { - //if you remove this line, then code compiles - lazy val m: Manifest[T] = sys.error("just something to make it compile") - def is(xs: List[T]) = List(xs) - } - - def main(args: Array[String]): Unit = { - println(Map(1 -> "2") is List(2)) - } - - } diff --git a/tests/pending/pos/t3411.scala b/tests/pending/pos/t3411.scala deleted file mode 100644 index 6d46be4e4..000000000 --- a/tests/pending/pos/t3411.scala +++ /dev/null @@ -1,8 +0,0 @@ -object A { - def g(c: PartialFunction[Any,Unit]): Unit = {} - - def f: Unit = { - lazy val x = 0 - g { case `x` => } - } -} diff --git a/tests/pending/pos/t344.scala b/tests/pending/pos/t344.scala deleted file mode 100644 index 449a763af..000000000 --- a/tests/pending/pos/t344.scala +++ /dev/null @@ -1,12 +0,0 @@ -object Bug { - class A; - case class A1() extends A; - case class A2() extends A; - def f: A = - if (true) - A1() - else { - val a = if (true) A1() else A2(); - a - }; -} diff --git a/tests/pending/pos/t3480.scala b/tests/pending/pos/t3480.scala index d9a092e8a..f04ea2933 100644 --- a/tests/pending/pos/t3480.scala +++ b/tests/pending/pos/t3480.scala @@ -1,4 +1,4 @@ object Test { - val List(_*) = List(1) + val List(_: _*) = List(1) val Array( who, what : _* ) = "Eclipse plugin cannot not handle this" split (" ") } diff --git a/tests/pending/pos/t3498-old.scala b/tests/pending/pos/t3498-old.scala deleted file mode 100644 index 118a8d849..000000000 --- a/tests/pending/pos/t3498-old.scala +++ /dev/null @@ -1,15 +0,0 @@ -abstract class A[T, @specialized(scala.Int) U : Manifest] { - def f(state: T): Array[U] -} - -abstract class B extends A[ Array[Byte], Int ] { - type T = Array[Byte] - type U = Int - - val N = 0 - - def f(state: T): Array[U] = - { - new Array[U](N + state(N)) - } -} diff --git a/tests/pos/sammy_poly.scala b/tests/pos/sammy_poly.scala new file mode 100644 index 000000000..f43fa292c --- /dev/null +++ b/tests/pos/sammy_poly.scala @@ -0,0 +1,7 @@ +// test synthesizeSAMFunction where the sam type is not fully defined +class T { + trait F[T, U] { def apply(x: T): U } + // NOTE: the f(x) desugaring for now assumes the single abstract method is called 'apply' + def app[T, U](x: T)(f: F[T, U]): U = f(x) + app(1)(x => List(x)) +} diff --git a/tests/pos/scoping1.scala b/tests/pos/scoping1.scala new file mode 100644 index 000000000..83ad1357a --- /dev/null +++ b/tests/pos/scoping1.scala @@ -0,0 +1,12 @@ +object This extends App { + trait A { + def foo(): Unit + } + abstract class C { self: A => + def bar() = this.foo() + } + class D extends C with A { + def foo() = () + } + val c: C = new D +} diff --git a/tests/pos/sealed-final.scala b/tests/pos/sealed-final.scala new file mode 100644 index 000000000..bdedb5c1f --- /dev/null +++ b/tests/pos/sealed-final.scala @@ -0,0 +1,14 @@ +sealed abstract class Foo { + @inline def bar(x: Int) = x + 1 +} +object Foo { + def mkFoo(): Foo = new Baz2 +} + +object Baz1 extends Foo +final class Baz2 extends Foo + +object Test { + // bar should be inlined now + def f = Foo.mkFoo() bar 10 +} diff --git a/tests/pos/spec-sealed.scala b/tests/pos/spec-sealed.scala new file mode 100644 index 000000000..d7ecfaaab --- /dev/null +++ b/tests/pos/spec-sealed.scala @@ -0,0 +1,32 @@ +sealed abstract class MyList[@specialized +A] { + def head: A + def tail: MyList[A] + + def ::[@specialized B >: A](x: B): MyList[B] = + new Cons[B](x, this) +} + +case object MyNil extends MyList[Nothing] { + def head = sys.error("nil") + def tail = sys.error("nil") +} + +case class Cons[@specialized a](private val hd: a, tl: MyList[a]) extends MyList[a] { + def head = hd + def tail = tl +} + +abstract class IntList extends MyList[Int] + +object Main extends App { + val xs = 1 :: 2 :: 3 :: MyNil + println(xs) +} + +/* +final class ConsI(hd1: Int, tl1: MyList[Int]) extends Cons[Int](hd1, tl1) { + override val hd = hd1 + override val tl = tl1 +} +*/ +//class IntCons(_hd: Int, _tl: MyList[Int]) extends Cons[Int](_hd, _tl) diff --git a/tests/pos/subtyping.scala b/tests/pos/subtyping.scala index 29d830dd2..e65bdd16f 100644 --- a/tests/pos/subtyping.scala +++ b/tests/pos/subtyping.scala @@ -1,32 +1,5 @@ -class A { - def test1(): Unit = { - implicitly[this.type <:< this.type] - implicitly[this.type <:< A] - } -} object test { - def tag1[T](x: T): String & T = ??? - def tag2[T](x: T): T & String = ??? - - val x1: Int & String = tag1(0) - val x2: Int & String = tag2(0) - val x3: String & Int = tag1(0) - val x4: String & Int = tag2(0) - -} - -object test2 { - - class A - class B - - val x: A | B = ??? - val y: B | A = x - - val a: A & B = ??? - val b: B & A = a + val x: Int = 1 } - - diff --git a/tests/pos/t319.scala b/tests/pos/t319.scala new file mode 100644 index 000000000..5c06f4db0 --- /dev/null +++ b/tests/pos/t319.scala @@ -0,0 +1,22 @@ +object test { + + trait A { type T; } + + trait B { type T; } + + /** def functor(x: A): B { type T = x.T } */ + abstract class functor() { + val arg: A; + val res: B { type T = arg.T } = + new B { type T = arg.T; }; + } + + val a = new A { type T = String }; + /** val b: B { type T = String } = functor(a) */ + val b: B { type T = String } = { + val tmp = new functor() { val arg: A { type T = String } = a }; + // Dotty deviaton: arg needs an explicit type here, or else the inherited type `A` would be assumed. + tmp.res + } + +} diff --git a/tests/pos/t3278.scala b/tests/pos/t3278.scala new file mode 100644 index 000000000..05bfbc146 --- /dev/null +++ b/tests/pos/t3278.scala @@ -0,0 +1,30 @@ +class Foo +class Test { + def update[B](x : B, b : Int): Unit = {} + def apply[B](x : B) = 1 +} +class Test2 { + type B = Foo + def update(x : B, b : Int): Unit = {} + def apply(x : B) = 1 +} + +object Test { + def main(a : Array[String]): Unit = { + val a = new Test + val f = new Foo + a(f) = 1 //works + a(f) = a(f) + 1 //works + a(f) += 1 //error: reassignment to val + } +} +object Test2 { + def main(args : Array[String]): Unit = { + args(0) += "a" + val a = new Test2 + val f = new Foo + a(f) = 1 //works + a(f) = a(f) + 1 //works + a(f) += 1 //error: reassignment to val + } +} diff --git a/tests/pos/t3343.scala b/tests/pos/t3343.scala new file mode 100644 index 000000000..9d1bc9355 --- /dev/null +++ b/tests/pos/t3343.scala @@ -0,0 +1,15 @@ +import scala.collection.mutable.{ Builder, ListBuffer } + +object Test { + class Converter[T] + object SimpleIntConverter extends Converter[Int] + + class TraversableConverter[T, Coll[X] <: Traversable[X]](converter: Converter[T], builder: Builder[T, Coll[T]]) extends Converter[Coll[T]] { + def convert(x: T): List[T] = List(x) + } + val tc: Converter[List[Int]] = new TraversableConverter(SimpleIntConverter, new ListBuffer[Int]) + val tc2 = new TraversableConverter(SimpleIntConverter, new ListBuffer[Int]) + + def main(args: Array[String]): Unit = { + } +} diff --git a/tests/pos/t3411.scala b/tests/pos/t3411.scala new file mode 100644 index 000000000..6d46be4e4 --- /dev/null +++ b/tests/pos/t3411.scala @@ -0,0 +1,8 @@ +object A { + def g(c: PartialFunction[Any,Unit]): Unit = {} + + def f: Unit = { + lazy val x = 0 + g { case `x` => } + } +} diff --git a/tests/pos/t344.scala b/tests/pos/t344.scala new file mode 100644 index 000000000..449a763af --- /dev/null +++ b/tests/pos/t344.scala @@ -0,0 +1,12 @@ +object Bug { + class A; + case class A1() extends A; + case class A2() extends A; + def f: A = + if (true) + A1() + else { + val a = if (true) A1() else A2(); + a + }; +} -- cgit v1.2.3