diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t5803.check | 4 | ||||
-rw-r--r-- | test/files/neg/t5803.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t5259.scala | 21 | ||||
-rw-r--r-- | test/files/run/enrich-gentraversable.check | 4 | ||||
-rw-r--r-- | test/files/run/enrich-gentraversable.scala | 30 | ||||
-rw-r--r-- | test/files/run/t5610.check | 6 | ||||
-rw-r--r-- | test/files/run/t5610.scala | 30 |
7 files changed, 99 insertions, 0 deletions
diff --git a/test/files/neg/t5803.check b/test/files/neg/t5803.check new file mode 100644 index 0000000000..6a2de2e1df --- /dev/null +++ b/test/files/neg/t5803.check @@ -0,0 +1,4 @@ +t5803.scala:3: error: could not find implicit value for parameter ev: Nothing + new Foo(): String + ^ +one error found diff --git a/test/files/neg/t5803.scala b/test/files/neg/t5803.scala new file mode 100644 index 0000000000..f818272f86 --- /dev/null +++ b/test/files/neg/t5803.scala @@ -0,0 +1,4 @@ +object Test { + class Foo()(implicit ev: Nothing) + new Foo(): String +} diff --git a/test/files/pos/t5259.scala b/test/files/pos/t5259.scala new file mode 100644 index 0000000000..d33c4dd6a7 --- /dev/null +++ b/test/files/pos/t5259.scala @@ -0,0 +1,21 @@ +class A[T] +class B { + def m(a: A[this.type] = new A[this.type]) { } +} + +class C { + def foo(a: Int, b: Int = 0) = 0 + def foo() = 0 +} + +object Test { + def newB = new B + newB.m() + + val stableB = new B + stableB.m() + + def f { + println((new C).foo(0)) + } +} diff --git a/test/files/run/enrich-gentraversable.check b/test/files/run/enrich-gentraversable.check new file mode 100644 index 0000000000..348b38d6a4 --- /dev/null +++ b/test/files/run/enrich-gentraversable.check @@ -0,0 +1,4 @@ +List(2, 4) +Array(2, 4) +HW +Vector(72, 108, 108, 32, 114, 108, 100) diff --git a/test/files/run/enrich-gentraversable.scala b/test/files/run/enrich-gentraversable.scala new file mode 100644 index 0000000000..c9320ff985 --- /dev/null +++ b/test/files/run/enrich-gentraversable.scala @@ -0,0 +1,30 @@ +object Test extends App { + import scala.collection.generic.{ CanBuildFrom, FromRepr, HasElem } + + def typed[T](t : => T) {} + + class FilterMapImpl[A, Repr](val r : Repr)(implicit hasElem : HasElem[Repr, A]) { + def filterMap[B, That](f : A => Option[B])(implicit cbf : CanBuildFrom[Repr, B, That]) : That = r.flatMap(f(_).toSeq) + } + + implicit def filterMap[Repr : FromRepr](r : Repr) = new FilterMapImpl(r) + + val l = List(1, 2, 3, 4, 5) + val fml = l.filterMap(i => if(i % 2 == 0) Some(i) else None) + typed[List[Int]](fml) + println(fml) + + val a = Array(1, 2, 3, 4, 5) + val fma = a.filterMap(i => if(i % 2 == 0) Some(i) else None) + typed[Array[Int]](fma) + println(fma.deep) + + val s = "Hello World" + val fms1 = s.filterMap(c => if(c >= 'A' && c <= 'Z') Some(c) else None) + typed[String](fms1) + println(fms1) + + val fms2 = s.filterMap(c =>if(c % 2 == 0) Some(c.toInt) else None) + typed[IndexedSeq[Int]](fms2) + println(fms2) +} diff --git a/test/files/run/t5610.check b/test/files/run/t5610.check new file mode 100644 index 0000000000..023f18d8f1 --- /dev/null +++ b/test/files/run/t5610.check @@ -0,0 +1,6 @@ +some string +some string +some string +some string +List(2, 3) +List(5, 6) diff --git a/test/files/run/t5610.scala b/test/files/run/t5610.scala new file mode 100644 index 0000000000..f62b2df6b4 --- /dev/null +++ b/test/files/run/t5610.scala @@ -0,0 +1,30 @@ +object Test { + def main(args: Array[String]): Unit = { + var test: String = null + val fun1: Int => () => Unit = foo(test) _ + val fun2: Int => () => Unit = foo(test)(_) + val fun3: Int => () => Unit = { + lazy val eta1: String = test + (dummy: Int) => foo(eta1)(dummy) + } + val fun4: Int => () => Unit = { + val eta1: () => String = () => test + (dummy: Int) => foo(eta1())(dummy) + } + test = "some string" + fun1(1)() + fun2(1)() + fun3(1)() + fun4(1)() + + val f: (String, Int*) => Unit = m(2, 3) + f("", 5, 6) + } + + def foo(s: => String)(dummy: Int) = () => println(s) + + def m(a: Int*)(z: String, b: Int*) { + println(a.toList) + println(b.toList) + } +} |