summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-10-12 09:41:13 +0000
committerMartin Odersky <odersky@gmail.com>2009-10-12 09:41:13 +0000
commitf75ee36c6fb4386eb89f19c40dfa000076aa9307 (patch)
tree1c43adb5b8b194a7a9c14d4ad7cdca04261cda68 /test/files/pos
parentbf9ca9a2b7455164c335a48826143749b6b107eb (diff)
downloadscala-f75ee36c6fb4386eb89f19c40dfa000076aa9307.tar.gz
scala-f75ee36c6fb4386eb89f19c40dfa000076aa9307.tar.bz2
scala-f75ee36c6fb4386eb89f19c40dfa000076aa9307.zip
reverted immutable.Vector because it gave rando...
reverted immutable.Vector because it gave random build errors on my machine. Fixed various tickets, updated test and check files.
Diffstat (limited to 'test/files/pos')
-rwxr-xr-xtest/files/pos/lexical.scala9
-rwxr-xr-xtest/files/pos/packageobjs.scala8
-rw-r--r--test/files/pos/strings.scala4
-rw-r--r--test/files/pos/t2023.scala16
-rwxr-xr-xtest/files/pos/t2060.scala44
-rwxr-xr-xtest/files/pos/t2425.scala15
6 files changed, 96 insertions, 0 deletions
diff --git a/test/files/pos/lexical.scala b/test/files/pos/lexical.scala
new file mode 100755
index 0000000000..034b84bf0f
--- /dev/null
+++ b/test/files/pos/lexical.scala
@@ -0,0 +1,9 @@
+// #2081
+class RichInt(n: Int) {
+ def days = 1000*60*60*24*n
+}
+
+object Test extends Application {
+ implicit def RichInt(n: Int): RichInt = new RichInt(n)
+ println(10.days)
+}
diff --git a/test/files/pos/packageobjs.scala b/test/files/pos/packageobjs.scala
new file mode 100755
index 0000000000..ccab133716
--- /dev/null
+++ b/test/files/pos/packageobjs.scala
@@ -0,0 +1,8 @@
+package object overloading {
+ def bar(f: (Int) => Unit): Unit = ()
+ def bar(f: (Int, Int) => Unit): Unit = ()
+}
+
+class PackageObjectOverloadingTest {
+ overloading.bar( (i: Int) => () ) // doesn't compile.
+}
diff --git a/test/files/pos/strings.scala b/test/files/pos/strings.scala
index 3bf40e3dda..9fe8cfd94b 100644
--- a/test/files/pos/strings.scala
+++ b/test/files/pos/strings.scala
@@ -4,3 +4,7 @@ object test {
def f() = "hello".concat("world");
}
+// #1000
+object A {
+ println("""This a "raw" string ending with a "double quote"""")
+}
diff --git a/test/files/pos/t2023.scala b/test/files/pos/t2023.scala
new file mode 100644
index 0000000000..21c6fc96a6
--- /dev/null
+++ b/test/files/pos/t2023.scala
@@ -0,0 +1,16 @@
+trait C[A]
+
+object C {
+ implicit def ipl[A](implicit from: A => Ordered[A]): C[A] = null
+}
+
+object P {
+ def foo[A](i: A, j: A)(implicit c: C[A]): Unit = ()
+}
+
+class ImplicitChainTest {
+ def testTrivial: Unit = {
+ P.foo('0', '9')
+ P.foo('0', '9')
+ }
+}
diff --git a/test/files/pos/t2060.scala b/test/files/pos/t2060.scala
new file mode 100755
index 0000000000..2c701150e4
--- /dev/null
+++ b/test/files/pos/t2060.scala
@@ -0,0 +1,44 @@
+/* The problem here is that we cannot insert an implicit to
+ * add a polymorphic method which is then instantiated to the
+ * right type. When searching for the implicit in the `fails to compile
+ * line':
+ *
+ * val failure = 1.0 + new Op[Int]
+ *
+ * we reduce the problem to finding a function from Double to
+ * {+: _ >: Op[Int] <: Any}, that is, a method which takes
+ * an argument which is an Op[Int] or a supertype thereof.
+ * Class Rich is not a subtype of this structural record, because
+ * polymorphic method instantiation is not contained in subtyping.
+ * That is: The method type [I](op : Op[I]): Op[I] is not a subtype
+ * of (Op[Int]): Op[Int].
+ * At present it is unclear whether this problem can be solved.
+ */
+object Test {
+ class Op[I];
+ class IntOp extends Op[Int];
+
+ class Rich(x : Double) {
+ def + (op : IntOp): IntOp = op;
+ def + [I](op : Op[I]): Op[I] = op;
+ def plus [I](op : Op[I]): Op[I] = op;
+ }
+
+ implicit def iToRich(x : Double) =
+ new Rich(x);
+
+ // fails to compile
+ val x = 1.0 + new Op[Int]
+
+ // works as expected --
+ // problem isn't in adding new "+"
+ val a = 1.0 + new IntOp;
+
+ // works as expected --
+ // problem isn't in binding type variable I
+ val b = 1.0 plus new Op[Int];
+
+ // works as expected --
+ // problem isn't in using Rich.+[I](op : Op[I])
+ val c = iToRich(1.0) + new Op[Int];
+}
diff --git a/test/files/pos/t2425.scala b/test/files/pos/t2425.scala
new file mode 100755
index 0000000000..403f1a18d7
--- /dev/null
+++ b/test/files/pos/t2425.scala
@@ -0,0 +1,15 @@
+trait B
+class D extends B
+object Test extends Application {
+ 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))
+}