diff options
author | Martin Odersky <odersky@gmail.com> | 2014-05-07 19:09:52 +0200 |
---|---|---|
committer | Samuel Gruetter <samuel.gruetter@epfl.ch> | 2014-05-20 13:38:49 +0200 |
commit | 27081ae59ba5b00b6ae05bb3cdd9c3ff7db0a28e (patch) | |
tree | ab350b5ef2d7b9adc29fe715be2efb4681970127 /tests/new | |
parent | fb3dba1bac13a755d2304928cbd49e7dde6f1bf9 (diff) | |
download | dotty-27081ae59ba5b00b6ae05bb3cdd9c3ff7db0a28e.tar.gz dotty-27081ae59ba5b00b6ae05bb3cdd9c3ff7db0a28e.tar.bz2 dotty-27081ae59ba5b00b6ae05bb3cdd9c3ff7db0a28e.zip |
Tests pos/23xx to 24xx.
Diffstat (limited to 'tests/new')
-rw-r--r-- | tests/new/t2405.scala | 23 | ||||
-rw-r--r-- | tests/new/t2421.scala | 14 | ||||
-rw-r--r-- | tests/new/t2421b_pos.scala | 19 | ||||
-rw-r--r-- | tests/new/t2421c.scala | 17 | ||||
-rwxr-xr-x | tests/new/t2425.scala | 15 | ||||
-rw-r--r-- | tests/new/t2435.scala | 27 | ||||
-rw-r--r-- | tests/new/t2441pos.scala | 8 | ||||
-rw-r--r-- | tests/new/t2444.scala | 15 | ||||
-rw-r--r-- | tests/new/t245.scala | 18 | ||||
-rw-r--r-- | tests/new/t247.scala | 26 | ||||
-rwxr-xr-x | tests/new/t2484.scala | 19 | ||||
-rw-r--r-- | tests/new/t2486.scala | 3 |
12 files changed, 204 insertions, 0 deletions
diff --git a/tests/new/t2405.scala b/tests/new/t2405.scala new file mode 100644 index 000000000..224b2ce83 --- /dev/null +++ b/tests/new/t2405.scala @@ -0,0 +1,23 @@ +object A { implicit val x: Int = 1 } + +// Problem as stated in the ticket. +object Test1 { + import A.{x => y} + implicitly[Int] +} + +// Testing for the absense of shadowing #1. +object Test2 { + import A.{x => y} + val x = 2 + implicitly[Int] +} + +// Testing for the absense of shadowing #2. +object Test3 { + { + import A.{x => y} + def x: Int = 0 + implicitly[Int] + } +} diff --git a/tests/new/t2421.scala b/tests/new/t2421.scala new file mode 100644 index 000000000..2544a1cb3 --- /dev/null +++ b/tests/new/t2421.scala @@ -0,0 +1,14 @@ +object Test { + abstract class <~<[-From, +To] extends (From => To) + implicit def trivial[A]: A <~< A = sys.error("") + + + trait Forcible[T] + implicit val forcibleInt: (Int <~< Forcible[Int]) = sys.error("") + + def headProxy[P <: Forcible[Int]](implicit w: Int <~< P): P = sys.error("") + + headProxy + // trivial[Int] should not be considered a valid implicit, since w would have type Int <~< Int, + // and headProxy's type parameter P cannot be instantiated to Int +} diff --git a/tests/new/t2421b_pos.scala b/tests/new/t2421b_pos.scala new file mode 100644 index 000000000..679b8a8d6 --- /dev/null +++ b/tests/new/t2421b_pos.scala @@ -0,0 +1,19 @@ +object Test { + class A + class B + class C + class F[X] + + def f(implicit aa: F[A]) = println(aa) + + implicit def a : F[A] = new F[A]() + implicit def b[X <: B]: Test.F[X] = new F[X]() + + f +} +/* bug: +error: ambiguous implicit values: + both method b in object Test1 of type [X <: Test1.B]Test1.F[X] + and method a in object Test1 of type => Test1.F[Test1.A] + match expected type Test1.F[Test1.A] +*/ diff --git a/tests/new/t2421c.scala b/tests/new/t2421c.scala new file mode 100644 index 000000000..bd24cacd7 --- /dev/null +++ b/tests/new/t2421c.scala @@ -0,0 +1,17 @@ +object Test { + class A + class B + class C + class F[X] + + def f(implicit aa: F[A]) = println(aa) + + implicit def a : F[A] = new F[A]() + + // generalised from t2421b to verify we check enough + class G[X] + implicit def g[X]: Test.G[X] = new G[X]() + implicit def b[X <: B](implicit mx: G[X]): Test.F[X] = new F[X]() + + f +} diff --git a/tests/new/t2425.scala b/tests/new/t2425.scala new file mode 100755 index 000000000..477d5467a --- /dev/null +++ b/tests/new/t2425.scala @@ -0,0 +1,15 @@ +trait B +class D extends B +object Test extends App { + def foo[T](bar: T) = { + bar match { + case _: Array[Array[_]] => println("array 2d") + case _: Array[_] => println("array 1d") + case _ => println("something else") + } + } + foo(Array.fill(10)(2)) + foo(Array.fill(10, 10)(2)) + foo(Array.fill(10, 10, 10)(2)) + foo(List(1, 2, 3)) +} diff --git a/tests/new/t2435.scala b/tests/new/t2435.scala new file mode 100644 index 000000000..697e9e1f2 --- /dev/null +++ b/tests/new/t2435.scala @@ -0,0 +1,27 @@ +object Bug { + abstract class FChain { + type T + + def chain(constant:String) = + new FConstant[this.type](constant, this) //removing [this.type], everything compiles + } + + case class FConstant[E <: FChain](constant:String, tail:E) extends FChain { + type T = tail.T + } + + object FNil extends FChain { + type T = Unit + } + +} + +object Test { + import Bug._ + println("Compiles:") + val a1 = FNil.chain("a").chain("a") + val a2 = a1.chain("a") + + println("\nDoesn't compile:") + val a = FNil.chain("a").chain("a").chain("a") +} diff --git a/tests/new/t2441pos.scala b/tests/new/t2441pos.scala new file mode 100644 index 000000000..25eb2232c --- /dev/null +++ b/tests/new/t2441pos.scala @@ -0,0 +1,8 @@ +abstract class A { + private def foo = List(1, 2) +} +trait B extends A { + private def foo = List("a", "b") + // However it compiles correctly if the type is given: + // private def foo: List[String] = List("a", "b") +} diff --git a/tests/new/t2444.scala b/tests/new/t2444.scala new file mode 100644 index 000000000..fac1e95d0 --- /dev/null +++ b/tests/new/t2444.scala @@ -0,0 +1,15 @@ +object Test { + + trait Foo + + class Bar { + object baz extends Foo + } + + def frob[P1, P2<:Foo](f:P1 => P2) = () + + def main(args:Array[String]) : Unit = { + frob((p:Bar) => p.baz) + } + +} diff --git a/tests/new/t245.scala b/tests/new/t245.scala new file mode 100644 index 000000000..570ac4178 --- /dev/null +++ b/tests/new/t245.scala @@ -0,0 +1,18 @@ +class Value {} + +object Test { + + implicit def view(v: Value): Int = 0 + + def foo(i: Int): Int = 0 + + def fun0 : Value = null + def fun0(i: Int ): Value = null + + def fun1(i: Int ): Value = null + def fun1(l: Long): Value = null + + foo(fun0 ); + foo(fun1(new Value)); + +} diff --git a/tests/new/t247.scala b/tests/new/t247.scala new file mode 100644 index 000000000..fdcafeb2c --- /dev/null +++ b/tests/new/t247.scala @@ -0,0 +1,26 @@ +class Order[t](less:(t,t) => Boolean,equal:(t,t) => Boolean) {} + +trait Map[A, B] extends scala.collection.Map[A, B] { + val factory:MapFactory[A] +} +abstract class MapFactory[A] { + def Empty[B]:Map[A,B]; +} + +class TreeMapFactory[KEY](newOrder:Order[KEY]) extends MapFactory[KEY] { + val order = newOrder; + def Empty[V] = new TreeMap[KEY,V](new TreeMapFactory[KEY](order)); +} + +class Tree[KEY,Entry](order:Order[KEY]) { + def size =0; +} + +class TreeMap[KEY,VALUE](_factory:TreeMapFactory[KEY]) extends Tree[KEY,Tuple2[KEY,VALUE]](_factory.order) with scala.collection.DefaultMap[KEY, VALUE] with Map[KEY, VALUE] { + val factory = _factory + val order = _factory.order; + def this(newOrder:Order[KEY]) = this(new TreeMapFactory[KEY](newOrder)); + def get(key:KEY) = null; + def iterator:Iterator[Tuple2[KEY,VALUE]] = null; + override def size = super[Tree].size +} diff --git a/tests/new/t2484.scala b/tests/new/t2484.scala new file mode 100755 index 000000000..15165c247 --- /dev/null +++ b/tests/new/t2484.scala @@ -0,0 +1,19 @@ +import concurrent.ExecutionContext.Implicits.global + +class Admin extends javax.swing.JApplet { + val jScrollPane = new javax.swing.JScrollPane (null, 0, 0) + def t2484: Unit = { + scala.concurrent.Future {jScrollPane.synchronized { + def someFunction () = {} + //scala.concurrent.ops.spawn {someFunction ()} + jScrollPane.addComponentListener (new java.awt.event.ComponentAdapter {override def componentShown (e: java.awt.event.ComponentEvent) = { + someFunction (); jScrollPane.removeComponentListener (this)}}) + }} + } +} +// t2630.scala +object Test { + def meh(xs: List[Any]): Unit = { + xs map { x => (new AnyRef {}) } + } +} diff --git a/tests/new/t2486.scala b/tests/new/t2486.scala new file mode 100644 index 000000000..69fe4c127 --- /dev/null +++ b/tests/new/t2486.scala @@ -0,0 +1,3 @@ +class A[T] +class B extends A[Int] +class C[T] extends A[T] { def f(t: A[T]) = t match { case x: B => () } } |