summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/scopes.check35
-rw-r--r--test/files/neg/scopes.scala20
-rw-r--r--test/files/run/bug874.check2
-rw-r--r--test/files/run/bug874.scala17
-rw-r--r--test/files/run/records.scala27
5 files changed, 101 insertions, 0 deletions
diff --git a/test/files/neg/scopes.check b/test/files/neg/scopes.check
new file mode 100644
index 0000000000..54c5d5b5e1
--- /dev/null
+++ b/test/files/neg/scopes.check
@@ -0,0 +1,35 @@
+scopes.scala:1: error: x is already defined as value x
+case class test0(x: Int, x: Float)
+ ^
+scopes.scala:1: error: type mismatch;
+ found : Float
+ required: Int
+case class test0(x: Int, x: Float)
+ ^
+scopes.scala:5: error: t is already defined as type t
+ type t = Float
+ ^
+scopes.scala:7: error: x is already defined as value x
+ val x: Float = .0f;
+ ^
+scopes.scala:10: error: y is already defined as value y
+ val y: Float = .0f
+ ^
+scopes.scala:13: error: x is already defined as value x
+ def f1(x: Int, x: Float) = x
+ ^
+scopes.scala:14: error: y is already defined as value y
+ def f2(x: Int)(y: Int, y: Float) = x + y
+ ^
+scopes.scala:15: error: x is already defined as value x
+ val closure = (x: Int, x: Float) => x
+ ^
+scopes.scala:17: error: x is already defined as value x
+ case x::x => x
+ ^
+scopes.scala:1: error: type mismatch;
+ found : Float
+ required: Int
+case class test0(x: Int, x: Float)
+ ^
+10 errors found
diff --git a/test/files/neg/scopes.scala b/test/files/neg/scopes.scala
new file mode 100644
index 0000000000..fd31ff5f72
--- /dev/null
+++ b/test/files/neg/scopes.scala
@@ -0,0 +1,20 @@
+case class test0(x: Int, x: Float)
+
+object test1 {
+ type t = Int
+ type t = Float
+ val x: Int = 0
+ val x: Float = .0f;
+ {
+ val y: Int = 0
+ val y: Float = .0f
+ ()
+ }
+ def f1(x: Int, x: Float) = x
+ def f2(x: Int)(y: Int, y: Float) = x + y
+ val closure = (x: Int, x: Float) => x
+ List() match {
+ case x::x => x
+ case Nil => Nil
+ }
+}
diff --git a/test/files/run/bug874.check b/test/files/run/bug874.check
new file mode 100644
index 0000000000..91de7e0a03
--- /dev/null
+++ b/test/files/run/bug874.check
@@ -0,0 +1,2 @@
+U created with xyz and 2
+U created with abc and 1
diff --git a/test/files/run/bug874.scala b/test/files/run/bug874.scala
new file mode 100644
index 0000000000..d83014651b
--- /dev/null
+++ b/test/files/run/bug874.scala
@@ -0,0 +1,17 @@
+object Test {
+ abstract class Base {
+ val U: {
+ def apply[A](x1: A)(x2: Int): Any
+ }
+ U("xyz")(2)
+ }
+ class Mix extends Base {
+ case class U[A](x1: A)(x2: Int) {
+ Console.println("U created with "+x1+" and "+x2)
+ }
+ }
+ def main(args : Array[String]) : Unit = {
+ val obvious: Base = new Mix;
+ obvious.U("abc")(1)
+ }
+}
diff --git a/test/files/run/records.scala b/test/files/run/records.scala
new file mode 100644
index 0000000000..c1dc7b67e8
--- /dev/null
+++ b/test/files/run/records.scala
@@ -0,0 +1,27 @@
+trait C {
+ def f: Int
+}
+
+object Test {
+ type T = C {
+ def f: Int
+ def g: String
+ }
+
+ val x: T = new C {
+ def f = 1
+ def g = "hello"
+ }
+
+ val y = new C {
+ def f = 2
+ def g = " world"
+ }
+
+ val z: T = y
+
+ def main(args: Array[String]): Unit = {
+ assert(x.f+z.f == 3)
+ assert(x.g+z.g == "hello world")
+ }
+}