From c854cc7fcc9d0f889c6235c1534133cff7360e7f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 17 Mar 2014 18:44:39 +0100 Subject: More tests --- tests/new/t1056.scala | 5 -- tests/pending/pos/t1071.scala | 19 +++++++ tests/pending/pos/t1208.scala | 7 +++ tests/pending/pos/t1236.scala | 14 +++++ tests/pending/pos/t1272.scala | 9 ++++ tests/pending/pos/t1279a.scala | 39 ++++++++++++++ tests/pending/pos/t1280.scala | 1 + tests/pending/pos/t1292.scala | 33 ++++++++++++ tests/pos/t1000.scala | 8 +++ tests/pos/t1001.scala | 115 +++++++++++++++++++++++++++++++++++++++++ tests/pos/t1006.scala | 15 ++++++ tests/pos/t1014.scala | 16 ++++++ tests/pos/t1027.scala | 18 +++++++ tests/pos/t1034.scala | 6 +++ tests/pos/t1035.scala | 32 ++++++++++++ tests/pos/t1048.scala | 14 +++++ tests/pos/t1049.scala | 7 +++ tests/pos/t1050.scala | 10 ++++ tests/pos/t1053.scala | 6 +++ tests/pos/t1056.scala | 5 ++ tests/pos/t1070.scala | 4 ++ tests/pos/t1075.scala | 17 ++++++ tests/pos/t1085.scala | 9 ++++ tests/pos/t1090.scala | 16 ++++++ tests/pos/t1107a.scala | 10 ++++ tests/pos/t1119.scala | 10 ++++ tests/pos/t1131.scala | 4 ++ tests/pos/t1133.scala | 32 ++++++++++++ tests/pos/t1136.scala | 8 +++ tests/pos/t1146.scala | 6 +++ tests/pos/t1147.scala | 6 +++ tests/pos/t115.scala | 9 ++++ tests/pos/t1159.scala | 13 +++++ tests/pos/t116.scala | 6 +++ tests/pos/t1164.scala | 29 +++++++++++ tests/pos/t1168.scala | 16 ++++++ tests/pos/t1185.scala | 15 ++++++ tests/pos/t119.scala | 7 +++ tests/pos/t1203a.scala | 13 +++++ tests/pos/t121.scala | 3 ++ tests/pos/t1210a.scala | 15 ++++++ tests/pos/t122.scala | 4 ++ tests/pos/t1226.scala | 8 +++ tests/pos/t1237.scala | 14 +++++ tests/pos/t124.scala | 5 ++ tests/pos/t1260.scala | 18 +++++++ tests/untried/pos/t1000.scala | 8 --- tests/untried/pos/t1001.scala | 115 ----------------------------------------- tests/untried/pos/t1006.scala | 15 ------ tests/untried/pos/t1014.scala | 16 ------ tests/untried/pos/t1027.scala | 18 ------- tests/untried/pos/t1034.scala | 6 --- tests/untried/pos/t1035.scala | 32 ------------ tests/untried/pos/t1048.scala | 14 ----- tests/untried/pos/t1049.scala | 7 --- tests/untried/pos/t1050.scala | 10 ---- tests/untried/pos/t1053.scala | 6 --- tests/untried/pos/t1070.scala | 4 -- tests/untried/pos/t1071.scala | 17 ------ tests/untried/pos/t1075.scala | 17 ------ tests/untried/pos/t1085.scala | 9 ---- tests/untried/pos/t1090.scala | 16 ------ tests/untried/pos/t1107a.scala | 10 ---- tests/untried/pos/t1119.scala | 10 ---- tests/untried/pos/t1131.scala | 4 -- tests/untried/pos/t1133.scala | 32 ------------ tests/untried/pos/t1136.scala | 8 --- tests/untried/pos/t1146.scala | 6 --- tests/untried/pos/t1147.scala | 6 --- tests/untried/pos/t115.scala | 9 ---- tests/untried/pos/t1159.scala | 13 ----- tests/untried/pos/t116.scala | 6 --- tests/untried/pos/t1164.scala | 29 ----------- tests/untried/pos/t1168.scala | 16 ------ tests/untried/pos/t1185.scala | 15 ------ tests/untried/pos/t119.scala | 7 --- tests/untried/pos/t1203a.scala | 13 ----- tests/untried/pos/t1208.scala | 4 -- tests/untried/pos/t121.scala | 3 -- tests/untried/pos/t1210a.scala | 15 ------ tests/untried/pos/t122.scala | 4 -- tests/untried/pos/t1226.scala | 8 --- tests/untried/pos/t1236.scala | 14 ----- tests/untried/pos/t1237.scala | 14 ----- tests/untried/pos/t124.scala | 5 -- tests/untried/pos/t1260.scala | 18 ------- tests/untried/pos/t1272.scala | 9 ---- tests/untried/pos/t1279a.scala | 39 -------------- tests/untried/pos/t1280.scala | 1 - tests/untried/pos/t1292.scala | 33 ------------ 90 files changed, 671 insertions(+), 666 deletions(-) delete mode 100644 tests/new/t1056.scala create mode 100644 tests/pending/pos/t1071.scala create mode 100644 tests/pending/pos/t1208.scala create mode 100644 tests/pending/pos/t1236.scala create mode 100644 tests/pending/pos/t1272.scala create mode 100644 tests/pending/pos/t1279a.scala create mode 100644 tests/pending/pos/t1280.scala create mode 100644 tests/pending/pos/t1292.scala create mode 100644 tests/pos/t1000.scala create mode 100644 tests/pos/t1001.scala create mode 100644 tests/pos/t1006.scala create mode 100644 tests/pos/t1014.scala create mode 100644 tests/pos/t1027.scala create mode 100644 tests/pos/t1034.scala create mode 100644 tests/pos/t1035.scala create mode 100644 tests/pos/t1048.scala create mode 100644 tests/pos/t1049.scala create mode 100644 tests/pos/t1050.scala create mode 100644 tests/pos/t1053.scala create mode 100644 tests/pos/t1056.scala create mode 100644 tests/pos/t1070.scala create mode 100644 tests/pos/t1075.scala create mode 100644 tests/pos/t1085.scala create mode 100644 tests/pos/t1090.scala create mode 100644 tests/pos/t1107a.scala create mode 100644 tests/pos/t1119.scala create mode 100644 tests/pos/t1131.scala create mode 100644 tests/pos/t1133.scala create mode 100644 tests/pos/t1136.scala create mode 100644 tests/pos/t1146.scala create mode 100644 tests/pos/t1147.scala create mode 100644 tests/pos/t115.scala create mode 100644 tests/pos/t1159.scala create mode 100644 tests/pos/t116.scala create mode 100644 tests/pos/t1164.scala create mode 100644 tests/pos/t1168.scala create mode 100644 tests/pos/t1185.scala create mode 100644 tests/pos/t119.scala create mode 100644 tests/pos/t1203a.scala create mode 100644 tests/pos/t121.scala create mode 100644 tests/pos/t1210a.scala create mode 100644 tests/pos/t122.scala create mode 100644 tests/pos/t1226.scala create mode 100644 tests/pos/t1237.scala create mode 100644 tests/pos/t124.scala create mode 100644 tests/pos/t1260.scala delete mode 100644 tests/untried/pos/t1000.scala delete mode 100644 tests/untried/pos/t1001.scala delete mode 100644 tests/untried/pos/t1006.scala delete mode 100644 tests/untried/pos/t1014.scala delete mode 100644 tests/untried/pos/t1027.scala delete mode 100644 tests/untried/pos/t1034.scala delete mode 100644 tests/untried/pos/t1035.scala delete mode 100644 tests/untried/pos/t1048.scala delete mode 100644 tests/untried/pos/t1049.scala delete mode 100644 tests/untried/pos/t1050.scala delete mode 100644 tests/untried/pos/t1053.scala delete mode 100644 tests/untried/pos/t1070.scala delete mode 100644 tests/untried/pos/t1071.scala delete mode 100644 tests/untried/pos/t1075.scala delete mode 100644 tests/untried/pos/t1085.scala delete mode 100644 tests/untried/pos/t1090.scala delete mode 100644 tests/untried/pos/t1107a.scala delete mode 100644 tests/untried/pos/t1119.scala delete mode 100644 tests/untried/pos/t1131.scala delete mode 100644 tests/untried/pos/t1133.scala delete mode 100644 tests/untried/pos/t1136.scala delete mode 100644 tests/untried/pos/t1146.scala delete mode 100644 tests/untried/pos/t1147.scala delete mode 100644 tests/untried/pos/t115.scala delete mode 100644 tests/untried/pos/t1159.scala delete mode 100644 tests/untried/pos/t116.scala delete mode 100644 tests/untried/pos/t1164.scala delete mode 100644 tests/untried/pos/t1168.scala delete mode 100644 tests/untried/pos/t1185.scala delete mode 100644 tests/untried/pos/t119.scala delete mode 100644 tests/untried/pos/t1203a.scala delete mode 100644 tests/untried/pos/t1208.scala delete mode 100644 tests/untried/pos/t121.scala delete mode 100644 tests/untried/pos/t1210a.scala delete mode 100644 tests/untried/pos/t122.scala delete mode 100644 tests/untried/pos/t1226.scala delete mode 100644 tests/untried/pos/t1236.scala delete mode 100644 tests/untried/pos/t1237.scala delete mode 100644 tests/untried/pos/t124.scala delete mode 100644 tests/untried/pos/t1260.scala delete mode 100644 tests/untried/pos/t1272.scala delete mode 100644 tests/untried/pos/t1279a.scala delete mode 100644 tests/untried/pos/t1280.scala delete mode 100644 tests/untried/pos/t1292.scala (limited to 'tests') diff --git a/tests/new/t1056.scala b/tests/new/t1056.scala deleted file mode 100644 index 68f1ff273..000000000 --- a/tests/new/t1056.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test { - type T = PartialFunction[String,String] - def g(h: T) = () - g({case s: String => s}) -} diff --git a/tests/pending/pos/t1071.scala b/tests/pending/pos/t1071.scala new file mode 100644 index 000000000..b241cd648 --- /dev/null +++ b/tests/pending/pos/t1071.scala @@ -0,0 +1,19 @@ +class C { + private val a = 0 + def getA = a +} + +class D(c: C) { + def a = c.getA +} + +object Test { + implicit def c2d(c: C): D = new D(c) + + val c = new C + (c: D).a // works + c.a // error +} + +// to fix this we'd need to check accessibility in the isMatchedBy of a SelectionProto, +// so that we can insert an implicit if this does not work. Need to check performance impact of this. diff --git a/tests/pending/pos/t1208.scala b/tests/pending/pos/t1208.scala new file mode 100644 index 000000000..7b14aadca --- /dev/null +++ b/tests/pending/pos/t1208.scala @@ -0,0 +1,7 @@ +object Test { + object Foo + val f: Option[Foo.type] = Some(Foo) +} + +// unsupported with current typing rules. +// on the other hand, we need a way to refer to a module class. diff --git a/tests/pending/pos/t1236.scala b/tests/pending/pos/t1236.scala new file mode 100644 index 000000000..eee1cbf02 --- /dev/null +++ b/tests/pending/pos/t1236.scala @@ -0,0 +1,14 @@ +trait Empty[E[_]] { + def e[A]: E[A] +} + +object T { + val ListEmpty = new Empty[List] { + def e[A]/*: List*/ = Nil // uncomment to get crash + } + + def foo[F[_]](q:(String,String)) = "hello" + def foo[F[_]](e: Empty[F]) = "world" + + val x = foo[List](ListEmpty) +} diff --git a/tests/pending/pos/t1272.scala b/tests/pending/pos/t1272.scala new file mode 100644 index 000000000..916b783bb --- /dev/null +++ b/tests/pending/pos/t1272.scala @@ -0,0 +1,9 @@ +object ImplicitTest { + implicit val i : Int = 10 + implicit def a(implicit i : Int) : Array[Byte] = null + implicit def b[T](implicit i : Int) : Array[T] = null + + def fn[T](implicit x : T) = 0 + + val x = fn[Array[Byte]] +} diff --git a/tests/pending/pos/t1279a.scala b/tests/pending/pos/t1279a.scala new file mode 100644 index 000000000..18b1e53f4 --- /dev/null +++ b/tests/pending/pos/t1279a.scala @@ -0,0 +1,39 @@ +// covariant linked list +abstract class M { + self => + + type T + final type selfType = M {type T <: self.T} + type actualSelfType >: self.type <: selfType + + def next: selfType + + // I don't understand why this doesn't compile, but that's a separate matter + // error: method all2 cannot be accessed in M.this.selfType + // because its instance type => Stream[M{type T <: M.this.selfType#T}] + // contains a malformed type: M.this.selfType#T + def all2: Stream[M {type T <: self.T}] = Stream.cons(self: actualSelfType, next.all2) + + // compiles successfully + def all3: Stream[M {type T <: self.T}] = all3Impl(self: actualSelfType) + private def all3Impl(first: M {type T <: self.T}): Stream[M {type T <: self.T}] = Stream.cons(first, all3Impl(first.next)) + + def all4: Stream[M {type T <: self.T}] = Unrelated.all4Impl[T](self: actualSelfType) +} + +// TODO!!! fix this bug for real, it compiles successfully, but weird types are inferred +object Unrelated { + // compiles successfully + def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl[U](first.next)) + + // should compile successfully without the [U], but: + // def all4ImplFail[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4ImplFail(first.next)) + // + // test/files/pos/t1279a.scala:31: error: type mismatch; + // found : first.selfType + // (which expands to) M{type T <: first.T} + // required: M{type T <: Nothing} + // def all4ImplFail[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4ImplFail(first.next)) + // ^ + // one error found +} diff --git a/tests/pending/pos/t1280.scala b/tests/pending/pos/t1280.scala new file mode 100644 index 000000000..39406b2e3 --- /dev/null +++ b/tests/pending/pos/t1280.scala @@ -0,0 +1 @@ +trait X { x => type T >: Null; new X { type T = Any with x.T } } diff --git a/tests/pending/pos/t1292.scala b/tests/pending/pos/t1292.scala new file mode 100644 index 000000000..83a996d53 --- /dev/null +++ b/tests/pending/pos/t1292.scala @@ -0,0 +1,33 @@ +trait Foo[T <: Foo[T, Enum], Enum <: Enumeration] { + type StV = Enum#Value + type Meta = MegaFoo[T, Enum] + + type Slog <: Enumeration + + def getSingleton: Meta +} + +trait MegaFoo[T <: Foo[T, Enum], Enum <: Enumeration] extends Foo[T, Enum] { + def doSomething(what: T, misc: StV, dog: Meta#Event) = None + abstract class Event + object Event + + def stateEnumeration: Slog + def se2: Enum +} + +object E extends Enumeration { + val A = Value + val B = Value +} + +class RFoo extends Foo[RFoo, E.type] { + def getSingleton = MegaRFoo + + type Slog = E.type +} + +object MegaRFoo extends RFoo with MegaFoo[RFoo, E.type] { + def stateEnumeration = E + def se2 = E +} diff --git a/tests/pos/t1000.scala b/tests/pos/t1000.scala new file mode 100644 index 000000000..613af76b9 --- /dev/null +++ b/tests/pos/t1000.scala @@ -0,0 +1,8 @@ +object A { + println("""This a "raw" string ending with a "double quote"""") +} + +object Test extends App { + val xs = Array(1, 2, 3) + Console.println(xs.filter(_ >= 0).length) +} diff --git a/tests/pos/t1001.scala b/tests/pos/t1001.scala new file mode 100644 index 000000000..7a06bfa0e --- /dev/null +++ b/tests/pos/t1001.scala @@ -0,0 +1,115 @@ +// was t1001.scala +class Foo; + +object Overload{ + val foo = classOf[Foo].getConstructors()(0) + foo.getDeclaringClass +} + +// was t1001.scala + +// I suspect the stack overflow is occurring when the compiler is determining the types for the following line at the end of the file:- +// val data = List(N26,N25) + +abstract class A +{ + // commenting out the following line (only) leads to successful compilation + protected val data: List[A] +} + +trait B[T <: B[T]] extends A { self: T => } + +abstract class C extends A +{ + // commenting out the following line (only) leads to successful compilation + protected val data: List[C] +} + +abstract class D extends C with B[D] {} + +abstract class Ee extends C with B[Ee] +{ +} + + +object N1 extends D +{ + val data = Nil +} + +object N2 extends D +{ + val data = Nil +} + +object N5 extends D +{ + val data = List(N1) +} + +object N6 extends D +{ + val data = List(N1) +} + +object N8 extends D +{ + val data = List(N1) +} + +object N10 extends D +{ + val data = Nil +} + +object N13 extends D +{ + val data = List(N2) +} + +object N14 extends D +{ + val data = List(N5,N10,N8) +} + +object N15 extends D +{ + val data = List(N14) +} + +object N16 extends D +{ + val data = List(N13,N6,N15) +} + +object N17 extends D +{ + val data = List(N16) +} + +object N21 extends D +{ + val data = List(N16) +} + +object N22 extends D +{ + val data = List(N17) +} + +object N25 extends D +{ + val data = List(N22) +} + +object N26 extends Ee +{ + val data = List(N21,N17) +} + +// Commenting out the following object (only) leads to successful compilation +object N31 extends Ee +{ + // If we use List[C](N26,N25), we achieve successful compilation + val data = List[C](N26,N25) +} diff --git a/tests/pos/t1006.scala b/tests/pos/t1006.scala new file mode 100644 index 000000000..2163b2b74 --- /dev/null +++ b/tests/pos/t1006.scala @@ -0,0 +1,15 @@ +object Test extends App { + +def test(): Unit = { + + abstract class A[T] { + def myVal: T + } + + class B[T1](value: T1) extends A[T1] { + def myVal: T1 = value + } + + Console.println(new B[Int](23).myVal) +} +} diff --git a/tests/pos/t1014.scala b/tests/pos/t1014.scala new file mode 100644 index 000000000..6fb7f7ba4 --- /dev/null +++ b/tests/pos/t1014.scala @@ -0,0 +1,16 @@ +class NodeSeq +class Elem extends NodeSeq + +class EO extends App with Moo { + // return type is Flog, inherited from overridden method. + // implicit conversions are applied because expected type `pt` is `Flog` when `computeType(rhs, pt)`. + def cat = (??? : Elem) + + implicit def nodeSeqToFlog(in: Elem): Flog = new Flog(in) +} + +trait Moo { + def cat: Flog +} + +class Flog(val in: NodeSeq) diff --git a/tests/pos/t1027.scala b/tests/pos/t1027.scala new file mode 100644 index 000000000..02ba9a8a3 --- /dev/null +++ b/tests/pos/t1027.scala @@ -0,0 +1,18 @@ +object T1027 extends App { + trait Comparable[T <: Comparable[T]] { this: T => + def < (that: T): Boolean + def <=(that: T): Boolean = this < that || this == that + def > (that: T): Boolean = that < this + def >=(that: T): Boolean = that <= this + } + class A(val x: String) extends Comparable[A]{ + def < (that: A) = this.x < that.x + } + val a = new A("a") + val b = new A("b") + println(a < b) + println(a > b) + println(a <= b) + println(a >= b) + println("Comparable traits : " + (new A("x") > new A("y")).toString) + } diff --git a/tests/pos/t1034.scala b/tests/pos/t1034.scala new file mode 100644 index 000000000..9d966334a --- /dev/null +++ b/tests/pos/t1034.scala @@ -0,0 +1,6 @@ +object Terminal { + def apply[a] : a => Unit = { a => () } + val i0 = Terminal.apply[Int] + val i1 = (Terminal)[Int] + val i2 = Terminal[Int] +} diff --git a/tests/pos/t1035.scala b/tests/pos/t1035.scala new file mode 100644 index 000000000..ef81cb0d9 --- /dev/null +++ b/tests/pos/t1035.scala @@ -0,0 +1,32 @@ +//A fatal error or Scala compiler +// Scala compiler version 2.7.1-final -- (c) 2002-2011 LAMP/EPFL +// Carlos Loria cloria@artinsoft.com +// 7/10/2008 + +class A { + var name:String = _ + def getName() = name + def this(name:String, age:Int) = {this(); this.name = name} + +} + +class B(name:String) extends A(name,0){ +} + +class D { + + object A { + def unapply(p:A) = Some(p.getName) + } + + object B { + def unapply(p:B) = Some(p.getName) + } + def foo(p:Any) = p match { + case B(n) => println("B") + case A(n) => println("A") + + + } + +} diff --git a/tests/pos/t1048.scala b/tests/pos/t1048.scala new file mode 100644 index 000000000..b8694b38e --- /dev/null +++ b/tests/pos/t1048.scala @@ -0,0 +1,14 @@ +trait T[U] { + def x: T[_ <: U] +} + +object T { + def unapply[U](t: T[U]): Option[T[_ <: U]] = Some(t.x) +} + +object Test { + def f[W](t: T[W]) = t match { + case T(T(_)) => () + } +} + diff --git a/tests/pos/t1049.scala b/tests/pos/t1049.scala new file mode 100644 index 000000000..61d99f946 --- /dev/null +++ b/tests/pos/t1049.scala @@ -0,0 +1,7 @@ +package t1049 + +abstract class Test { + type T <: A + class A { self: T => } + class B extends A { self: T => } +} diff --git a/tests/pos/t1050.scala b/tests/pos/t1050.scala new file mode 100644 index 000000000..d34b0cff1 --- /dev/null +++ b/tests/pos/t1050.scala @@ -0,0 +1,10 @@ +package t1050 + +abstract class A { + type T <: scala.AnyRef + class A { this: T => + def b = 3 + def c = b + b + } +} diff --git a/tests/pos/t1053.scala b/tests/pos/t1053.scala new file mode 100644 index 000000000..1d4dfb637 --- /dev/null +++ b/tests/pos/t1053.scala @@ -0,0 +1,6 @@ +trait T[A] { trait U { type W = A; val x = 3 } } + +object Test { + val x : ({ type V = T[this.type] })#V = null + val y = new x.U { } +} diff --git a/tests/pos/t1056.scala b/tests/pos/t1056.scala new file mode 100644 index 000000000..68f1ff273 --- /dev/null +++ b/tests/pos/t1056.scala @@ -0,0 +1,5 @@ +object Test { + type T = PartialFunction[String,String] + def g(h: T) = () + g({case s: String => s}) +} diff --git a/tests/pos/t1070.scala b/tests/pos/t1070.scala new file mode 100644 index 000000000..1622043a8 --- /dev/null +++ b/tests/pos/t1070.scala @@ -0,0 +1,4 @@ +import scala.beans.BeanProperty; +trait beanpropertytrait { + @BeanProperty var myVariable: Long = -1l; +} diff --git a/tests/pos/t1075.scala b/tests/pos/t1075.scala new file mode 100644 index 000000000..5f72957da --- /dev/null +++ b/tests/pos/t1075.scala @@ -0,0 +1,17 @@ +class Directory(var dir_ : String) +{ + if (!dir_.startsWith("/")) { + throw new RuntimeException("Invalid directory") + } + dir_ = dir_.replaceAll("/{2,}", "/") + + def this(serialized : Array[Byte]) = { + this(new String(serialized, "UTF-8")) + } + + def dir = dir_ +} + +object Test extends Directory("/bab/dkkd//dkkdkd//kdkdk") with App { + println(dir) +} diff --git a/tests/pos/t1085.scala b/tests/pos/t1085.scala new file mode 100644 index 000000000..c59e657cb --- /dev/null +++ b/tests/pos/t1085.scala @@ -0,0 +1,9 @@ +trait Functor[a] { + type MyType[a] +} + +object Test { + def listFunctor[a]: Functor[a]{type MyType[x]=List[x]} = new Functor[a] { + type MyType[t]=List[t] + } +} diff --git a/tests/pos/t1090.scala b/tests/pos/t1090.scala new file mode 100644 index 000000000..a9bce90b0 --- /dev/null +++ b/tests/pos/t1090.scala @@ -0,0 +1,16 @@ +object Test { + trait Manager { + type Node; + def iterator : Iterator[Node] + } + trait Core { + type Node; + trait NodeImpl + trait Manager extends Test.Manager { + type Node = Core.this.Node + } + def f(manager : Manager) = manager.iterator.foreach{ + case node : NodeImpl => + } + } +} diff --git a/tests/pos/t1107a.scala b/tests/pos/t1107a.scala new file mode 100644 index 000000000..0bf40bb4c --- /dev/null +++ b/tests/pos/t1107a.scala @@ -0,0 +1,10 @@ +object F { + type AnyClass = Class[_] + def tryf[T](ignore: List[AnyClass])(f: => T): Any = { + try { + f + } catch { + case e if ignore == null || ignore.isEmpty => {false} + } + } +} diff --git a/tests/pos/t1119.scala b/tests/pos/t1119.scala new file mode 100644 index 000000000..8b36877c4 --- /dev/null +++ b/tests/pos/t1119.scala @@ -0,0 +1,10 @@ +trait B +{ + type T >: this.type <: B + + + // compile-time check: have we achieved our objective? + def test: T = this +} + + diff --git a/tests/pos/t1131.scala b/tests/pos/t1131.scala new file mode 100644 index 000000000..1b2a90457 --- /dev/null +++ b/tests/pos/t1131.scala @@ -0,0 +1,4 @@ +trait A { self: Any { def p: Any } => + def f(b: => Unit): Unit = {} + f { p } +} diff --git a/tests/pos/t1133.scala b/tests/pos/t1133.scala new file mode 100644 index 000000000..562b528ea --- /dev/null +++ b/tests/pos/t1133.scala @@ -0,0 +1,32 @@ +object Match +{ + def main(args: Array[String]) = { + args(0) match { + case Extractor1(Extractor2(Extractor3("dog", "dog", "dog"), x2, x3), b, c, Extractor3("b", "b", f), e) => println(e) + case Extractor3(Extractor2(Extractor1("a", "aa", "aaa", "aa", "a"), Extractor2("a", "aa", "aaa"), e), y, z) => println(e) + case Extractor2(Extractor3("a", "a", x), Extractor3("b", "b", y), Extractor3("c", "c", z)) => println(z) + case _ => println("fail") + } + } + + object Extractor1 { + def unapply(x: Any) = x match { + case x: String => Some(x, x+x, x+x+x, x+x, x) + case _ => None + } + } + + object Extractor2 { + def unapply(x: Any) = x match { + case x: String => Some(x, x+x, x+x+x) + case _ => None + } + } + + object Extractor3 { + def unapply(x: Any) = x match { + case x: String => Some(x, x, x) + case _ => None + } + } +} diff --git a/tests/pos/t1136.scala b/tests/pos/t1136.scala new file mode 100644 index 000000000..92d603e69 --- /dev/null +++ b/tests/pos/t1136.scala @@ -0,0 +1,8 @@ +object test { + def foo(s: Int*): Unit = { + s.toList match { + case t: List[Int] => foo(t: _*) + //case _ => // unreachable code + } + } +} diff --git a/tests/pos/t1146.scala b/tests/pos/t1146.scala new file mode 100644 index 000000000..7e5adc4f4 --- /dev/null +++ b/tests/pos/t1146.scala @@ -0,0 +1,6 @@ +class Code { + val _ = () => { + val arr = Array[String]() + null + } +} diff --git a/tests/pos/t1147.scala b/tests/pos/t1147.scala new file mode 100644 index 000000000..ff2e8bc52 --- /dev/null +++ b/tests/pos/t1147.scala @@ -0,0 +1,6 @@ +class App(arg: String) { + @deprecated("..") def this() = { + this("foo") + } +} + diff --git a/tests/pos/t115.scala b/tests/pos/t115.scala new file mode 100644 index 000000000..0e6a63c16 --- /dev/null +++ b/tests/pos/t115.scala @@ -0,0 +1,9 @@ +class S[A](f: A => A, x: A) { + Console.println(f(x)); +} +class T[B](f: B => B, y: B) extends S((x: B) => f(x), y) { +} +object Test extends App { + new T[Int](x => x * 2, 1); + val f = new S((x: Int) => x, 1); +} diff --git a/tests/pos/t1159.scala b/tests/pos/t1159.scala new file mode 100644 index 000000000..7e09418b2 --- /dev/null +++ b/tests/pos/t1159.scala @@ -0,0 +1,13 @@ +object test17 { + def main(args : Array[String]) = { + val value = + if (false) + new java.lang.Float(0) + else if (false) + new java.lang.Long(0) + else + new java.lang.Integer(0) + + println(value) + } +} diff --git a/tests/pos/t116.scala b/tests/pos/t116.scala new file mode 100644 index 000000000..1e31b71bf --- /dev/null +++ b/tests/pos/t116.scala @@ -0,0 +1,6 @@ +class C { + def this(x: Int) = { + this(); + class D extends C; + } +} 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/t1168.scala b/tests/pos/t1168.scala new file mode 100644 index 000000000..75638e792 --- /dev/null +++ b/tests/pos/t1168.scala @@ -0,0 +1,16 @@ +object Test extends App { + + trait SpecialException {} + + try { + throw new Exception + } catch { + case e : SpecialException => { + println("matched SpecialException: "+e) + assume(e.isInstanceOf[SpecialException]) + } + case e : Exception => { + assume(e.isInstanceOf[Exception]) + } + } +} diff --git a/tests/pos/t1185.scala b/tests/pos/t1185.scala new file mode 100644 index 000000000..fa863d158 --- /dev/null +++ b/tests/pos/t1185.scala @@ -0,0 +1,15 @@ +class Test { + private[this] var member = 0; + def foo() = { + (() => member=1)() + } + def look=member +} + +object Main{ + def main(args : Array[String]): Unit = { + val fff=new Test() + fff.foo() + assert(1==fff.look) + } +} diff --git a/tests/pos/t119.scala b/tests/pos/t119.scala new file mode 100644 index 000000000..44a156675 --- /dev/null +++ b/tests/pos/t119.scala @@ -0,0 +1,7 @@ +class K[E] { + case class A(v: E) {} +} + +class K2 extends K[Int] { + val A(v) = A(42) +} diff --git a/tests/pos/t1203a.scala b/tests/pos/t1203a.scala new file mode 100644 index 000000000..cf5ab9fba --- /dev/null +++ b/tests/pos/t1203a.scala @@ -0,0 +1,13 @@ +class Node +object NodeSeq { + implicit def seqToNodeSeq(s: Seq[Node]): NodeSeq = ??? +} +abstract class NodeSeq extends collection.immutable.Seq[Node] + +case class ant(t: String) extends scala.annotation.Annotation +object Test { + def main(args: Array[String]): Unit = { + val a: NodeSeq @ant("12") = Nil + println(a) + } +} diff --git a/tests/pos/t121.scala b/tests/pos/t121.scala new file mode 100644 index 000000000..78ddc41ee --- /dev/null +++ b/tests/pos/t121.scala @@ -0,0 +1,3 @@ +class Bug121_B(b: Array[Byte]) { + def get(x: Int): Byte = return b(x); +} diff --git a/tests/pos/t1210a.scala b/tests/pos/t1210a.scala new file mode 100644 index 000000000..b3492f96e --- /dev/null +++ b/tests/pos/t1210a.scala @@ -0,0 +1,15 @@ +// both styles of abstraction should behave the same +// related to 1210 because that bug broke the OO version below +trait OO { + abstract class Test { self => + type T + + val v: Test {type T = self.T} = self.v.v + } +} + +trait FP { + abstract class Test[T] { + val v: Test[T] = v.v + } +} diff --git a/tests/pos/t122.scala b/tests/pos/t122.scala new file mode 100644 index 000000000..630e24ce4 --- /dev/null +++ b/tests/pos/t122.scala @@ -0,0 +1,4 @@ +class L { + val List(v:Int, 2) = List(2, v:Int) + val (a:Int, b:Int) = (1, a) +} diff --git a/tests/pos/t1226.scala b/tests/pos/t1226.scala new file mode 100644 index 000000000..0af21cbb6 --- /dev/null +++ b/tests/pos/t1226.scala @@ -0,0 +1,8 @@ +package graphs; + +abstract class Graph (private[graphs] val mappings : Any){ +} + +class Nodes (mappings : Any) extends Graph(mappings) { + mappings.toString; +} diff --git a/tests/pos/t1237.scala b/tests/pos/t1237.scala new file mode 100644 index 000000000..31ba2966a --- /dev/null +++ b/tests/pos/t1237.scala @@ -0,0 +1,14 @@ +class HelloWorld { + def main(args: Array[String]): Unit = { + + object TypeBool; + + trait Fct { + def g(x : Int) = TypeBool // breaks. + + // def g(x : Int) = 3 // fine. + } + + () + } +} diff --git a/tests/pos/t124.scala b/tests/pos/t124.scala new file mode 100644 index 000000000..9aed6786f --- /dev/null +++ b/tests/pos/t124.scala @@ -0,0 +1,5 @@ +class N{ + val F: Any => Any = (x:Any) => F(x); + val f:(Any => Any) = (x:Any) => f(x); + val g: Any => Any = (x:Any) => g(x); +} diff --git a/tests/pos/t1260.scala b/tests/pos/t1260.scala new file mode 100644 index 000000000..02f9e7e6b --- /dev/null +++ b/tests/pos/t1260.scala @@ -0,0 +1,18 @@ +case class Foo(a: String, b: String) + +object Bar { + def unapply(s: String): Option[Long] = + try { Some(s.toLong) } catch { case _ => None } +} + +object Test { + def main(args: Array[String]): Unit = { + val f = Foo("1", "2") + f match { + case Foo(Bar(1), Bar(2)) => 1 + case Foo(Bar(i), Bar(j)) if i >= 0 => 2 + case _ => 3 + } + } +} + diff --git a/tests/untried/pos/t1000.scala b/tests/untried/pos/t1000.scala deleted file mode 100644 index 613af76b9..000000000 --- a/tests/untried/pos/t1000.scala +++ /dev/null @@ -1,8 +0,0 @@ -object A { - println("""This a "raw" string ending with a "double quote"""") -} - -object Test extends App { - val xs = Array(1, 2, 3) - Console.println(xs.filter(_ >= 0).length) -} diff --git a/tests/untried/pos/t1001.scala b/tests/untried/pos/t1001.scala deleted file mode 100644 index 7a06bfa0e..000000000 --- a/tests/untried/pos/t1001.scala +++ /dev/null @@ -1,115 +0,0 @@ -// was t1001.scala -class Foo; - -object Overload{ - val foo = classOf[Foo].getConstructors()(0) - foo.getDeclaringClass -} - -// was t1001.scala - -// I suspect the stack overflow is occurring when the compiler is determining the types for the following line at the end of the file:- -// val data = List(N26,N25) - -abstract class A -{ - // commenting out the following line (only) leads to successful compilation - protected val data: List[A] -} - -trait B[T <: B[T]] extends A { self: T => } - -abstract class C extends A -{ - // commenting out the following line (only) leads to successful compilation - protected val data: List[C] -} - -abstract class D extends C with B[D] {} - -abstract class Ee extends C with B[Ee] -{ -} - - -object N1 extends D -{ - val data = Nil -} - -object N2 extends D -{ - val data = Nil -} - -object N5 extends D -{ - val data = List(N1) -} - -object N6 extends D -{ - val data = List(N1) -} - -object N8 extends D -{ - val data = List(N1) -} - -object N10 extends D -{ - val data = Nil -} - -object N13 extends D -{ - val data = List(N2) -} - -object N14 extends D -{ - val data = List(N5,N10,N8) -} - -object N15 extends D -{ - val data = List(N14) -} - -object N16 extends D -{ - val data = List(N13,N6,N15) -} - -object N17 extends D -{ - val data = List(N16) -} - -object N21 extends D -{ - val data = List(N16) -} - -object N22 extends D -{ - val data = List(N17) -} - -object N25 extends D -{ - val data = List(N22) -} - -object N26 extends Ee -{ - val data = List(N21,N17) -} - -// Commenting out the following object (only) leads to successful compilation -object N31 extends Ee -{ - // If we use List[C](N26,N25), we achieve successful compilation - val data = List[C](N26,N25) -} diff --git a/tests/untried/pos/t1006.scala b/tests/untried/pos/t1006.scala deleted file mode 100644 index 2163b2b74..000000000 --- a/tests/untried/pos/t1006.scala +++ /dev/null @@ -1,15 +0,0 @@ -object Test extends App { - -def test(): Unit = { - - abstract class A[T] { - def myVal: T - } - - class B[T1](value: T1) extends A[T1] { - def myVal: T1 = value - } - - Console.println(new B[Int](23).myVal) -} -} diff --git a/tests/untried/pos/t1014.scala b/tests/untried/pos/t1014.scala deleted file mode 100644 index 6fb7f7ba4..000000000 --- a/tests/untried/pos/t1014.scala +++ /dev/null @@ -1,16 +0,0 @@ -class NodeSeq -class Elem extends NodeSeq - -class EO extends App with Moo { - // return type is Flog, inherited from overridden method. - // implicit conversions are applied because expected type `pt` is `Flog` when `computeType(rhs, pt)`. - def cat = (??? : Elem) - - implicit def nodeSeqToFlog(in: Elem): Flog = new Flog(in) -} - -trait Moo { - def cat: Flog -} - -class Flog(val in: NodeSeq) diff --git a/tests/untried/pos/t1027.scala b/tests/untried/pos/t1027.scala deleted file mode 100644 index 02ba9a8a3..000000000 --- a/tests/untried/pos/t1027.scala +++ /dev/null @@ -1,18 +0,0 @@ -object T1027 extends App { - trait Comparable[T <: Comparable[T]] { this: T => - def < (that: T): Boolean - def <=(that: T): Boolean = this < that || this == that - def > (that: T): Boolean = that < this - def >=(that: T): Boolean = that <= this - } - class A(val x: String) extends Comparable[A]{ - def < (that: A) = this.x < that.x - } - val a = new A("a") - val b = new A("b") - println(a < b) - println(a > b) - println(a <= b) - println(a >= b) - println("Comparable traits : " + (new A("x") > new A("y")).toString) - } diff --git a/tests/untried/pos/t1034.scala b/tests/untried/pos/t1034.scala deleted file mode 100644 index 9d966334a..000000000 --- a/tests/untried/pos/t1034.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Terminal { - def apply[a] : a => Unit = { a => () } - val i0 = Terminal.apply[Int] - val i1 = (Terminal)[Int] - val i2 = Terminal[Int] -} diff --git a/tests/untried/pos/t1035.scala b/tests/untried/pos/t1035.scala deleted file mode 100644 index e0a9379c7..000000000 --- a/tests/untried/pos/t1035.scala +++ /dev/null @@ -1,32 +0,0 @@ -//A fatal error or Scala compiler -// Scala compiler version 2.7.1-final -- (c) 2002-2011 LAMP/EPFL -// Carlos Loria cloria@artinsoft.com -// 7/10/2008 - -class A { - var name:String = _ - def getName() = name - def this(name:String, age:Int){this();this.name=name} - -} - -class B(name:String) extends A(name,0){ -} - -class D { - - object A { - def unapply(p:A) = Some(p.getName) - } - - object B { - def unapply(p:B) = Some(p.getName) - } - def foo(p:Any) = p match { - case B(n) => println("B") - case A(n) => println("A") - - - } - -} diff --git a/tests/untried/pos/t1048.scala b/tests/untried/pos/t1048.scala deleted file mode 100644 index cd16db5b6..000000000 --- a/tests/untried/pos/t1048.scala +++ /dev/null @@ -1,14 +0,0 @@ -trait T[U] { - def x: T[V] forSome { type V <: U } -} - -object T { - def unapply[U](t: T[U]): Option[T[V] forSome { type V <: U }] = Some(t.x) -} - -object Test { - def f[W](t: T[W]) = t match { - case T(T(_)) => () - } -} - diff --git a/tests/untried/pos/t1049.scala b/tests/untried/pos/t1049.scala deleted file mode 100644 index 61d99f946..000000000 --- a/tests/untried/pos/t1049.scala +++ /dev/null @@ -1,7 +0,0 @@ -package t1049 - -abstract class Test { - type T <: A - class A { self: T => } - class B extends A { self: T => } -} diff --git a/tests/untried/pos/t1050.scala b/tests/untried/pos/t1050.scala deleted file mode 100644 index d34b0cff1..000000000 --- a/tests/untried/pos/t1050.scala +++ /dev/null @@ -1,10 +0,0 @@ -package t1050 - -abstract class A { - type T <: scala.AnyRef - class A { this: T => - def b = 3 - def c = b - b - } -} diff --git a/tests/untried/pos/t1053.scala b/tests/untried/pos/t1053.scala deleted file mode 100644 index 1d4dfb637..000000000 --- a/tests/untried/pos/t1053.scala +++ /dev/null @@ -1,6 +0,0 @@ -trait T[A] { trait U { type W = A; val x = 3 } } - -object Test { - val x : ({ type V = T[this.type] })#V = null - val y = new x.U { } -} diff --git a/tests/untried/pos/t1070.scala b/tests/untried/pos/t1070.scala deleted file mode 100644 index 1622043a8..000000000 --- a/tests/untried/pos/t1070.scala +++ /dev/null @@ -1,4 +0,0 @@ -import scala.beans.BeanProperty; -trait beanpropertytrait { - @BeanProperty var myVariable: Long = -1l; -} diff --git a/tests/untried/pos/t1071.scala b/tests/untried/pos/t1071.scala deleted file mode 100644 index 59149a021..000000000 --- a/tests/untried/pos/t1071.scala +++ /dev/null @@ -1,17 +0,0 @@ -class C { - private val a = 0 - def getA = a -} - -class D(c: C) { - def a = c.getA -} - -object Test { - implicit def c2d(c: C): D = new D(c) - - val c = new C - (c: D).a // works - c.a // error -} - diff --git a/tests/untried/pos/t1075.scala b/tests/untried/pos/t1075.scala deleted file mode 100644 index 5f72957da..000000000 --- a/tests/untried/pos/t1075.scala +++ /dev/null @@ -1,17 +0,0 @@ -class Directory(var dir_ : String) -{ - if (!dir_.startsWith("/")) { - throw new RuntimeException("Invalid directory") - } - dir_ = dir_.replaceAll("/{2,}", "/") - - def this(serialized : Array[Byte]) = { - this(new String(serialized, "UTF-8")) - } - - def dir = dir_ -} - -object Test extends Directory("/bab/dkkd//dkkdkd//kdkdk") with App { - println(dir) -} diff --git a/tests/untried/pos/t1085.scala b/tests/untried/pos/t1085.scala deleted file mode 100644 index c59e657cb..000000000 --- a/tests/untried/pos/t1085.scala +++ /dev/null @@ -1,9 +0,0 @@ -trait Functor[a] { - type MyType[a] -} - -object Test { - def listFunctor[a]: Functor[a]{type MyType[x]=List[x]} = new Functor[a] { - type MyType[t]=List[t] - } -} diff --git a/tests/untried/pos/t1090.scala b/tests/untried/pos/t1090.scala deleted file mode 100644 index a9bce90b0..000000000 --- a/tests/untried/pos/t1090.scala +++ /dev/null @@ -1,16 +0,0 @@ -object Test { - trait Manager { - type Node; - def iterator : Iterator[Node] - } - trait Core { - type Node; - trait NodeImpl - trait Manager extends Test.Manager { - type Node = Core.this.Node - } - def f(manager : Manager) = manager.iterator.foreach{ - case node : NodeImpl => - } - } -} diff --git a/tests/untried/pos/t1107a.scala b/tests/untried/pos/t1107a.scala deleted file mode 100644 index 0bf40bb4c..000000000 --- a/tests/untried/pos/t1107a.scala +++ /dev/null @@ -1,10 +0,0 @@ -object F { - type AnyClass = Class[_] - def tryf[T](ignore: List[AnyClass])(f: => T): Any = { - try { - f - } catch { - case e if ignore == null || ignore.isEmpty => {false} - } - } -} diff --git a/tests/untried/pos/t1119.scala b/tests/untried/pos/t1119.scala deleted file mode 100644 index 8b36877c4..000000000 --- a/tests/untried/pos/t1119.scala +++ /dev/null @@ -1,10 +0,0 @@ -trait B -{ - type T >: this.type <: B - - - // compile-time check: have we achieved our objective? - def test: T = this -} - - diff --git a/tests/untried/pos/t1131.scala b/tests/untried/pos/t1131.scala deleted file mode 100644 index 1b2a90457..000000000 --- a/tests/untried/pos/t1131.scala +++ /dev/null @@ -1,4 +0,0 @@ -trait A { self: Any { def p: Any } => - def f(b: => Unit): Unit = {} - f { p } -} diff --git a/tests/untried/pos/t1133.scala b/tests/untried/pos/t1133.scala deleted file mode 100644 index 562b528ea..000000000 --- a/tests/untried/pos/t1133.scala +++ /dev/null @@ -1,32 +0,0 @@ -object Match -{ - def main(args: Array[String]) = { - args(0) match { - case Extractor1(Extractor2(Extractor3("dog", "dog", "dog"), x2, x3), b, c, Extractor3("b", "b", f), e) => println(e) - case Extractor3(Extractor2(Extractor1("a", "aa", "aaa", "aa", "a"), Extractor2("a", "aa", "aaa"), e), y, z) => println(e) - case Extractor2(Extractor3("a", "a", x), Extractor3("b", "b", y), Extractor3("c", "c", z)) => println(z) - case _ => println("fail") - } - } - - object Extractor1 { - def unapply(x: Any) = x match { - case x: String => Some(x, x+x, x+x+x, x+x, x) - case _ => None - } - } - - object Extractor2 { - def unapply(x: Any) = x match { - case x: String => Some(x, x+x, x+x+x) - case _ => None - } - } - - object Extractor3 { - def unapply(x: Any) = x match { - case x: String => Some(x, x, x) - case _ => None - } - } -} diff --git a/tests/untried/pos/t1136.scala b/tests/untried/pos/t1136.scala deleted file mode 100644 index 92d603e69..000000000 --- a/tests/untried/pos/t1136.scala +++ /dev/null @@ -1,8 +0,0 @@ -object test { - def foo(s: Int*): Unit = { - s.toList match { - case t: List[Int] => foo(t: _*) - //case _ => // unreachable code - } - } -} diff --git a/tests/untried/pos/t1146.scala b/tests/untried/pos/t1146.scala deleted file mode 100644 index 7e5adc4f4..000000000 --- a/tests/untried/pos/t1146.scala +++ /dev/null @@ -1,6 +0,0 @@ -class Code { - val _ = () => { - val arr = Array[String]() - null - } -} diff --git a/tests/untried/pos/t1147.scala b/tests/untried/pos/t1147.scala deleted file mode 100644 index ff2e8bc52..000000000 --- a/tests/untried/pos/t1147.scala +++ /dev/null @@ -1,6 +0,0 @@ -class App(arg: String) { - @deprecated("..") def this() = { - this("foo") - } -} - diff --git a/tests/untried/pos/t115.scala b/tests/untried/pos/t115.scala deleted file mode 100644 index 0e6a63c16..000000000 --- a/tests/untried/pos/t115.scala +++ /dev/null @@ -1,9 +0,0 @@ -class S[A](f: A => A, x: A) { - Console.println(f(x)); -} -class T[B](f: B => B, y: B) extends S((x: B) => f(x), y) { -} -object Test extends App { - new T[Int](x => x * 2, 1); - val f = new S((x: Int) => x, 1); -} diff --git a/tests/untried/pos/t1159.scala b/tests/untried/pos/t1159.scala deleted file mode 100644 index 7e09418b2..000000000 --- a/tests/untried/pos/t1159.scala +++ /dev/null @@ -1,13 +0,0 @@ -object test17 { - def main(args : Array[String]) = { - val value = - if (false) - new java.lang.Float(0) - else if (false) - new java.lang.Long(0) - else - new java.lang.Integer(0) - - println(value) - } -} diff --git a/tests/untried/pos/t116.scala b/tests/untried/pos/t116.scala deleted file mode 100644 index 1e31b71bf..000000000 --- a/tests/untried/pos/t116.scala +++ /dev/null @@ -1,6 +0,0 @@ -class C { - def this(x: Int) = { - this(); - class D extends C; - } -} diff --git a/tests/untried/pos/t1164.scala b/tests/untried/pos/t1164.scala deleted file mode 100644 index ab58c1d6b..000000000 --- a/tests/untried/pos/t1164.scala +++ /dev/null @@ -1,29 +0,0 @@ - - -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/untried/pos/t1168.scala b/tests/untried/pos/t1168.scala deleted file mode 100644 index 75638e792..000000000 --- a/tests/untried/pos/t1168.scala +++ /dev/null @@ -1,16 +0,0 @@ -object Test extends App { - - trait SpecialException {} - - try { - throw new Exception - } catch { - case e : SpecialException => { - println("matched SpecialException: "+e) - assume(e.isInstanceOf[SpecialException]) - } - case e : Exception => { - assume(e.isInstanceOf[Exception]) - } - } -} diff --git a/tests/untried/pos/t1185.scala b/tests/untried/pos/t1185.scala deleted file mode 100644 index fa863d158..000000000 --- a/tests/untried/pos/t1185.scala +++ /dev/null @@ -1,15 +0,0 @@ -class Test { - private[this] var member = 0; - def foo() = { - (() => member=1)() - } - def look=member -} - -object Main{ - def main(args : Array[String]): Unit = { - val fff=new Test() - fff.foo() - assert(1==fff.look) - } -} diff --git a/tests/untried/pos/t119.scala b/tests/untried/pos/t119.scala deleted file mode 100644 index 44a156675..000000000 --- a/tests/untried/pos/t119.scala +++ /dev/null @@ -1,7 +0,0 @@ -class K[E] { - case class A(v: E) {} -} - -class K2 extends K[Int] { - val A(v) = A(42) -} diff --git a/tests/untried/pos/t1203a.scala b/tests/untried/pos/t1203a.scala deleted file mode 100644 index cf5ab9fba..000000000 --- a/tests/untried/pos/t1203a.scala +++ /dev/null @@ -1,13 +0,0 @@ -class Node -object NodeSeq { - implicit def seqToNodeSeq(s: Seq[Node]): NodeSeq = ??? -} -abstract class NodeSeq extends collection.immutable.Seq[Node] - -case class ant(t: String) extends scala.annotation.Annotation -object Test { - def main(args: Array[String]): Unit = { - val a: NodeSeq @ant("12") = Nil - println(a) - } -} diff --git a/tests/untried/pos/t1208.scala b/tests/untried/pos/t1208.scala deleted file mode 100644 index 9ac783d39..000000000 --- a/tests/untried/pos/t1208.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test { - object Foo - val f: Option[Foo.type] = Some(Foo) -} diff --git a/tests/untried/pos/t121.scala b/tests/untried/pos/t121.scala deleted file mode 100644 index 78ddc41ee..000000000 --- a/tests/untried/pos/t121.scala +++ /dev/null @@ -1,3 +0,0 @@ -class Bug121_B(b: Array[Byte]) { - def get(x: Int): Byte = return b(x); -} diff --git a/tests/untried/pos/t1210a.scala b/tests/untried/pos/t1210a.scala deleted file mode 100644 index b3492f96e..000000000 --- a/tests/untried/pos/t1210a.scala +++ /dev/null @@ -1,15 +0,0 @@ -// both styles of abstraction should behave the same -// related to 1210 because that bug broke the OO version below -trait OO { - abstract class Test { self => - type T - - val v: Test {type T = self.T} = self.v.v - } -} - -trait FP { - abstract class Test[T] { - val v: Test[T] = v.v - } -} diff --git a/tests/untried/pos/t122.scala b/tests/untried/pos/t122.scala deleted file mode 100644 index 630e24ce4..000000000 --- a/tests/untried/pos/t122.scala +++ /dev/null @@ -1,4 +0,0 @@ -class L { - val List(v:Int, 2) = List(2, v:Int) - val (a:Int, b:Int) = (1, a) -} diff --git a/tests/untried/pos/t1226.scala b/tests/untried/pos/t1226.scala deleted file mode 100644 index 0af21cbb6..000000000 --- a/tests/untried/pos/t1226.scala +++ /dev/null @@ -1,8 +0,0 @@ -package graphs; - -abstract class Graph (private[graphs] val mappings : Any){ -} - -class Nodes (mappings : Any) extends Graph(mappings) { - mappings.toString; -} diff --git a/tests/untried/pos/t1236.scala b/tests/untried/pos/t1236.scala deleted file mode 100644 index 75a1befd2..000000000 --- a/tests/untried/pos/t1236.scala +++ /dev/null @@ -1,14 +0,0 @@ -trait Empty[E[_]] { - def e[A]: E[A] -} - -object T { - val ListEmpty = new Empty[List] { - def e[A] = Nil - } - - def foo[F[_]](q:(String,String)) = "hello" - def foo[F[_]](e: Empty[F]) = "world" - - val x = foo[List](ListEmpty) -} diff --git a/tests/untried/pos/t1237.scala b/tests/untried/pos/t1237.scala deleted file mode 100644 index 31ba2966a..000000000 --- a/tests/untried/pos/t1237.scala +++ /dev/null @@ -1,14 +0,0 @@ -class HelloWorld { - def main(args: Array[String]): Unit = { - - object TypeBool; - - trait Fct { - def g(x : Int) = TypeBool // breaks. - - // def g(x : Int) = 3 // fine. - } - - () - } -} diff --git a/tests/untried/pos/t124.scala b/tests/untried/pos/t124.scala deleted file mode 100644 index 9aed6786f..000000000 --- a/tests/untried/pos/t124.scala +++ /dev/null @@ -1,5 +0,0 @@ -class N{ - val F: Any => Any = (x:Any) => F(x); - val f:(Any => Any) = (x:Any) => f(x); - val g: Any => Any = (x:Any) => g(x); -} diff --git a/tests/untried/pos/t1260.scala b/tests/untried/pos/t1260.scala deleted file mode 100644 index 02f9e7e6b..000000000 --- a/tests/untried/pos/t1260.scala +++ /dev/null @@ -1,18 +0,0 @@ -case class Foo(a: String, b: String) - -object Bar { - def unapply(s: String): Option[Long] = - try { Some(s.toLong) } catch { case _ => None } -} - -object Test { - def main(args: Array[String]): Unit = { - val f = Foo("1", "2") - f match { - case Foo(Bar(1), Bar(2)) => 1 - case Foo(Bar(i), Bar(j)) if i >= 0 => 2 - case _ => 3 - } - } -} - diff --git a/tests/untried/pos/t1272.scala b/tests/untried/pos/t1272.scala deleted file mode 100644 index 916b783bb..000000000 --- a/tests/untried/pos/t1272.scala +++ /dev/null @@ -1,9 +0,0 @@ -object ImplicitTest { - implicit val i : Int = 10 - implicit def a(implicit i : Int) : Array[Byte] = null - implicit def b[T](implicit i : Int) : Array[T] = null - - def fn[T](implicit x : T) = 0 - - val x = fn[Array[Byte]] -} diff --git a/tests/untried/pos/t1279a.scala b/tests/untried/pos/t1279a.scala deleted file mode 100644 index 18b1e53f4..000000000 --- a/tests/untried/pos/t1279a.scala +++ /dev/null @@ -1,39 +0,0 @@ -// covariant linked list -abstract class M { - self => - - type T - final type selfType = M {type T <: self.T} - type actualSelfType >: self.type <: selfType - - def next: selfType - - // I don't understand why this doesn't compile, but that's a separate matter - // error: method all2 cannot be accessed in M.this.selfType - // because its instance type => Stream[M{type T <: M.this.selfType#T}] - // contains a malformed type: M.this.selfType#T - def all2: Stream[M {type T <: self.T}] = Stream.cons(self: actualSelfType, next.all2) - - // compiles successfully - def all3: Stream[M {type T <: self.T}] = all3Impl(self: actualSelfType) - private def all3Impl(first: M {type T <: self.T}): Stream[M {type T <: self.T}] = Stream.cons(first, all3Impl(first.next)) - - def all4: Stream[M {type T <: self.T}] = Unrelated.all4Impl[T](self: actualSelfType) -} - -// TODO!!! fix this bug for real, it compiles successfully, but weird types are inferred -object Unrelated { - // compiles successfully - def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl[U](first.next)) - - // should compile successfully without the [U], but: - // def all4ImplFail[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4ImplFail(first.next)) - // - // test/files/pos/t1279a.scala:31: error: type mismatch; - // found : first.selfType - // (which expands to) M{type T <: first.T} - // required: M{type T <: Nothing} - // def all4ImplFail[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4ImplFail(first.next)) - // ^ - // one error found -} diff --git a/tests/untried/pos/t1280.scala b/tests/untried/pos/t1280.scala deleted file mode 100644 index 39406b2e3..000000000 --- a/tests/untried/pos/t1280.scala +++ /dev/null @@ -1 +0,0 @@ -trait X { x => type T >: Null; new X { type T = Any with x.T } } diff --git a/tests/untried/pos/t1292.scala b/tests/untried/pos/t1292.scala deleted file mode 100644 index 83a996d53..000000000 --- a/tests/untried/pos/t1292.scala +++ /dev/null @@ -1,33 +0,0 @@ -trait Foo[T <: Foo[T, Enum], Enum <: Enumeration] { - type StV = Enum#Value - type Meta = MegaFoo[T, Enum] - - type Slog <: Enumeration - - def getSingleton: Meta -} - -trait MegaFoo[T <: Foo[T, Enum], Enum <: Enumeration] extends Foo[T, Enum] { - def doSomething(what: T, misc: StV, dog: Meta#Event) = None - abstract class Event - object Event - - def stateEnumeration: Slog - def se2: Enum -} - -object E extends Enumeration { - val A = Value - val B = Value -} - -class RFoo extends Foo[RFoo, E.type] { - def getSingleton = MegaRFoo - - type Slog = E.type -} - -object MegaRFoo extends RFoo with MegaFoo[RFoo, E.type] { - def stateEnumeration = E - def se2 = E -} -- cgit v1.2.3