diff options
author | odersky <odersky@gmail.com> | 2015-02-07 18:03:01 +0100 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2015-02-07 18:03:01 +0100 |
commit | 9641b2a417f203b5c2e88e6330b2230713471307 (patch) | |
tree | 7509a675738c13a428d2ecb5a371d242213a4849 /tests/pos | |
parent | 329b6bfa9929c984b40368a1cc5f2f8cdc15b6c8 (diff) | |
parent | 976ed6fd0aa4f0dd3da54889c4d85ef856f6531f (diff) | |
download | dotty-9641b2a417f203b5c2e88e6330b2230713471307.tar.gz dotty-9641b2a417f203b5c2e88e6330b2230713471307.tar.bz2 dotty-9641b2a417f203b5c2e88e6330b2230713471307.zip |
Merge pull request #339 from dotty-staging/fix/#329-and-others
Fix/#329 and others
Diffstat (limited to 'tests/pos')
-rw-r--r-- | tests/pos/sammy_poly.scala | 7 | ||||
-rw-r--r-- | tests/pos/scoping1.scala | 12 | ||||
-rw-r--r-- | tests/pos/sealed-final.scala | 14 | ||||
-rw-r--r-- | tests/pos/spec-sealed.scala | 32 | ||||
-rw-r--r-- | tests/pos/subtyping.scala | 29 | ||||
-rw-r--r-- | tests/pos/t319.scala | 22 | ||||
-rw-r--r-- | tests/pos/t3252.scala | 15 | ||||
-rw-r--r-- | tests/pos/t3278.scala | 30 | ||||
-rw-r--r-- | tests/pos/t3343.scala | 15 | ||||
-rw-r--r-- | tests/pos/t3411.scala | 8 | ||||
-rw-r--r-- | tests/pos/t344.scala | 12 |
11 files changed, 168 insertions, 28 deletions
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/t3252.scala b/tests/pos/t3252.scala new file mode 100644 index 000000000..3ecc1e7ce --- /dev/null +++ b/tests/pos/t3252.scala @@ -0,0 +1,15 @@ +class A { + def f(x : Boolean) : Thread = { + g { + x match { + case false => + B.h { } + } + } + } + + private def g[T](block : => T) = sys.error("") +} +object B { + def h(block : => Unit) : Nothing = sys.error("") +} 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 + }; +} |