diff options
author | Martin Odersky <odersky@gmail.com> | 2015-01-27 11:38:50 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-01-27 11:38:50 +0100 |
commit | 57b616c1a7adc78dd46cb3ae5545e312c11e69be (patch) | |
tree | 105089136359d4114b2b16f33c45dfac70b695fe /tests | |
parent | f59d1d33d6e9dbb2988f165dc9b5b03792218a4c (diff) | |
download | dotty-57b616c1a7adc78dd46cb3ae5545e312c11e69be.tar.gz dotty-57b616c1a7adc78dd46cb3ae5545e312c11e69be.tar.bz2 dotty-57b616c1a7adc78dd46cb3ae5545e312c11e69be.zip |
New tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/t3020.scala | 9 | ||||
-rw-r--r-- | tests/pos/t3037.scala | 13 | ||||
-rw-r--r-- | tests/pos/t304.scala | 5 | ||||
-rw-r--r-- | tests/pos/t3106.scala | 7 | ||||
-rw-r--r-- | tests/pos/t3137.scala | 17 | ||||
-rw-r--r-- | tests/pos/t3152.scala | 20 | ||||
-rwxr-xr-x | tests/pos/t3174.scala | 14 | ||||
-rw-r--r-- | tests/pos/t3177.scala | 39 | ||||
-rw-r--r-- | tests/pos/t8023.scala | 9 | ||||
-rw-r--r-- | tests/pos/t9004.scala | 29 |
10 files changed, 162 insertions, 0 deletions
diff --git a/tests/pos/t3020.scala b/tests/pos/t3020.scala new file mode 100644 index 000000000..016563e27 --- /dev/null +++ b/tests/pos/t3020.scala @@ -0,0 +1,9 @@ +object Test { + def main(args: Array[String]): Unit = { + var x = true + + ( { if (x) new scala.util.Random() } .asInstanceOf[Runnable] ) + } +} + + diff --git a/tests/pos/t3037.scala b/tests/pos/t3037.scala new file mode 100644 index 000000000..b71ffe041 --- /dev/null +++ b/tests/pos/t3037.scala @@ -0,0 +1,13 @@ +package test + +object A { + println(("a" match { + case "a" => 1 + case _ => "a" + }).asInstanceOf[Object]) + def foo[T](x: T) = x + var x: Int = 1 + var y: Long = 1L + x = foo(x) + y = foo(y) +} diff --git a/tests/pos/t304.scala b/tests/pos/t304.scala new file mode 100644 index 000000000..76da44157 --- /dev/null +++ b/tests/pos/t304.scala @@ -0,0 +1,5 @@ +object O { + def f1 = -1; + def f2 = 0-1; + def f3 = -f1; +} diff --git a/tests/pos/t3106.scala b/tests/pos/t3106.scala new file mode 100644 index 000000000..a9591d0aa --- /dev/null +++ b/tests/pos/t3106.scala @@ -0,0 +1,7 @@ +class Sample[A] (val d0: ((A,A)) => A) {} + +object Sample { + implicit def apply[A] (x:A): Sample[A] = { + new Sample(p => p._1) + } +} diff --git a/tests/pos/t3137.scala b/tests/pos/t3137.scala new file mode 100644 index 000000000..cb7317af0 --- /dev/null +++ b/tests/pos/t3137.scala @@ -0,0 +1,17 @@ +trait A { + val C: Any +} + +class B extends A { + class C + object C +} + +trait AA { + type C + def C: Int => C +} + +class BB extends AA { + case class C(v: Int) +} diff --git a/tests/pos/t3152.scala b/tests/pos/t3152.scala new file mode 100644 index 000000000..3d1dcbd6f --- /dev/null +++ b/tests/pos/t3152.scala @@ -0,0 +1,20 @@ +trait Applicative[M[_]] + +sealed trait MA[M[_], A] { + def sequence[N[_], B](implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = sys.error("stub") + // def sequence3[N[_], B]()(implicit a: A <:< N[B], n: Applicative[N]): N[M[B]] = sys.error("stub") +} + +object test { + implicit def ListMA[A](l: List[A]): MA[List, A] = sys.error("stub") + implicit val ao: Applicative[Option] = sys.error("stub") + + /* This compiles OK: + (Nil: List[Option[Int]]).sequence3(): Option[List[Int]] + */ + + // BUG: error: immutable is not an enclosing class + // !!! No line number is reported with the error + (Nil: List[Option[Int]]).sequence: Option[List[Int]] + (List[Option[Int]]()).sequence: Option[List[Int]] +} diff --git a/tests/pos/t3174.scala b/tests/pos/t3174.scala new file mode 100755 index 000000000..8d9b2578d --- /dev/null +++ b/tests/pos/t3174.scala @@ -0,0 +1,14 @@ +object test { + def method(): Unit = { + class Foo extends AnyRef { + object Color { + object Blue + } + + class Board { + val grid = Color.Blue + } + } + new Foo + } + } diff --git a/tests/pos/t3177.scala b/tests/pos/t3177.scala new file mode 100644 index 000000000..12dfce6ee --- /dev/null +++ b/tests/pos/t3177.scala @@ -0,0 +1,39 @@ +trait InvariantFunctor[F[_]] { + def xmap[A, B](ma: F[A], f: A => B, g: B => A): F[B] +} + +object InvariantFunctor { + import Endo._ + + implicit val EndoInvariantFunctor: InvariantFunctor[Endo] = new InvariantFunctor[Endo] { + def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + } + + // The definition about fails with: + // anon-type.scala:9: error: not found: value b + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + // ^ + // anon-type.scala:8: error: not found: type $anon + // implicit val EndoInvariantFunctor = new InvariantFunctor[Endo] { + // ^ + + + // These both work: + // implicit val EndoInvariantFunctorAscribed: InvariantFunctor[Endo] = new InvariantFunctor[Endo] { + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b))) + // } + // + // implicit val EndoInvariantFunctorStubbed = new InvariantFunctor[Endo] { + // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = error("stub") + // } +} + +trait Endo[X] + +object Endo { + implicit def EndoTo[A](f: A => A): Endo[A] = new Endo[A] { + def apply(a: A) = f(a) + } + + implicit def EndoFrom[A](e: Endo[A]): A => A = e.apply(_) +} diff --git a/tests/pos/t8023.scala b/tests/pos/t8023.scala new file mode 100644 index 000000000..66d478abd --- /dev/null +++ b/tests/pos/t8023.scala @@ -0,0 +1,9 @@ +class C[K] +class D[K] + +object Test3 { + def foo = (null: Any) match { + case a: C[k] => new C[k]() // this one worked before as the info of `A` was complete + // () + } +} diff --git a/tests/pos/t9004.scala b/tests/pos/t9004.scala new file mode 100644 index 000000000..d591bc852 --- /dev/null +++ b/tests/pos/t9004.scala @@ -0,0 +1,29 @@ +object Main { + trait AA[RR] { type R = RR; def r: R } + + def test1(a: AA[_]) = { + val f = () => a.r + // The tree a.r is given the type `a.R` which normalizes + // to B', where B' is a distinct symbol ("captured existential skolem") + // to substitute for the reference to an existential skolem of B. + // + // inference of the result type of the function computes the + // packed type of tree `a.r` to make sure that terms and types + // local to the body of the function don't leak into its result + // type. The captured existential skolem is considered to be local + // so it is abstracted to its upper bound, Any. + // + // However, the packedType transformation need not have even considered + // B', as it is clear that the type `a.R` is not local to the function + // body! + f: (() => a.R) + + // The workaround is to annotate the function type, rather than + // relying in inference. + val g: (() => a.R) = () => a.r + val g2 = () => a.r + + () + } + // typer debug trace: http://rawgit.com/retronym/d5aeaf8e0a4a2e6eef4b/raw/out.html +} |