diff options
-rw-r--r-- | tests/pending/pos/annot.scala | 5 | ||||
-rw-r--r-- | tests/pending/pos/t1672.scala | 36 | ||||
-rw-r--r-- | tests/pending/pos/vararg-pattern.scala | 12 | ||||
-rw-r--r-- | tests/pos/array-clone.scala | 7 | ||||
-rw-r--r-- | tests/pos/getset.scala | 23 | ||||
-rw-r--r-- | tests/pos/lambdalift.scala | 46 | ||||
-rw-r--r-- | tests/pos/points.scala | 8 | ||||
-rw-r--r-- | tests/pos/synthetics.scala | 4 | ||||
-rw-r--r-- | tests/pos/t7093.scala | 27 | ||||
-rw-r--r-- | tests/pos/unapply.scala | 11 |
10 files changed, 179 insertions, 0 deletions
diff --git a/tests/pending/pos/annot.scala b/tests/pending/pos/annot.scala new file mode 100644 index 000000000..8e21803b4 --- /dev/null +++ b/tests/pending/pos/annot.scala @@ -0,0 +1,5 @@ +class Test { + + @SuppressWarnings("hi") def foo() = ??? + +} diff --git a/tests/pending/pos/t1672.scala b/tests/pending/pos/t1672.scala new file mode 100644 index 000000000..77a86db22 --- /dev/null +++ b/tests/pending/pos/t1672.scala @@ -0,0 +1,36 @@ +// moved to pending. +/* Tail calls translates this program to: + +final lazy object Test1672: Test1672$ = new Test1672$() + final class Test1672$() extends Object() { this: Test1672$.type => + @tailrec def bar: (x: Int)(y: Int)Nothing = { + def tailLabel2: ($this: Test1672$.type)(x: Int)(y: Int)Nothing = { + try { + throw new scala.package.RuntimeException() + } catch { + def $anonfun: (x$1: Throwable)Nothing = + x$1 match { + case _: scala.package.Throwable => + tailLabel2($this)(x)(y) + } + closure($anonfun) + } + } + tailLabel2(Test1672$.this)(x)(y) + } + } + +Note the tail call to taillabel2 from the local method $anonfun. +LambdaLift doe snot know how to deal wioth this. +*/ + +object Test1672 { + @annotation.tailrec + def bar(x: Int)(y: Int) : Nothing = { + try { + throw new RuntimeException + } catch { + case _: Throwable => bar(x)(y) + } + } +} diff --git a/tests/pending/pos/vararg-pattern.scala b/tests/pending/pos/vararg-pattern.scala new file mode 100644 index 000000000..314d6460f --- /dev/null +++ b/tests/pending/pos/vararg-pattern.scala @@ -0,0 +1,12 @@ +object Test { + + List(1, 2, 3, 4) match { + case List(1, 2, xs: _*) => + val ys: Seq[Int] = xs + println(ys) + } + val List(1, 2, x: _*) = List(1, 2, 3, 4) + +} + + diff --git a/tests/pos/array-clone.scala b/tests/pos/array-clone.scala new file mode 100644 index 000000000..ef5ac5c85 --- /dev/null +++ b/tests/pos/array-clone.scala @@ -0,0 +1,7 @@ +object test { + + val xs = Array(1, 2, 3) + + val ys: Array[Int] = xs.clone() + +} diff --git a/tests/pos/getset.scala b/tests/pos/getset.scala new file mode 100644 index 000000000..7b6207e94 --- /dev/null +++ b/tests/pos/getset.scala @@ -0,0 +1,23 @@ +package test + +trait T { + + val x = 2 + + var y = 2 + + private[this] var z = 3 + + private var a = 3 + +} +class C { + + val x = 2 + + var y = 2 + + private[this] var z = 3 + + private var a = 3 +} diff --git a/tests/pos/lambdalift.scala b/tests/pos/lambdalift.scala new file mode 100644 index 000000000..febae6828 --- /dev/null +++ b/tests/pos/lambdalift.scala @@ -0,0 +1,46 @@ +object test { + + def foo(x: Int) = { + + def bar(y: Int) = x + y + def baz(z: Int) = bar(z) + + baz(1) + + } + + def foo2(x: Int) = { + + class C { + def bam(y: Int): String => Int = { + def baz = x + y + z => baz * z.length + } + } + + val fun = new C().bam(1) + fun("abc") + + } +} + +class Super(x: Int) + +class Sub extends Super({ + def foo3(x: Int) = { + + class C { + def this(name: String) = this() + + def bam(y: Int): String => Int = { + def baz = x + y + z => baz * z.length + } + } + + val fun = new C("dummy").bam(1) + fun("abc") + + } + foo3(22) +}) diff --git a/tests/pos/points.scala b/tests/pos/points.scala new file mode 100644 index 000000000..db6104c88 --- /dev/null +++ b/tests/pos/points.scala @@ -0,0 +1,8 @@ +class Point extends Comparable[Point] { + override def compareTo(other: Point): Int = ??? +} + +class ColoredPoint extends Point with Comparable[ColoredPoint] { + override def compareTo(other: ColoredPoint): Int = ??? +} + diff --git a/tests/pos/synthetics.scala b/tests/pos/synthetics.scala new file mode 100644 index 000000000..c7d49df70 --- /dev/null +++ b/tests/pos/synthetics.scala @@ -0,0 +1,4 @@ +case class C(x: Int, var y: String) { + +} + diff --git a/tests/pos/t7093.scala b/tests/pos/t7093.scala new file mode 100644 index 000000000..287b7a78c --- /dev/null +++ b/tests/pos/t7093.scala @@ -0,0 +1,27 @@ +object Test { + + trait A[+X] { + protected[this] def f(x: X): X = x + } + + trait B extends A[B] { + def kaboom = f(new B {}) + } + +// protected[this] disables variance checking +// of the signature of `f`. +// +// C's parent list unifies A[B] with A[C] +// +// The protected[this] loophole is widely used +// in the collections, every newBuilder method +// would fail variance checking otherwise. + class C extends B with A[C] { + override protected[this] def f(c: C) = c + } + +// java.lang.ClassCastException: B$$anon$1 cannot be cast to C +// at C.f(<console>:15) + new C().kaboom +} + diff --git a/tests/pos/unapply.scala b/tests/pos/unapply.scala new file mode 100644 index 000000000..ba885be73 --- /dev/null +++ b/tests/pos/unapply.scala @@ -0,0 +1,11 @@ +object test { + class Foo[T](val arg : T) + + object Foo { + def unapply [a](m : Foo[a]) = Some (m.arg) + } + def matchAndGetArgFromFoo[b]( e:Foo[b]):b = {e match { case Foo(x) => x }} +// Unapply node here will have type argument [a] instantiated to scala.Nothing: +// UnApply(TypeApply(Select(Ident(Foo),unapply),List(TypeTree[TypeVar(PolyParam(a) -> TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing))])),List(),List(Bind(x,Ident(_)))) +// but the type of the UnApply node itself is correct: RefinedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,<empty>)),test$)),Foo), test$$Foo$$a, TypeAlias(TypeRef(NoPrefix,a))) +} |