aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-08-13 11:31:39 +0200
committerMartin Odersky <odersky@gmail.com>2014-08-13 12:05:05 +0200
commit34f73ded3519a1df7d278685f3f33facd00f1c58 (patch)
tree3cf71a8baea0de46c9ca126a1ea2dbd6ea55c731 /tests
parent3558e07b8f3a604bfd67c721cdec3eb9db29e7eb (diff)
downloaddotty-34f73ded3519a1df7d278685f3f33facd00f1c58.tar.gz
dotty-34f73ded3519a1df7d278685f3f33facd00f1c58.tar.bz2
dotty-34f73ded3519a1df7d278685f3f33facd00f1c58.zip
Fix and enable RefChecks
RefChecks is now enabled. Some of the tests had to be fixed to be refchecks-correct.
Diffstat (limited to 'tests')
-rw-r--r--tests/pos/desugar.scala37
-rw-r--r--tests/pos/hk.scala6
-rw-r--r--tests/pos/inferred.scala26
-rw-r--r--tests/pos/opassign.scala18
-rw-r--r--tests/pos/t1832.scala2
-rw-r--r--tests/pos/tycons.scala4
-rw-r--r--tests/pos/typers.scala2
7 files changed, 49 insertions, 46 deletions
diff --git a/tests/pos/desugar.scala b/tests/pos/desugar.scala
index f0d8645b7..0d3b6d8ca 100644
--- a/tests/pos/desugar.scala
+++ b/tests/pos/desugar.scala
@@ -6,11 +6,11 @@ object desugar {
val list = List(1, 2, 3)
{ var z: Int = y }
-
+
def foo0(first: Int, second: Int = 2, third: Int = 3) = first + second
def foo1(first: Int, second: Int = 2)(third: Int = 3) = first + second
def foo2(first: Int)(second: Int = 2)(third: Int = 3) = first + second
-
+
object caseClasses { self =>
trait List[+T] {
def head: T
@@ -23,34 +23,37 @@ object desugar {
def apply[T](head: T): Cons[T] = apply(head, Nil)
}
- case object Nil extends List[Nothing]
+ case object Nil extends List[Nothing] {
+ def head = throw new Error()
+ def tail = throw new Error()
+ }
}
-
+
object patDefs {
-
+
import caseClasses._
val xs: List[Int] = Cons(1, Cons(2, Nil))
-
- val Cons(y, ys) = xs
+
+ val Cons(y, ys) = xs
val Cons(z, _) = xs
val Cons(_, _) = xs
-
+
val (cons: Cons[Int]) = xs
-
+
val x1, y1, z1: Int = 1
}
-
+
object Binops {
-
+
x :: y :: Nil
-
+
val x :: y :: Nil = list
-
+
}
-
+
object fors {
-
+
for (x <- List(1, 2, 3)) yield 2
for (x <- List(1, 2, 3) if x % 2 == 0) yield x * x
for (x <- List(1, 2, 3); y <- 0 to x) yield x * y
@@ -65,7 +68,7 @@ object desugar {
for (x <- List(1, 2, 3); y = x * x; if x + y % 2 == 0) println(x * y)
for (x <- List(1, 2, 3); y = x * x; z = x * y; u <- 0 to y) println(x * y * z * u)
}
-
+
object misc {
'hello
s"this is a $x + ${x + y} string"
@@ -82,4 +85,4 @@ object desugar {
do x -= 1 while (x > 0)
}
-} \ No newline at end of file
+}
diff --git a/tests/pos/hk.scala b/tests/pos/hk.scala
index 461c6e386..9fdaf94f6 100644
--- a/tests/pos/hk.scala
+++ b/tests/pos/hk.scala
@@ -2,7 +2,7 @@ import language.higherKinds
object hk0 {
- class Base {
+ abstract class Base {
type Rep[T]
val strRep: Rep[String]
}
@@ -13,7 +13,7 @@ object hk0 {
val sr: Rep[String] = ""
}
- class Functor[F[_]] {
+ abstract class Functor[F[_]] {
def map[A, B](f: A => B): F[A] => F[B]
}
val ml: Functor[List] = ???
@@ -53,4 +53,4 @@ object higherKinded {
tree1: Tree[String]
}
-} \ No newline at end of file
+}
diff --git a/tests/pos/inferred.scala b/tests/pos/inferred.scala
index 525848541..87bbd9473 100644
--- a/tests/pos/inferred.scala
+++ b/tests/pos/inferred.scala
@@ -1,13 +1,13 @@
-class LIST[+T] {
-
+abstract class LIST[+T] {
+
def isEmpty: Boolean
def head: T
def tail: LIST[T]
-
+
def prepend [U >: T] (x: U): LIST[U] = new CONS(x, this)
-
+
def map[U](f: T => U): LIST[U] = if (isEmpty) NIL else tail.map(f).prepend(f(head))
-
+
}
object NIL extends LIST[Nothing] {
@@ -37,22 +37,22 @@ object Inferred {
val nn = bar(NIL)
val ints: LIST[Int] = NIL prepend 1
-
+
val ints1 = NIL prepend 1 prepend 2
val a = if (1 == 0) NIL else ints
-
+
val n2 = scala.collection.immutable.Nil
-
+
val ss2: scala.collection.immutable.List[String] = "abc" :: n2
-
+
val ss3 = "abc" :: n2
-
+
def cl = ((x: Int) => x + 1)
-
+
val ints2 = ints map (_ + 1)
-
+
val ints3 = new CONS[Int](1, NIL)
-
+
val ints4 = new CONS(1, NIL)
} \ No newline at end of file
diff --git a/tests/pos/opassign.scala b/tests/pos/opassign.scala
index 7b8fec652..8f6cad903 100644
--- a/tests/pos/opassign.scala
+++ b/tests/pos/opassign.scala
@@ -1,28 +1,28 @@
object opassign {
-
+
var count: Int = 0
def next = { count += 1; count }
-
+
var x: Int = 0
x += 1
-
+
{ var x: Int = 0
x += 1
}
-
+
class Ref {
- var x: Int
+ var x: Int = _
}
val r = new Ref
r.x += 1
-
+
val arr = new Array[Int](10)
arr(0) += 1
-
+
def f(x: Int): Ref = new Ref
f(next).x += 1
-
+
val buf = new collection.mutable.ListBuffer[Int]
buf += 1
-} \ No newline at end of file
+}
diff --git a/tests/pos/t1832.scala b/tests/pos/t1832.scala
index 9ad9703c2..c34fe4bfa 100644
--- a/tests/pos/t1832.scala
+++ b/tests/pos/t1832.scala
@@ -2,7 +2,7 @@ trait Cloning {
trait Foo
def fn(g: Any => Unit): Foo
- class Star { def *(a: Cloning.this.Foo): Cloning.this.Foo }
+ abstract class Star { def *(a: Cloning.this.Foo): Cloning.this.Foo }
implicit def mkStar(i: Int): Star = new Star { def *(a: Foo): Foo = null }
diff --git a/tests/pos/tycons.scala b/tests/pos/tycons.scala
index f138c78be..ef16a7792 100644
--- a/tests/pos/tycons.scala
+++ b/tests/pos/tycons.scala
@@ -12,11 +12,11 @@ object obj extends List[Number] with Set[Exception] {
val e: Exception = x
}
-class Functor[F <: TypeConstructor] {
+abstract class Functor[F <: TypeConstructor] {
def map[A, B](f: F { type TypeArg <: A }): F { type TypeArg <: B }
}
implicit object ListFunctor extends Functor[List] {
- def map[A, B](f: List[A]): List[B] = ???
+ override def map[A, B](f: List { type TypeArg <: A }): List { type TypeArg <: B } = ???
}
diff --git a/tests/pos/typers.scala b/tests/pos/typers.scala
index b2d786c1c..fe11ca602 100644
--- a/tests/pos/typers.scala
+++ b/tests/pos/typers.scala
@@ -88,7 +88,7 @@ object typers {
}
class Refinements {
- val y: C { type T; val key: T; def process(x: T): Int }
+ val y: C { type T; val key: T; def process(x: T): Int } = ???
}
object Accessibility {