aboutsummaryrefslogtreecommitdiff
path: root/tests/pos
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-05-03 13:31:27 +0200
committerMartin Odersky <odersky@gmail.com>2014-05-12 12:50:38 +0200
commit1b32071acef5c7c2c08e21ee577c7cc709876ffa (patch)
tree6cf36469ca3a59b855a3c589b4542c19d3b30fb8 /tests/pos
parent8a4186ff782efefb98686aa35bf7f5dd1418210d (diff)
downloaddotty-1b32071acef5c7c2c08e21ee577c7cc709876ffa.tar.gz
dotty-1b32071acef5c7c2c08e21ee577c7cc709876ffa.tar.bz2
dotty-1b32071acef5c7c2c08e21ee577c7cc709876ffa.zip
More tests
Diffstat (limited to 'tests/pos')
-rw-r--r--tests/pos/t1164.scala29
-rw-r--r--tests/pos/t1318.scala31
-rw-r--r--tests/pos/t1385.scala3
-rw-r--r--tests/pos/t1391.scala43
-rw-r--r--tests/pos/t1422_pos.scala2
-rw-r--r--tests/pos/t1438.scala10
-rw-r--r--tests/pos/t1439.scala8
-rw-r--r--tests/pos/t1480.scala6
-rw-r--r--tests/pos/t151.scala6
-rw-r--r--tests/pos/t1560.scala13
-rw-r--r--tests/pos/t1565.scala19
-rw-r--r--tests/pos/t1569.scala5
-rw-r--r--tests/pos/t159.scala22
-rw-r--r--tests/pos/t1591_pos.scala7
-rw-r--r--tests/pos/t1591b.scala13
15 files changed, 217 insertions, 0 deletions
diff --git a/tests/pos/t1164.scala b/tests/pos/t1164.scala
new file mode 100644
index 000000000..ab58c1d6b
--- /dev/null
+++ b/tests/pos/t1164.scala
@@ -0,0 +1,29 @@
+
+
+object test {
+
+ class Foo[a](val arg : a)
+
+ object Foo {
+ def apply [a](arg : a, right :a) = new Foo[a](arg)
+ def unapply [a](m : Foo[a]) = Some (m.arg)
+ }
+
+ def matchAndGetArgFromFoo[a]( e:Foo[a]):a = {e match { case Foo(x) => x }}
+
+
+ // Try the same thing as above but use function as argument to Bar
+ // constructor
+
+ type FunIntToA [a] = (Int) => a
+ class Bar[a] (var f: FunIntToA[a])
+
+ object Bar {
+ def apply[a](f: FunIntToA[a]) = new Bar[a](f)
+ def unapply[a](m: Bar[a]) = Some (m.f)
+ }
+
+ def matchAndGetFunFromBar[a](b:Bar[a]) : FunIntToA[a] = { b match { case Bar(x) => x}}
+
+
+}
diff --git a/tests/pos/t1318.scala b/tests/pos/t1318.scala
new file mode 100644
index 000000000..34e2bc8dd
--- /dev/null
+++ b/tests/pos/t1318.scala
@@ -0,0 +1,31 @@
+abstract class F {
+ type mType <: M
+}
+
+abstract class M { self =>
+
+ type mType <: M
+
+ type fType = F {type mType >: self.mType }
+ def fs: List[fType]
+}
+
+abstract class A0 extends M {
+ type mType = A0
+ def fs: List[fType] = Nil
+}
+
+object A extends A0 {}
+
+abstract class B0 extends M {
+ type mType = B0
+ def fs: List[fType] = Nil
+}
+
+object B extends B0 {}
+
+object C {
+ def ab = List(A) ::: List(B)
+ // the following compiles successfully:
+ // def ab = List(A) ::: List[M](B)
+}
diff --git a/tests/pos/t1385.scala b/tests/pos/t1385.scala
new file mode 100644
index 000000000..aefd9c35b
--- /dev/null
+++ b/tests/pos/t1385.scala
@@ -0,0 +1,3 @@
+object Test extends Serializable {
+ private def readResolve: AnyRef = this
+}
diff --git a/tests/pos/t1391.scala b/tests/pos/t1391.scala
new file mode 100644
index 000000000..5178ba987
--- /dev/null
+++ b/tests/pos/t1391.scala
@@ -0,0 +1,43 @@
+package sandbox
+
+ class hierarOverload {
+
+ /*
+ * Template structure - using abstract types.
+ */
+ trait AB {
+ type TA <: A
+ type TB <: B
+
+ protected trait A {
+ val entities : List[TB]
+ }
+
+ protected trait B {
+ var group : TA
+ }
+ }
+
+ /*
+ * Template instantiation in an object to ease use and globally define
+ abstract types
+ */
+ object NAnB extends AB {
+ type TB = nB
+ type TA = nA
+
+ class nA extends A {
+ val entities = List[nB]()
+ }
+
+ class nB extends B {
+ var group = new nA
+ }
+ }
+
+ def foo (): Unit = {
+ val t = new NAnB.nA
+ println(t)
+ }
+
+ }
diff --git a/tests/pos/t1422_pos.scala b/tests/pos/t1422_pos.scala
new file mode 100644
index 000000000..658f5c730
--- /dev/null
+++ b/tests/pos/t1422_pos.scala
@@ -0,0 +1,2 @@
+case class A(private val foo:String)
+case class B(protected[this] val foo:String)
diff --git a/tests/pos/t1438.scala b/tests/pos/t1438.scala
new file mode 100644
index 000000000..221c3439d
--- /dev/null
+++ b/tests/pos/t1438.scala
@@ -0,0 +1,10 @@
+class C[A] {
+ type CC[B] <: C[B]
+ def aio[T]: T = aio[T]
+}
+class D[A] extends C[A] {
+ protected def nv[B](elems: Iterator[B]): CC[B] = {
+ val x = new D[B]
+ x.aio[CC[B]]
+ }
+}
diff --git a/tests/pos/t1439.scala b/tests/pos/t1439.scala
new file mode 100644
index 000000000..0efcc74b6
--- /dev/null
+++ b/tests/pos/t1439.scala
@@ -0,0 +1,8 @@
+// no unchecked warnings
+class View[C[A]] { }
+
+object Test {
+ (null: Any) match {
+ case v: View[_] =>
+ }
+}
diff --git a/tests/pos/t1480.scala b/tests/pos/t1480.scala
new file mode 100644
index 000000000..1d9f94d2e
--- /dev/null
+++ b/tests/pos/t1480.scala
@@ -0,0 +1,6 @@
+class Foo{
+ def compare(newP : Any, oldP : Any) : Boolean = (newP,oldP) match {
+ case (newP : AnyRef, oldP : AnyRef) if newP == oldP => newP == oldP
+ case (newS : Symbol, oldS: Symbol) if newS == oldS => newS == oldS
+ }
+}
diff --git a/tests/pos/t151.scala b/tests/pos/t151.scala
new file mode 100644
index 000000000..86667b49f
--- /dev/null
+++ b/tests/pos/t151.scala
@@ -0,0 +1,6 @@
+abstract class Foo {
+ type T;
+ def foo(a: T): Int = 0;
+ val foo: Foo = null;
+ def a: foo.T = a;
+}
diff --git a/tests/pos/t1560.scala b/tests/pos/t1560.scala
new file mode 100644
index 000000000..dd76392e6
--- /dev/null
+++ b/tests/pos/t1560.scala
@@ -0,0 +1,13 @@
+object Test extends App {
+
+ trait C[T] {
+ def t: T
+ }
+
+ def b: Option[C[_]] = null
+
+ def c = b match {
+ case Some(b) => b.t
+ }
+
+}
diff --git a/tests/pos/t1565.scala b/tests/pos/t1565.scala
new file mode 100644
index 000000000..59d27a086
--- /dev/null
+++ b/tests/pos/t1565.scala
@@ -0,0 +1,19 @@
+object Bug1565 {
+
+// object X0 { 0; (a : Int, b : Int, c : Int) => println(List(a, b)) } // can't parse in Dotty
+// def x() = { 0; (a : Int, b : Int) => println(List(a, b)) ; 0 } // can't parse in Dotty
+
+// (a : Int, b : Int) => println(List(a, b)) not legal as a template statement
+
+ // various function syntaxes to exercise the parser
+ val xs = List(1,2,3)
+ xs.filter(x => x < 2)
+ xs.filter((x) => x < 2)
+ xs.filter { x => x < 2 }
+ xs.filter { _ < 2 }
+ xs.filter (_ < 2)
+ xs.foreach { e =>
+ val buf0 = e + 1
+ buf0
+ }
+}
diff --git a/tests/pos/t1569.scala b/tests/pos/t1569.scala
new file mode 100644
index 000000000..a7200a6d1
--- /dev/null
+++ b/tests/pos/t1569.scala
@@ -0,0 +1,5 @@
+object Bug {
+ class C { type T }
+ def foo(x: Int)(y: C)(z: y.T): Unit = {}
+ foo(3)(new C { type T = String })("hello")
+}
diff --git a/tests/pos/t159.scala b/tests/pos/t159.scala
new file mode 100644
index 000000000..4d67f8aff
--- /dev/null
+++ b/tests/pos/t159.scala
@@ -0,0 +1,22 @@
+object foo {
+ // the problem seems to appear only
+ // if "val _" is in the body of a case
+ def cooked(ckd: StringBuilder): Unit = {
+ 'a' match {
+ case '-' =>
+ val _ = ckd.append( '_' );
+ case 'v' =>
+ val _ = ckd.append( '_' );
+ }
+ }
+}
+
+object foo1 {
+ def f(): Unit = {
+ 1 match {
+ case 2 => val _ = 1;
+ case 3 => val _ = 2;
+ case 4 => val _ = 2;
+ }
+ }
+}
diff --git a/tests/pos/t1591_pos.scala b/tests/pos/t1591_pos.scala
new file mode 100644
index 000000000..4f55d7ce1
--- /dev/null
+++ b/tests/pos/t1591_pos.scala
@@ -0,0 +1,7 @@
+trait A
+
+object Test {
+ lazy val a = new A {
+ object Zenek
+ }
+}
diff --git a/tests/pos/t1591b.scala b/tests/pos/t1591b.scala
new file mode 100644
index 000000000..c671ad647
--- /dev/null
+++ b/tests/pos/t1591b.scala
@@ -0,0 +1,13 @@
+import scala.tools.nsc._
+
+class SemanticTokens(val compiler: Global) {
+ import compiler._
+
+ def build() = ErrorType
+
+ class Process {
+ def f() = analyzer
+ // or to crash the compiler instead of a nice message,
+ // def f() = analyzer underlying _
+ }
+}