diff options
Diffstat (limited to 'test/files')
110 files changed, 1828 insertions, 280 deletions
diff --git a/test/files/jvm/non-fatal-tests.scala b/test/files/jvm/non-fatal-tests.scala index 791b1d3100..1ff7ee516e 100644 --- a/test/files/jvm/non-fatal-tests.scala +++ b/test/files/jvm/non-fatal-tests.scala @@ -4,8 +4,7 @@ trait NonFatalTests { //NonFatals val nonFatals: Seq[Throwable] = - Seq(new StackOverflowError, - new RuntimeException, + Seq(new RuntimeException, new Exception, new Throwable, new NotImplementedError) @@ -13,6 +12,7 @@ trait NonFatalTests { //Fatals val fatals: Seq[Throwable] = Seq(new InterruptedException, + new StackOverflowError, new OutOfMemoryError, new LinkageError, new VirtualMachineError {}, diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala index 1d6f0b7907..4f900d98d7 100644 --- a/test/files/jvm/typerep.scala +++ b/test/files/jvm/typerep.scala @@ -86,7 +86,7 @@ object testArrays { object testTuples { println(getType((3, "abc"))) - println(getType(Triple('a', 'b', "c"))) + println(getType(('a', 'b', "c"))) println(getType(((3, "abc"), (4, "xyz")))) println(getType(((Some('b'), 3), (Some('a'), 4)))) //println(getType(((Some('b'), 3), (None, 4)))) diff --git a/test/files/neg/class-of-double-targs.check b/test/files/neg/class-of-double-targs.check new file mode 100644 index 0000000000..f7e2094f97 --- /dev/null +++ b/test/files/neg/class-of-double-targs.check @@ -0,0 +1,4 @@ +class-of-double-targs.scala:2: error: expression of type Class[Int](classOf[scala.Int]) does not take type parameters. + classOf[Int][Int] + ^ +one error found diff --git a/test/files/neg/class-of-double-targs.scala b/test/files/neg/class-of-double-targs.scala new file mode 100644 index 0000000000..26a2fa8381 --- /dev/null +++ b/test/files/neg/class-of-double-targs.scala @@ -0,0 +1,3 @@ +object Test { + classOf[Int][Int] +} diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala index aa7dac7d7d..f937197829 100644 --- a/test/files/neg/patmatexhaust.scala +++ b/test/files/neg/patmatexhaust.scala @@ -22,9 +22,9 @@ class TestSealedExhaustive { // compile only def ma3(x:Mult) = (x,x) match { // not exhaustive case (Kult(_), Qult()) => // Kult missing - //case Pair(Kult(_), Kult(_)) => + //case (Kult(_), Kult(_)) => case (Qult(), Kult(_)) => // Qult missing - //case Pair(Qult(), Qult()) => + //case (Qult(), Qult()) => } def ma3u(x:Mult) = ((x,x) : @unchecked) match { // not exhaustive, but not checked! diff --git a/test/files/neg/t414.scala b/test/files/neg/t414.scala index 1662b9a105..86646d13c2 100644 --- a/test/files/neg/t414.scala +++ b/test/files/neg/t414.scala @@ -1,5 +1,5 @@ case class Empty[a]() extends IntMap[a]; -case class Node[a](left: IntMap[a], keyVal: Pair[Int, a], right: IntMap[a]) extends IntMap[a]; +case class Node[a](left: IntMap[a], keyVal: Tuple2[Int, a], right: IntMap[a]) extends IntMap[a]; abstract class IntMap[a] { def lookup(key: Int): a = this match { case Empty => diff --git a/test/files/neg/t5702-neg-bad-and-wild.check b/test/files/neg/t5702-neg-bad-and-wild.check index ff9e5e5703..a52136dbf8 100644 --- a/test/files/neg/t5702-neg-bad-and-wild.check +++ b/test/files/neg/t5702-neg-bad-and-wild.check @@ -23,6 +23,6 @@ t5702-neg-bad-and-wild.scala:23: error: bad simple pattern: bad use of _* (a seq val K(ns @ _*, x) = k // bad use of _* (a sequence pattern must be the last pattern) ^ t5702-neg-bad-and-wild.scala:24: error: bad simple pattern: bad use of _* (sequence pattern not allowed) - val (b, _ * ) = Pair(5,6) // bad use of _* (sequence pattern not allowed) + val (b, _ * ) = (5,6) // bad use of _* (sequence pattern not allowed) ^ 9 errors found diff --git a/test/files/neg/t5702-neg-bad-and-wild.scala b/test/files/neg/t5702-neg-bad-and-wild.scala index 3833a002b1..aadda37da7 100644 --- a/test/files/neg/t5702-neg-bad-and-wild.scala +++ b/test/files/neg/t5702-neg-bad-and-wild.scala @@ -21,7 +21,7 @@ object Test { //gowild.scala:14: error: star patterns must correspond with varargs parameters val K(is @ _*) = k val K(ns @ _*, x) = k // bad use of _* (a sequence pattern must be the last pattern) - val (b, _ * ) = Pair(5,6) // bad use of _* (sequence pattern not allowed) + val (b, _ * ) = (5,6) // bad use of _* (sequence pattern not allowed) // no longer complains //bad-and-wild.scala:15: error: ')' expected but '}' found. } diff --git a/test/files/neg/t7605-deprecation.check b/test/files/neg/t7605-deprecation.check index 9c466c058c..6db94613a1 100644 --- a/test/files/neg/t7605-deprecation.check +++ b/test/files/neg/t7605-deprecation.check @@ -1,12 +1,15 @@ -t7605-deprecation.scala:2: warning: Procedure syntax is deprecated. Convert procedure to method by adding `: Unit =`. - def this(i: Int) { this() } - ^ -t7605-deprecation.scala:3: warning: Procedure syntax is deprecated. Convert procedure to method by adding `: Unit =`. +t7605-deprecation.scala:2: warning: Procedure syntax is deprecated. Convert procedure `bar` to method by adding `: Unit =`. def bar {} ^ -t7605-deprecation.scala:4: warning: Procedure syntax is deprecated. Convert procedure to method by adding `: Unit`. +t7605-deprecation.scala:3: warning: Procedure syntax is deprecated. Convert procedure `baz` to method by adding `: Unit`. def baz ^ +t7605-deprecation.scala:4: warning: Procedure syntax is deprecated. Convert procedure `boo` to method by adding `: Unit`. + def boo(i: Int, l: Long) + ^ +t7605-deprecation.scala:5: warning: Procedure syntax is deprecated. Convert procedure `boz` to method by adding `: Unit =`. + def boz(i: Int, l: Long) {} + ^ error: No warnings can be incurred under -Xfatal-warnings. -three warnings found +four warnings found one error found diff --git a/test/files/neg/t7605-deprecation.scala b/test/files/neg/t7605-deprecation.scala index 4a7dcd26d6..2b3362f94a 100644 --- a/test/files/neg/t7605-deprecation.scala +++ b/test/files/neg/t7605-deprecation.scala @@ -1,5 +1,8 @@ abstract class Foo { - def this(i: Int) { this() } def bar {} def baz -}
\ No newline at end of file + def boo(i: Int, l: Long) + def boz(i: Int, l: Long) {} + def this(i: Int) { this() } // Don't complain here! + def foz: Unit // Don't complain here! +} diff --git a/test/files/neg/t997.scala b/test/files/neg/t997.scala index e8d10f4317..1198738f24 100644 --- a/test/files/neg/t997.scala +++ b/test/files/neg/t997.scala @@ -1,5 +1,5 @@ // An extractor with 2 results -object Foo { def unapply(x : String) = Some(Pair(x, x)) } +object Foo { def unapply(x : String) = Some((x, x)) } object Test extends App { diff --git a/test/files/neg/wellkinded_wrongarity.check b/test/files/neg/wellkinded_wrongarity.check index 1dc38db5c1..b9f033b453 100644 --- a/test/files/neg/wellkinded_wrongarity.check +++ b/test/files/neg/wellkinded_wrongarity.check @@ -1,4 +1,4 @@ -wellkinded_wrongarity.scala:5: error: Pair takes two type parameters, expected: one -object mp extends Monad[Pair] +wellkinded_wrongarity.scala:5: error: Tuple2 takes two type parameters, expected: one +object mp extends Monad[Tuple2] ^ one error found diff --git a/test/files/neg/wellkinded_wrongarity.scala b/test/files/neg/wellkinded_wrongarity.scala index 2bb0e2ce8a..39c7601d53 100644 --- a/test/files/neg/wellkinded_wrongarity.scala +++ b/test/files/neg/wellkinded_wrongarity.scala @@ -2,4 +2,4 @@ class Monad[m[x]] -object mp extends Monad[Pair] +object mp extends Monad[Tuple2] diff --git a/test/files/pos/bounds.scala b/test/files/pos/bounds.scala index cfea4626c3..26bc84a1b9 100644 --- a/test/files/pos/bounds.scala +++ b/test/files/pos/bounds.scala @@ -1,11 +1,11 @@ trait Map[A, +C] { - def ++ [B1 >: C] (kvs: Iterable[Pair[A, B1]]): Map[A, B1] = this - def ++ [B1 >: C] (kvs: Iterator[Pair[A, B1]]): Map[A, B1] = this + def ++ [B1 >: C] (kvs: Iterable[Tuple2[A, B1]]): Map[A, B1] = this + def ++ [B1 >: C] (kvs: Iterator[Tuple2[A, B1]]): Map[A, B1] = this } class ListMap[A, +B] extends Map[A, B] {} object ListMap { def empty[X, Y] = new ListMap[X, Y] - def apply[A1, B2](elems: Pair[A1, B2]*): Map[A1, B2] = empty[A1,B2].++(elems.iterator) + def apply[A1, B2](elems: Tuple2[A1, B2]*): Map[A1, B2] = empty[A1,B2].++(elems.iterator) } diff --git a/test/files/pos/macro-implicit-invalidate-on-error.check b/test/files/pos/macro-implicit-invalidate-on-error.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/pos/macro-implicit-invalidate-on-error.check diff --git a/test/files/pos/macro-implicit-invalidate-on-error.scala b/test/files/pos/macro-implicit-invalidate-on-error.scala new file mode 100644 index 0000000000..22cd2d34b4 --- /dev/null +++ b/test/files/pos/macro-implicit-invalidate-on-error.scala @@ -0,0 +1,28 @@ +package scala.reflect +package api + +import scala.language.experimental.macros +import scala.reflect.macros.Context + +trait Liftable[T] { + def apply(universe: api.Universe, value: T): universe.Tree +} + +object Liftable { + implicit def liftCaseClass[T <: Product]: Liftable[T] = macro liftCaseClassImpl[T] + + def liftCaseClassImpl[T: c.WeakTypeTag](c: Context): c.Expr[Liftable[T]] = { + import c.universe._ + val tpe = weakTypeOf[T] + if (!tpe.typeSymbol.asClass.isCaseClass) c.abort(c.enclosingPosition, "denied") + val p = List(q"Literal(Constant(1))") + c.Expr[Liftable[T]] { q""" + new scala.reflect.api.Liftable[$tpe] { + def apply(universe: scala.reflect.api.Universe, value: $tpe): universe.Tree = { + import universe._ + Apply(Select(Ident(TermName("C")), TermName("apply")), List(..$p)) + } + } + """ } + } +} diff --git a/test/files/pos/patmat.scala b/test/files/pos/patmat.scala index 4e652b146e..51b879abf2 100644 --- a/test/files/pos/patmat.scala +++ b/test/files/pos/patmat.scala @@ -3,8 +3,8 @@ object ZipFun { //just compilation - def zipFun[a, b](xs: List[a], ys: List[b]): List[Pair[a, b]] = (Pair(xs, ys): @unchecked) match { - // !!! case Pair(List(), _), Pair(_, List()) => List() + def zipFun[a, b](xs: List[a], ys: List[b]): List[Tuple2[a, b]] = ((xs, ys): @unchecked) match { + // !!! case (List(), _), (_, List()) => List() case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1) } } diff --git a/test/files/pos/spec-doubledef-new.scala b/test/files/pos/spec-doubledef-new.scala index ad9c6399a5..589ceb33b2 100644 --- a/test/files/pos/spec-doubledef-new.scala +++ b/test/files/pos/spec-doubledef-new.scala @@ -19,12 +19,12 @@ abstract class B[T, @specialized(scala.Int) U : TypeTag, @specialized(scala.Int) val u: U val v: V - def f(t: T, v2: V): Pair[U, V] = { + def f(t: T, v2: V): Tuple2[U, V] = { val m: Array[U] = null if (m.isEmpty) { - Pair(u, v) + (u, v) } else { - Pair(u, v2) + (u, v2) } } }
\ No newline at end of file diff --git a/test/files/pos/spec-doubledef-old.scala b/test/files/pos/spec-doubledef-old.scala index 86b0d857d3..bde259e4fa 100644 --- a/test/files/pos/spec-doubledef-old.scala +++ b/test/files/pos/spec-doubledef-old.scala @@ -17,12 +17,12 @@ abstract class B[T, @specialized(scala.Int) U : Manifest, @specialized(scala.Int val u: U val v: V - def f(t: T, v2: V): Pair[U, V] = { + def f(t: T, v2: V): Tuple2[U, V] = { val m: Array[U] = null if (m.isEmpty) { - Pair(u, v) + (u, v) } else { - Pair(u, v2) + (u, v2) } } } diff --git a/test/files/pos/t0064.scala b/test/files/pos/t0064.scala index c2ce4bf6d0..1eeca8dcad 100644 --- a/test/files/pos/t0064.scala +++ b/test/files/pos/t0064.scala @@ -1,6 +1,6 @@ object B { def main(Args:Array[String]) = { - val Pair(_,x) = Pair(1,2); + val (_,x) = (1,2); x + 1; } } diff --git a/test/files/pos/t1014.scala b/test/files/pos/t1014.scala new file mode 100644 index 0000000000..6fb7f7ba49 --- /dev/null +++ b/test/files/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/test/files/pos/t1203a.scala b/test/files/pos/t1203a.scala new file mode 100644 index 0000000000..cf5ab9fba0 --- /dev/null +++ b/test/files/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/test/files/pos/t247.scala b/test/files/pos/t247.scala index e976404e61..fdcafeb2c6 100644 --- a/test/files/pos/t247.scala +++ b/test/files/pos/t247.scala @@ -16,11 +16,11 @@ class Tree[KEY,Entry](order:Order[KEY]) { def size =0; } -class TreeMap[KEY,VALUE](_factory:TreeMapFactory[KEY]) extends Tree[KEY,Pair[KEY,VALUE]](_factory.order) with scala.collection.DefaultMap[KEY, VALUE] with Map[KEY, VALUE] { +class TreeMap[KEY,VALUE](_factory:TreeMapFactory[KEY]) extends Tree[KEY,Tuple2[KEY,VALUE]](_factory.order) with scala.collection.DefaultMap[KEY, VALUE] with Map[KEY, VALUE] { val factory = _factory val order = _factory.order; def this(newOrder:Order[KEY]) = this(new TreeMapFactory[KEY](newOrder)); def get(key:KEY) = null; - def iterator:Iterator[Pair[KEY,VALUE]] = null; + def iterator:Iterator[Tuple2[KEY,VALUE]] = null; override def size = super[Tree].size } diff --git a/test/files/pos/t2698.scala b/test/files/pos/t2698.scala new file mode 100644 index 0000000000..bce02e48b3 --- /dev/null +++ b/test/files/pos/t2698.scala @@ -0,0 +1,14 @@ +class WordExp { + abstract class Label + type _labelT <: Label +} + +import scala.collection._ + +abstract class S2 { + val lang: WordExp + type __labelT = lang._labelT + + var deltaq: Array[__labelT] = _ + def delta1 = immutable.Map(deltaq.zipWithIndex: _*) +} diff --git a/test/files/pos/t3160.scala b/test/files/pos/t3160.scala new file mode 100644 index 0000000000..cc007dc014 --- /dev/null +++ b/test/files/pos/t3160.scala @@ -0,0 +1,6 @@ +import scala.collection.mutable._ +class Node + +class A { + def f(x: Node): Node = ??? +} diff --git a/test/files/pos/t443.scala b/test/files/pos/t443.scala index 5b5e3ea828..cdaefe9ecd 100644 --- a/test/files/pos/t443.scala +++ b/test/files/pos/t443.scala @@ -1,10 +1,10 @@ object Test { - def lookup(): Option[Pair[String, String]] = - ((null: Option[Pair[String, String]]) : @unchecked) match { - case Some(Pair(_, _)) => + def lookup(): Option[Tuple2[String, String]] = + ((null: Option[Tuple2[String, String]]) : @unchecked) match { + case Some((_, _)) => if (true) - Some(Pair(null, null)) + Some((null, null)) else lookup() match { case Some(_) => Some(null) diff --git a/test/files/pos/t4579.scala b/test/files/pos/t4579.scala index 8951ec011f..cd1553f02a 100644 --- a/test/files/pos/t4579.scala +++ b/test/files/pos/t4579.scala @@ -190,10 +190,10 @@ object LispCaseClasses extends Lisp { def extendEnv(env: Environment, ps: List[String], args: List[Data]): Environment = - Pair(ps, args) match { - case Pair(List(), List()) => + (ps, args) match { + case (List(), List()) => env - case Pair(p :: ps1, arg :: args1) => + case (p :: ps1, arg :: args1) => extendEnv(env.extend(p, arg), ps1, args1) case _ => lispError("wrong number of arguments") @@ -381,10 +381,10 @@ object LispAny extends Lisp { def extendEnv(env: Environment, ps: List[String], args: List[Data]): Environment = - Pair(ps, args) match { - case Pair(List(), List()) => + (ps, args) match { + case (List(), List()) => env - case Pair(p :: ps1, arg :: args1) => + case (p :: ps1, arg :: args1) => extendEnv(env.extend(p, arg), ps1, args1) case _ => lispError("wrong number of arguments") diff --git a/test/files/pos/t5120.scala b/test/files/pos/t5120.scala index 6731af14e4..86d4470bd5 100644 --- a/test/files/pos/t5120.scala +++ b/test/files/pos/t5120.scala @@ -5,9 +5,9 @@ class Test { class ScopedKey[T] class Value[T] - class Compiled[T](val settings: Seq[Pair[T]]) + class Compiled[T](val settings: Seq[Tuple2[T]]) - case class Pair[T](k: ScopedKey[T], v: ScopedKey[T]) + case class Tuple2[T](k: ScopedKey[T], v: ScopedKey[T]) def transform[T](x: T) = x diff --git a/test/files/pos/t6201.scala b/test/files/pos/t6201.scala new file mode 100644 index 0000000000..d4e5bce03a --- /dev/null +++ b/test/files/pos/t6201.scala @@ -0,0 +1,19 @@ +// probably needs xml's weirdness to reproduce +// (specifically, _root_.scala.xml.Null being in the root package) +class Elem + +class Test { + def elem: Elem = ??? + + class Foo1 { + def must(x: Elem) = () + } + + class Foo2 { + def must(x: Int) = () + } + implicit def toFoo1(s: Elem) = new Foo1() + implicit def toFoo2(s: Elem) = new Foo2() + + def is: Unit = { (elem) } +}
\ No newline at end of file diff --git a/test/files/pos/t7983.scala b/test/files/pos/t7983.scala new file mode 100644 index 0000000000..a583e538c5 --- /dev/null +++ b/test/files/pos/t7983.scala @@ -0,0 +1,31 @@ +package foo.bar.baz // the package nesting level material to this bug + +class DivergenceTest { + + trait ColumnBase[T] + + trait ShapeLevel + trait Flat extends ShapeLevel + trait Lower extends Flat + + class Shape2[Level <: ShapeLevel, -M, U] + + implicit final def columnBaseShape[Level >: Flat <: ShapeLevel, T, C <: ColumnBase[_]] + (implicit ev: C <:< ColumnBase[T] + ): Shape2[Level, C, T] = ??? + + implicit final def intShape[Level <: ShapeLevel, T]: Shape2[Level, Int, Int] = ??? + implicit final def tuple2Shape[Level <: ShapeLevel, M1,M2, U1,U2] + (implicit u1: Shape2[_ <: Level, M1, U1], + u2: Shape2[_ <: Level, M2, U2] + ): Shape2[Level, (M1,M2), (U1,U2)] = ??? + + def foo { + class Coffees extends ColumnBase[Int] + + def map1[F, T](f: F)(implicit shape: Shape2[_ <: Flat, F, T]) = ??? + + map1(((1, null: Coffees), 1)) + map1(((null: Coffees, 1), 1)) // fails with implicit divergence error in 2.11.0-M6, works under 2.10.3 + } +} diff --git a/test/files/pos/t7987/Macro_1.scala b/test/files/pos/t7987/Macro_1.scala new file mode 100644 index 0000000000..81f717b9c4 --- /dev/null +++ b/test/files/pos/t7987/Macro_1.scala @@ -0,0 +1,6 @@ +import scala.language.experimental._ + +object Macro { + def apply[A](a: A): A = macro impl[A] + def impl[A](c: reflect.macros.Context)(a: c.Expr[A]): c.Expr[A] = a +} diff --git a/test/files/pos/t7987/Test_2.scala b/test/files/pos/t7987/Test_2.scala new file mode 100644 index 0000000000..5896fdb517 --- /dev/null +++ b/test/files/pos/t7987/Test_2.scala @@ -0,0 +1,12 @@ +class C[T] { + def foo = 0 +} + +object Test { + implicit def AnyToC[T](a: Any): C[T] = new C[T] + // was: "macro not expanded" + Macro { + "".foo + () + } +} diff --git a/test/files/pos/tcpoly_bounds1.scala b/test/files/pos/tcpoly_bounds1.scala index 5874cc664d..63263cb152 100644 --- a/test/files/pos/tcpoly_bounds1.scala +++ b/test/files/pos/tcpoly_bounds1.scala @@ -1,7 +1,7 @@ -class Foo[t[x]<: Pair[Int, x]] +class Foo[t[x]<: Tuple2[Int, x]] // -class MyPair[z](a: Int, b: z) extends Pair[Int, z](a,b) +class MyPair[z](a: Int, b: z) extends Tuple2[Int, z](a,b) object foo extends Foo[MyPair] diff --git a/test/files/pos/typealiases.scala b/test/files/pos/typealiases.scala index d03b521f77..93d1dce4dc 100644 --- a/test/files/pos/typealiases.scala +++ b/test/files/pos/typealiases.scala @@ -14,7 +14,7 @@ trait Test[T] { object main extends Test[Int] { val pair1 = (1,1) - implicit def topair(x: Int): Pair[Int, Int] = (x,x) + implicit def topair(x: Int): Tuple2[Int, Int] = (x,x) val pair2: MyPair[Int] = 1 val x: Short = 1 } diff --git a/test/files/pos/unapplyNeedsMemberType.scala b/test/files/pos/unapplyNeedsMemberType.scala index b423257e04..3a96e189af 100644 --- a/test/files/pos/unapplyNeedsMemberType.scala +++ b/test/files/pos/unapplyNeedsMemberType.scala @@ -19,7 +19,7 @@ class Join[a] extends Gunk[a] { def append(s1: Seq, s2: Seq): Seq = s1 // mock implementation def unapply_Cons(s: Any) = s match { - case App(Cons(x, xs), ys) => Some(Pair(x, append(xs, ys))) + case App(Cons(x, xs), ys) => Some((x, append(xs, ys))) case _ => null } } diff --git a/test/files/pos/valdefs.scala b/test/files/pos/valdefs.scala index 85ffa132b7..c8f78cd2bf 100644 --- a/test/files/pos/valdefs.scala +++ b/test/files/pos/valdefs.scala @@ -11,6 +11,6 @@ object test { } abstract class Sub2() extends Base() { - override val Pair(x, y) = Pair("abc", 2.0); + override val (x, y) = ("abc", 2.0); } } diff --git a/test/files/positions/ExcludedPrefix1.scala b/test/files/positions/ExcludedPrefix1.scala index f3562c37f0..b3182eae78 100644 --- a/test/files/positions/ExcludedPrefix1.scala +++ b/test/files/positions/ExcludedPrefix1.scala @@ -35,7 +35,7 @@ object ExcludedPrefix1 { (i, j) = (0, 0) - val Pair( + val ( k, l) = (0, 0) } diff --git a/test/files/positions/Overlap4.scala b/test/files/positions/Overlap4.scala index 0049293954..f54837295b 100644 --- a/test/files/positions/Overlap4.scala +++ b/test/files/positions/Overlap4.scala @@ -1,3 +1,3 @@ object Overlap4 { - val Pair(a, b) = (0, 0) + val (a, b) = (0, 0) } diff --git a/test/files/positions/Scaladoc7.scala b/test/files/positions/Scaladoc7.scala index 6175222e3f..0198d4d6ac 100644 --- a/test/files/positions/Scaladoc7.scala +++ b/test/files/positions/Scaladoc7.scala @@ -2,5 +2,5 @@ object Scaladoc7 { /** * Foo */ - val Pair(i, j) = (1, 2) + val (i, j) = (1, 2) } diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index d41b982614..1f868097ca 100644 --- a/test/files/presentation/callcc-interpreter.check +++ b/test/files/presentation/callcc-interpreter.check @@ -1,8 +1,8 @@ reload: CallccInterpreter.scala -askTypeCompletion at CallccInterpreter.scala(51,38) +askTypeCompletion at CallccInterpreter.scala(51,34) ================================================================================ -[response] askCompletionAt (51,38) +[response] askTypeCompletion at (51,34) retrieved 59 members abstract trait Term extends AnyRef abstract trait Value extends AnyRef @@ -83,8 +83,8 @@ def showM(m: callccInterpreter.M[callccInterpreter.Value]): String = m.in.apply( askType at CallccInterpreter.scala(50,30) ================================================================================ [response] askTypeAt (50,30) -def add(a: callccInterpreter.Value, b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value] = scala.this.Predef.Pair.apply[callccInterpreter.Value, callccInterpreter.Value](a, b) match { - case scala.this.Predef.Pair.unapply[callccInterpreter.Value, callccInterpreter.Value](<unapply-selector>) <unapply> ((n: Int)callccInterpreter.Num((m @ _)), (n: Int)callccInterpreter.Num((n @ _))) => this.unitM[callccInterpreter.Num](callccInterpreter.this.Num.apply(m.+(n))) +def add(a: callccInterpreter.Value, b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value] = scala.Tuple2.apply[callccInterpreter.Value, callccInterpreter.Value](a, b) match { + case (_1: callccInterpreter.Value, _2: callccInterpreter.Value)(callccInterpreter.Value, callccInterpreter.Value)((n: Int)callccInterpreter.Num((m @ _)), (n: Int)callccInterpreter.Num((n @ _))) => this.unitM[callccInterpreter.Num](callccInterpreter.this.Num.apply(m.+(n))) case _ => callccInterpreter.this.unitM[callccInterpreter.Wrong.type](callccInterpreter.this.Wrong) } ================================================================================ diff --git a/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala b/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala index ce3b996b96..d498fe0b17 100644 --- a/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala +++ b/test/files/presentation/callcc-interpreter/src/CallccInterpreter.scala @@ -40,15 +40,15 @@ object callccInterpreter { override def toString() = "<function>" } - type Environment = List[Pair[Name, Value]] + type Environment = List[Tuple2[Name, Value]] def lookup(x: Name, e: Environment): M[Value] = e match { case List() => unitM(Wrong) - case Pair(y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1) + case (y, b) :: e1 => if (x == y) unitM(b) else lookup(x, e1) } - def add(a: Value, b: Value) /*?*/ = Pair(a, b) match { - case Pair(Num(m), Num(n)) => this./*!*/unitM(Num(m + n)) + def add(a: Value, b: Value) /*?*/ = (a, b) match { + case (Num(m), Num(n)) => this./*!*/unitM(Num(m + n)) case _ => unitM(Wrong) } @@ -60,16 +60,20 @@ object callccInterpreter { def interp(t: Term, e: Environment): M[Value] = t match { case Var(x) => lookup(x, e) case Con(n) => unitM(Num(n)) - case Add(l, r) => for (val a <- interp(l, e); - val b <- interp(r, e); - val c <- add(a, b)) - yield c - case Lam(x, t) => unitM(Fun(a => interp(t, Pair(x, a) :: e))) - case App(f, t) => for (val a <- interp(f, e); - val b <- interp(t, e); - val c <- apply(a, b)) - yield c - case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e)) + case Add(l, r) => + for { + a <- interp(l, e) + b <- interp(r, e) + c <- add(a, b) + } yield c + case Lam(x, t) => unitM(Fun(a => interp(t, (x, a) :: e))) + case App(f, t) => + for { + a <- interp(f, e) + b <- interp(t, e) + c <- apply(a, b) + } yield c + case Ccc(x, t) => callCC(k => interp(t, (x, Fun(k)) :: e)) } def test(t: Term): String = showM(interp(t, List())) diff --git a/test/files/presentation/completion-implicit-chained.check b/test/files/presentation/completion-implicit-chained.check index b34e6bc7e1..f9d77f7a53 100644 --- a/test/files/presentation/completion-implicit-chained.check +++ b/test/files/presentation/completion-implicit-chained.check @@ -2,7 +2,7 @@ reload: Completions.scala askTypeCompletion at Completions.scala(11,16) ================================================================================ -[response] askCompletionAt (11,16) +[response] askTypeCompletion at (11,16) retrieved 24 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check index aa6660cec5..c59fa6843f 100644 --- a/test/files/presentation/ide-bug-1000349.check +++ b/test/files/presentation/ide-bug-1000349.check @@ -2,7 +2,7 @@ reload: CompletionOnEmptyArgMethod.scala askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17) ================================================================================ -[response] askCompletionAt (2,17) +[response] askTypeCompletion at (2,17) retrieved 32 members def +(other: String): String def ->[B](y: B): (Foo, B) diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check index cb7de6d34a..f5b4253e1a 100644 --- a/test/files/presentation/ide-bug-1000475.check +++ b/test/files/presentation/ide-bug-1000475.check @@ -2,7 +2,7 @@ reload: Foo.scala askTypeCompletion at Foo.scala(3,7) ================================================================================ -[response] askCompletionAt (3,7) +[response] askTypeCompletion at (3,7) retrieved 31 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit @@ -36,7 +36,7 @@ final def wait(x$1: Long,x$2: Int): Unit askTypeCompletion at Foo.scala(6,10) ================================================================================ -[response] askCompletionAt (6,10) +[response] askTypeCompletion at (6,10) retrieved 31 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit @@ -70,7 +70,7 @@ final def wait(x$1: Long,x$2: Int): Unit askTypeCompletion at Foo.scala(7,7) ================================================================================ -[response] askCompletionAt (7,7) +[response] askTypeCompletion at (7,7) retrieved 31 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index 9a2cad5fd2..dff89b155b 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -2,7 +2,7 @@ reload: CrashOnLoad.scala askTypeCompletion at CrashOnLoad.scala(6,12) ================================================================================ -[response] askCompletionAt (6,12) +[response] askTypeCompletion at (6,12) retrieved 120 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check index ef361599c5..5ad52b4dd3 100644 --- a/test/files/presentation/implicit-member.check +++ b/test/files/presentation/implicit-member.check @@ -2,7 +2,7 @@ reload: ImplicitMember.scala askTypeCompletion at ImplicitMember.scala(7,7) ================================================================================ -[response] askCompletionAt (7,7) +[response] askTypeCompletion at (7,7) retrieved 34 members def +(other: String): String def ->[B](y: B): (Implicit.type, B) diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check index 10d29bfed6..20f17aa7d0 100644 --- a/test/files/presentation/ping-pong.check +++ b/test/files/presentation/ping-pong.check @@ -2,7 +2,7 @@ reload: PingPong.scala askTypeCompletion at PingPong.scala(10,23) ================================================================================ -[response] askCompletionAt (10,23) +[response] askTypeCompletion at (10,23) retrieved 35 members [inaccessible] private[this] val ping: Ping [inaccessible] protected[package lang] def clone(): Object @@ -39,7 +39,7 @@ private[this] val name: String askTypeCompletion at PingPong.scala(19,20) ================================================================================ -[response] askCompletionAt (19,20) +[response] askTypeCompletion at (19,20) retrieved 35 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit diff --git a/test/files/presentation/scope-completion-1.check b/test/files/presentation/scope-completion-1.check new file mode 100644 index 0000000000..63f956b239 --- /dev/null +++ b/test/files/presentation/scope-completion-1.check @@ -0,0 +1,19 @@ +reload: Completions.scala + +askScopeCompletion at Completions.scala(6,2) +================================================================================ +[response] askScopeCompletion at (6,2) +retrieved 3 members +class Completion1 extends AnyRef +def <init>(): test.Completion1 +object Completion2 +================================================================================ + +askScopeCompletion at Completions.scala(10,2) +================================================================================ +[response] askScopeCompletion at (10,2) +retrieved 3 members +class Completion1 extends AnyRef +def <init>(): test.Completion2.type +object Completion2 +================================================================================ diff --git a/test/files/presentation/scope-completion-1/Test.scala b/test/files/presentation/scope-completion-1/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/scope-completion-1/Test.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest
\ No newline at end of file diff --git a/test/files/presentation/scope-completion-1/src/Completions.scala b/test/files/presentation/scope-completion-1/src/Completions.scala new file mode 100644 index 0000000000..c4eea6b261 --- /dev/null +++ b/test/files/presentation/scope-completion-1/src/Completions.scala @@ -0,0 +1,12 @@ +package test + +/* completion on empty class and object */ + +class Completion1 { + /*_*/ +} + +object Completion2 { + /*_*/ +} + diff --git a/test/files/presentation/scope-completion-2.check b/test/files/presentation/scope-completion-2.check new file mode 100644 index 0000000000..3a1dbd7cff --- /dev/null +++ b/test/files/presentation/scope-completion-2.check @@ -0,0 +1,35 @@ +reload: Completions.scala + +askScopeCompletion at Completions.scala(16,4) +================================================================================ +[response] askScopeCompletion at (16,4) +retrieved 11 members +class Completion1 extends AnyRef +def <init>(): test.Completion1 +def test: Unit +object Completion1 +private class Cc1 extends AnyRef +private class Co1 extends AnyRef +private def fc1: Int +private def fo1: Int +private[this] val c: test.Completion1 +private[this] val vc1: Int +private[this] val vo1: Int +================================================================================ + +askScopeCompletion at Completions.scala(32,4) +================================================================================ +[response] askScopeCompletion at (32,4) +retrieved 11 members +[inaccessible] private[this] val vc1: Int +class Completion1 extends AnyRef +def <init>(): test.Completion1.type +def test: Unit +object Completion1 +private class Cc1 extends AnyRef +private class Co1 extends AnyRef +private def fc1: Int +private def fo1: Int +private[this] val c: test.Completion1 +private[this] val vo1: Int +================================================================================ diff --git a/test/files/presentation/scope-completion-2/Test.scala b/test/files/presentation/scope-completion-2/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/scope-completion-2/Test.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest
\ No newline at end of file diff --git a/test/files/presentation/scope-completion-2/src/Completions.scala b/test/files/presentation/scope-completion-2/src/Completions.scala new file mode 100644 index 0000000000..96d38f1b85 --- /dev/null +++ b/test/files/presentation/scope-completion-2/src/Completions.scala @@ -0,0 +1,35 @@ +package test + +/* private elements are visible in the companion class/object */ + +class Completion1 { + + import Completion1._ + + private val vc1 = 0 + private def fc1 = 0 + + private class Cc1 + + def test { + // needs to be done in a method, because of SI-7280 + /*_*/ + } +} + +object Completion1 { + + val c = new Completion1() + import c._ + + private val vo1 = 0 + private def fo1 = 0 + + private class Co1 + + def test { + // needs to be done in a method, because of SI-7280 + /*_*/ + } +} + diff --git a/test/files/presentation/scope-completion-3.check b/test/files/presentation/scope-completion-3.check new file mode 100644 index 0000000000..cf73e89a3b --- /dev/null +++ b/test/files/presentation/scope-completion-3.check @@ -0,0 +1,111 @@ +reload: Completions.scala + +askScopeCompletion at Completions.scala(75,2) +================================================================================ +[response] askScopeCompletion at (75,2) +retrieved 49 members +[inaccessible] private class Cb2 extends AnyRef +[inaccessible] private class Ct2 extends AnyRef +[inaccessible] private def fb2: Int +[inaccessible] private def ft2: Int +[inaccessible] private object Ob2 +[inaccessible] private object Ot2 +[inaccessible] private type tb2 = Completion1.this.tb2 +[inaccessible] private type tt2 = Completion1.this.tt2 +[inaccessible] private[this] val vb1: Int +[inaccessible] private[this] val vb2: Int +[inaccessible] private[this] val vt1: Int +[inaccessible] private[this] val vt2: Int +[inaccessible] private[this] var rb1: Int +[inaccessible] private[this] var rb2: Int +[inaccessible] private[this] var rt1: Int +[inaccessible] private[this] var rt2: Int +abstract class Base1 extends AnyRef +abstract trait Trait1 extends AnyRef +class Cb1 extends AnyRef +class Cc1 extends AnyRef +class Completion1 extends Base1 with Trait1 +class Ct1 extends AnyRef +def <init>(): test.Completion1 +def fb1: Int +def fc1: Int +def ft1: Int +object Completion2 +object Ob1 +object Oc1 +object Ot1 +override def fb3: Int +override def ft3: Int +override type tb3 = Completion1.this.tb3 +override type tt3 = Completion1.this.tt3 +private class Cc2 extends AnyRef +private def fc2: Int +private object Oc2 +private type tc2 = Completion1.this.tc2 +private[this] val vb3: Int +private[this] val vc1: Int +private[this] val vc2: Int +private[this] val vt3: Int +private[this] var rb3: Int +private[this] var rc1: Int +private[this] var rc2: Int +private[this] var rt3: Int +type tb1 = Completion1.this.tb1 +type tc1 = Completion1.this.tc1 +type tt1 = Completion1.this.tt1 +================================================================================ + +askScopeCompletion at Completions.scala(104,2) +================================================================================ +[response] askScopeCompletion at (104,2) +retrieved 49 members +[inaccessible] private class Cb2 extends AnyRef +[inaccessible] private class Ct2 extends AnyRef +[inaccessible] private def fb2: Int +[inaccessible] private def ft2: Int +[inaccessible] private object Ob2 +[inaccessible] private object Ot2 +[inaccessible] private type tb2 = test.Completion2.tb2 +[inaccessible] private type tt2 = test.Completion2.tt2 +[inaccessible] private[this] val vb1: Int +[inaccessible] private[this] val vb2: Int +[inaccessible] private[this] val vt1: Int +[inaccessible] private[this] val vt2: Int +[inaccessible] private[this] var rb1: Int +[inaccessible] private[this] var rb2: Int +[inaccessible] private[this] var rt1: Int +[inaccessible] private[this] var rt2: Int +abstract class Base1 extends AnyRef +abstract trait Trait1 extends AnyRef +class Cb1 extends AnyRef +class Co1 extends AnyRef +class Completion1 extends Base1 with Trait1 +class Ct1 extends AnyRef +def <init>(): test.Completion2.type +def fb1: Int +def fo1: Int +def ft1: Int +object Completion2 +object Ob1 +object Oo1 +object Ot1 +override def fb3: Int +override def ft3: Int +override type tb3 = test.Completion2.tb3 +override type tt3 = test.Completion2.tt3 +private class Co2 extends AnyRef +private def fo2: Int +private object Oo2 +private type to2 = test.Completion2.to2 +private[this] val vb3: Int +private[this] val vo1: Int +private[this] val vo2: Int +private[this] val vt3: Int +private[this] var rb3: Int +private[this] var ro1: Int +private[this] var ro2: Int +private[this] var rt3: Int +type tb1 = test.Completion2.tb1 +type to1 = test.Completion2.to1 +type tt1 = test.Completion2.tt1 +================================================================================ diff --git a/test/files/presentation/scope-completion-3/Test.scala b/test/files/presentation/scope-completion-3/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/scope-completion-3/Test.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest
\ No newline at end of file diff --git a/test/files/presentation/scope-completion-3/src/Completions.scala b/test/files/presentation/scope-completion-3/src/Completions.scala new file mode 100644 index 0000000000..18cef1cefa --- /dev/null +++ b/test/files/presentation/scope-completion-3/src/Completions.scala @@ -0,0 +1,106 @@ +package test + +/* check availability of members defined locally and in hierachy */ + +abstract class Base1 { + + type tb1 = Int + val vb1 = 0 + var rb1 = 0 + def fb1 = 0 + class Cb1 + object Ob1 + + private type tb2 = Int + private val vb2 = 0 + private var rb2 = 0 + private def fb2 = 0 + private class Cb2 + private object Ob2 + + type tb3 + val vb3: Int + var rb3: Int + def fb3: Int +} + +trait Trait1 { + + type tt1 = Int + val vt1 = 0 + var rt1 = 0 + def ft1 = 0 + class Ct1 + object Ot1 + + private type tt2 = Int + private val vt2 = 0 + private var rt2 = 0 + private def ft2 = 0 + private class Ct2 + private object Ot2 + + type tt3 + val vt3: Int + var rt3: Int + def ft3: Int +} + +class Completion1 extends Base1 with Trait1 { + + type tc1 = Int + val vc1 = 0 + var rc1 = 0 + def fc1 = 0 + class Cc1 + object Oc1 + + private type tc2 = Int + private val vc2 = 0 + private var rc2 = 0 + private def fc2 = 0 + private class Cc2 + private object Oc2 + + override type tb3 = Int + override val vb3 = 12 + override var rb3 = 12 + override def fb3 = 12 + + override type tt3 = Int + override val vt3 = 12 + override var rt3 = 12 + override def ft3 = 12 + + /*_*/ +} + +object Completion2 extends Base1 with Trait1 { + + type to1 = Int + val vo1 = 0 + var ro1 = 0 + def fo1 = 0 + class Co1 + object Oo1 + + private type to2 = Int + private val vo2 = 0 + private var ro2 = 0 + private def fo2 = 0 + private class Co2 + private object Oo2 + + override type tb3 = Int + override val vb3 = 12 + override var rb3 = 12 + override def fb3 = 12 + + override type tt3 = Int + override val vt3 = 12 + override var rt3 = 12 + override def ft3 = 12 + + /*_*/ +} + diff --git a/test/files/presentation/scope-completion-4.check b/test/files/presentation/scope-completion-4.check new file mode 100644 index 0000000000..59c47464c4 --- /dev/null +++ b/test/files/presentation/scope-completion-4.check @@ -0,0 +1,293 @@ +reload: Completions.scala + +askScopeCompletion at Completions.scala(12,8) +================================================================================ +[response] askScopeCompletion at (12,8) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +class ffc extends AnyRef +def <init>(): test.Completion1 +def f: Unit +def ff: Unit +def fff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(15,6) +================================================================================ +[response] askScopeCompletion at (15,6) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +class ffc extends AnyRef +def <init>(): test.Completion1 +def f: Unit +def ff: Unit +def fff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(18,8) +================================================================================ +[response] askScopeCompletion at (18,8) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +class ffc extends AnyRef +def <init>(): ffc +def f: Unit +def ff: Unit +def fff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(21,6) +================================================================================ +[response] askScopeCompletion at (21,6) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +class ffc extends AnyRef +def <init>(): test.Completion1 +def f: Unit +def ff: Unit +def fff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(24,4) +================================================================================ +[response] askScopeCompletion at (24,4) +retrieved 6 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +def <init>(): test.Completion1 +def f: Unit +def ff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(29,8) +================================================================================ +[response] askScopeCompletion at (29,8) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +class fcc extends AnyRef +def <init>(): fc +def f: Unit +def fcf: Unit +def ff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(32,6) +================================================================================ +[response] askScopeCompletion at (32,6) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +class fcc extends AnyRef +def <init>(): fc +def f: Unit +def fcf: Unit +def ff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(35,8) +================================================================================ +[response] askScopeCompletion at (35,8) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +class fcc extends AnyRef +def <init>(): fc.this.fcc +def f: Unit +def fcf: Unit +def ff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(38,6) +================================================================================ +[response] askScopeCompletion at (38,6) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +class fcc extends AnyRef +def <init>(): fc +def f: Unit +def fcf: Unit +def ff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(41,4) +================================================================================ +[response] askScopeCompletion at (41,4) +retrieved 6 members +class Completion1 extends AnyRef +class c extends AnyRef +class fc extends AnyRef +def <init>(): test.Completion1 +def f: Unit +def ff: Unit +================================================================================ + +askScopeCompletion at Completions.scala(44,2) +================================================================================ +[response] askScopeCompletion at (44,2) +retrieved 4 members +class Completion1 extends AnyRef +class c extends AnyRef +def <init>(): test.Completion1 +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(51,8) +================================================================================ +[response] askScopeCompletion at (51,8) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +class ccc extends AnyRef +def <init>(): cc.this.ccc +def ccf: Unit +def cf: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(54,6) +================================================================================ +[response] askScopeCompletion at (54,6) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +class ccc extends AnyRef +def <init>(): c.this.cc +def ccf: Unit +def cf: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(57,8) +================================================================================ +[response] askScopeCompletion at (57,8) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +class ccc extends AnyRef +def <init>(): c.this.cc +def ccf: Unit +def cf: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(60,6) +================================================================================ +[response] askScopeCompletion at (60,6) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +class ccc extends AnyRef +def <init>(): c.this.cc +def ccf: Unit +def cf: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(63,4) +================================================================================ +[response] askScopeCompletion at (63,4) +retrieved 6 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +def <init>(): Completion1.this.c +def cf: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(68,8) +================================================================================ +[response] askScopeCompletion at (68,8) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +class cfc extends AnyRef +def <init>(): cfc +def cf: Unit +def cff: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(71,6) +================================================================================ +[response] askScopeCompletion at (71,6) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +class cfc extends AnyRef +def <init>(): Completion1.this.c +def cf: Unit +def cff: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(74,8) +================================================================================ +[response] askScopeCompletion at (74,8) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +class cfc extends AnyRef +def <init>(): Completion1.this.c +def cf: Unit +def cff: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(77,6) +================================================================================ +[response] askScopeCompletion at (77,6) +retrieved 8 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +class cfc extends AnyRef +def <init>(): Completion1.this.c +def cf: Unit +def cff: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(80,4) +================================================================================ +[response] askScopeCompletion at (80,4) +retrieved 6 members +class Completion1 extends AnyRef +class c extends AnyRef +class cc extends AnyRef +def <init>(): Completion1.this.c +def cf: Unit +def f: Unit +================================================================================ + +askScopeCompletion at Completions.scala(83,2) +================================================================================ +[response] askScopeCompletion at (83,2) +retrieved 4 members +class Completion1 extends AnyRef +class c extends AnyRef +def <init>(): test.Completion1 +def f: Unit +================================================================================ diff --git a/test/files/presentation/scope-completion-4/Test.scala b/test/files/presentation/scope-completion-4/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/scope-completion-4/Test.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest
\ No newline at end of file diff --git a/test/files/presentation/scope-completion-4/src/Completions.scala b/test/files/presentation/scope-completion-4/src/Completions.scala new file mode 100644 index 0000000000..d11315720a --- /dev/null +++ b/test/files/presentation/scope-completion-4/src/Completions.scala @@ -0,0 +1,84 @@ +package test + +/* check that members defined in sub-block are not visible*/ + +class Completion1 { + + def f { + + def ff { + + def fff { + /*_*/ + } + + /*_*/ + + class ffc { + /*_*/ + } + + /*_*/ + } + + /*_*/ + + class fc { + + def fcf { + /*_*/ + } + + /*_*/ + + class fcc { + /*_*/ + } + + /*_*/ + } + + /*_*/ + } + + /*_*/ + + class c { + + class cc { + + class ccc { + /*_*/ + } + + /*_*/ + + def ccf { + /*_*/ + } + + /*_*/ + } + + /*_*/ + + def cf { + + class cfc { + /*_*/ + } + + /*_*/ + + def cff { + /*_*/ + } + + /*_*/ + } + + /*_*/ + } + + /*_*/ +} diff --git a/test/files/presentation/scope-completion-import.check b/test/files/presentation/scope-completion-import.check new file mode 100644 index 0000000000..d518b0c37a --- /dev/null +++ b/test/files/presentation/scope-completion-import.check @@ -0,0 +1,141 @@ +reload: Completions.scala + +askScopeCompletion at Completions.scala(15,4) +================================================================================ +[response] askScopeCompletion at (15,4) +retrieved 10 members +class C extends AnyRef +class Foo extends AnyRef +class Foo_1 extends AnyRef +class Foo_2 extends AnyRef +class Foo_3 extends AnyRef +def <init>(): test.Foo +def fCCC: Int +def fOOO: Int +object O +val o: test.O.type +================================================================================ + +askScopeCompletion at Completions.scala(19,4) +================================================================================ +[response] askScopeCompletion at (19,4) +retrieved 9 members +class C extends AnyRef +class Foo extends AnyRef +class Foo_1 extends AnyRef +class Foo_2 extends AnyRef +class Foo_3 extends AnyRef +def <init>(): test.Foo +def fCCC: Int +def fOOO: Int +object O +================================================================================ + +askScopeCompletion at Completions.scala(24,4) +================================================================================ +[response] askScopeCompletion at (24,4) +retrieved 9 members +class C extends AnyRef +class Foo extends AnyRef +class Foo_1 extends AnyRef +class Foo_2 extends AnyRef +class Foo_3 extends AnyRef +def <init>(): test.Foo +def fCCC: Int +object O +val c: test.C +================================================================================ + +askScopeCompletion at Completions.scala(27,5) +================================================================================ +[response] askScopeCompletion at (27,5) +retrieved 8 members +class C extends AnyRef +class Foo extends AnyRef +class Foo_1 extends AnyRef +class Foo_2 extends AnyRef +class Foo_3 extends AnyRef +def <init>(): test.Foo +object O +val c: test.C +================================================================================ + +askScopeCompletion at Completions.scala(30,5) +================================================================================ +[response] askScopeCompletion at (30,5) +retrieved 9 members +class C extends AnyRef +class Foo extends AnyRef +class Foo_1 extends AnyRef +class Foo_2 extends AnyRef +class Foo_3 extends AnyRef +def <init>(): test.Foo +def fCCC: Int +object O +val c: test.C +================================================================================ + +askScopeCompletion at Completions.scala(32,5) +================================================================================ +[response] askScopeCompletion at (32,5) +retrieved 10 members +class C extends AnyRef +class Foo extends AnyRef +class Foo_1 extends AnyRef +class Foo_2 extends AnyRef +class Foo_3 extends AnyRef +def <init>(): test.Foo +def fCCC: Int +def fOOO: Int +object O +val c: test.C +================================================================================ + +askScopeCompletion at Completions.scala(41,4) +================================================================================ +[response] askScopeCompletion at (41,4) +retrieved 10 members +class C extends AnyRef +class Foo extends AnyRef +class Foo_1 extends AnyRef +class Foo_2 extends AnyRef +class Foo_3 extends AnyRef +def <init>(): test.Foo_1 +def bar: Unit +def fCCC: Int +def fOOO: Int +object O +================================================================================ + +askScopeCompletion at Completions.scala(51,4) +================================================================================ +[response] askScopeCompletion at (51,4) +retrieved 11 members +class C extends AnyRef +class Foo extends AnyRef +class Foo_1 extends AnyRef +class Foo_2 extends AnyRef +class Foo_3 extends AnyRef +def <init>(): test.Foo_2 +def bar: Unit +def fCCC: Int +def fOOO: Int +object O +private[this] val o: test.O.type +================================================================================ + +askScopeCompletion at Completions.scala(61,4) +================================================================================ +[response] askScopeCompletion at (61,4) +retrieved 10 members +class C extends AnyRef +class Foo extends AnyRef +class Foo_1 extends AnyRef +class Foo_2 extends AnyRef +class Foo_3 extends AnyRef +def <init>(): test.Foo_3 +def bar: Unit +def fCCC: Int +object O +private[this] val c: test.C +================================================================================ diff --git a/test/files/presentation/scope-completion-import/Test.scala b/test/files/presentation/scope-completion-import/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/scope-completion-import/Test.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest
\ No newline at end of file diff --git a/test/files/presentation/scope-completion-import/src/Completions.scala b/test/files/presentation/scope-completion-import/src/Completions.scala new file mode 100644 index 0000000000..6e08321283 --- /dev/null +++ b/test/files/presentation/scope-completion-import/src/Completions.scala @@ -0,0 +1,64 @@ +package test + +class C { + def fCCC : Int = 0 +} + +object O extends C { + def fOOO : Int = 0 +} + +class Foo { + { + val o = O + import o._ + /*_*/ + } + { + import O._ + /*_*/ + } + { + val c = new C + import c._ + /*_*/ + } + { + f/*_*/ + val c = new C + import c._ + f/*_*/ + import O._ + f/*_*/ + } +} + +class Foo_1 { + + import O._ + + def bar { + /*_*/ + } +} + +class Foo_2 { + + val o = O + import o._ + + def bar { + /*_*/ + } +} + +class Foo_3 { + + val c = new C + import c._ + + def bar { + /*_*/ + } +} + diff --git a/test/files/presentation/t1207.check b/test/files/presentation/t1207.check index 84bfd79d75..0eed4ece04 100644 --- a/test/files/presentation/t1207.check +++ b/test/files/presentation/t1207.check @@ -2,7 +2,7 @@ reload: Completions.scala askTypeCompletion at Completions.scala(10,15) ================================================================================ -[response] askCompletionAt (10,15) +[response] askTypeCompletion at (10,15) retrieved 3 members final package bongo final package lang @@ -11,7 +11,7 @@ final package util askTypeCompletion at Completions.scala(11,16) ================================================================================ -[response] askCompletionAt (11,16) +[response] askTypeCompletion at (11,16) retrieved 3 members final package bongo final package lang @@ -20,7 +20,7 @@ final package util askTypeCompletion at Completions.scala(12,19) ================================================================================ -[response] askCompletionAt (12,19) +[response] askTypeCompletion at (12,19) retrieved 3 members final package bongo final package lang @@ -29,7 +29,7 @@ final package util askTypeCompletion at Completions.scala(13,19) ================================================================================ -[response] askCompletionAt (13,19) +[response] askTypeCompletion at (13,19) retrieved 3 members final package bongo final package lang @@ -38,7 +38,7 @@ final package util askTypeCompletion at Completions.scala(14,23) ================================================================================ -[response] askCompletionAt (14,23) +[response] askTypeCompletion at (14,23) retrieved 3 members final package bongo final package lang @@ -47,7 +47,7 @@ final package util askTypeCompletion at Completions.scala(15,10) ================================================================================ -[response] askCompletionAt (15,10) +[response] askTypeCompletion at (15,10) retrieved 0 members ================================================================================ diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check index 5f17c0b762..04806b5867 100644 --- a/test/files/presentation/t5708.check +++ b/test/files/presentation/t5708.check @@ -2,7 +2,7 @@ reload: Completions.scala askTypeCompletion at Completions.scala(17,9) ================================================================================ -[response] askCompletionAt (17,9) +[response] askTypeCompletion at (17,9) retrieved 39 members [inaccessible] private def privateM: String [inaccessible] private[this] val privateV: String diff --git a/test/files/presentation/t7915.check b/test/files/presentation/t7915.check new file mode 100644 index 0000000000..b18b4ddb55 --- /dev/null +++ b/test/files/presentation/t7915.check @@ -0,0 +1,11 @@ +reload: Foo.scala + +askHyperlinkPos for `Bar` at (7,11) Foo.scala +================================================================================ +[response] found askHyperlinkPos for `Bar` at (1,7) Foo.scala +================================================================================ + +askHyperlinkPos for `bar` at (7,22) Foo.scala +================================================================================ +[response] found askHyperlinkPos for `bar` at (2,7) Foo.scala +================================================================================ diff --git a/test/files/presentation/t7915/Test.scala b/test/files/presentation/t7915/Test.scala new file mode 100644 index 0000000000..c2f89bdb17 --- /dev/null +++ b/test/files/presentation/t7915/Test.scala @@ -0,0 +1,8 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + override def runDefaultTests() { + sourceFiles foreach (src => askLoadedTyped(src).get) + super.runDefaultTests() + } +} diff --git a/test/files/presentation/t7915/src/Foo.scala b/test/files/presentation/t7915/src/Foo.scala new file mode 100644 index 0000000000..a4166ae5b4 --- /dev/null +++ b/test/files/presentation/t7915/src/Foo.scala @@ -0,0 +1,9 @@ +class Bar { + def bar(b: Int = 2) {} +} + +class Foo { + def foo() { + new Bar/*#*/().bar/*#*/() + } +} diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check index 078e0a2342..217da34b9c 100644 --- a/test/files/presentation/visibility.check +++ b/test/files/presentation/visibility.check @@ -2,7 +2,7 @@ reload: Completions.scala askTypeCompletion at Completions.scala(14,12) ================================================================================ -[response] askCompletionAt (14,12) +[response] askTypeCompletion at (14,12) retrieved 37 members [inaccessible] private[this] def secretPrivateThis(): Unit def +(other: String): String @@ -42,7 +42,7 @@ protected[package lang] def finalize(): Unit askTypeCompletion at Completions.scala(16,11) ================================================================================ -[response] askCompletionAt (16,11) +[response] askTypeCompletion at (16,11) retrieved 37 members def +(other: String): String def ->[B](y: B): (accessibility.Foo, B) @@ -82,7 +82,7 @@ protected[package lang] def finalize(): Unit askTypeCompletion at Completions.scala(22,11) ================================================================================ -[response] askCompletionAt (22,11) +[response] askTypeCompletion at (22,11) retrieved 37 members [inaccessible] private def secretPrivate(): Unit def +(other: String): String @@ -122,7 +122,7 @@ protected[package lang] def finalize(): Unit askTypeCompletion at Completions.scala(28,10) ================================================================================ -[response] askCompletionAt (28,10) +[response] askTypeCompletion at (28,10) retrieved 37 members [inaccessible] private def secretPrivate(): Unit [inaccessible] private[this] def secretPrivateThis(): Unit @@ -162,7 +162,7 @@ protected[package accessibility] def secretProtectedInPackage(): Unit askTypeCompletion at Completions.scala(37,8) ================================================================================ -[response] askCompletionAt (37,8) +[response] askTypeCompletion at (37,8) retrieved 37 members [inaccessible] private def secretPrivate(): Unit [inaccessible] private[this] def secretPrivateThis(): Unit diff --git a/test/files/run/Course-2002-05.scala b/test/files/run/Course-2002-05.scala index e6764b92c8..80317bc757 100644 --- a/test/files/run/Course-2002-05.scala +++ b/test/files/run/Course-2002-05.scala @@ -3,15 +3,15 @@ //############################################################################ object M0 { - def partition[a](xs: List[a], pred: a => Boolean): Pair[List[a], List[a]] = { + def partition[a](xs: List[a], pred: a => Boolean): Tuple2[List[a], List[a]] = { if (xs.isEmpty) - Pair(List(),List()) + (List(),List()) else { val tailPartition = partition(xs.tail, pred); if (pred(xs.head)) - Pair(xs.head :: tailPartition._1, tailPartition._2) + (xs.head :: tailPartition._1, tailPartition._2) else - Pair(tailPartition._1, xs.head :: tailPartition._2) + (tailPartition._1, xs.head :: tailPartition._2) } } @@ -49,9 +49,9 @@ object M0 { //############################################################################ object M1 { - def partition[a](xs: List[a], pred: a => Boolean): Pair[List[a], List[a]] = { - xs.foldRight[Pair[List[a], List[a]]](Pair(List(), List())) { - (x, p) => if (pred (x)) Pair(x :: p._1, p._2) else Pair(p._1, x :: p._2) + def partition[a](xs: List[a], pred: a => Boolean): Tuple2[List[a], List[a]] = { + xs.foldRight[Tuple2[List[a], List[a]]]((List(), List())) { + (x, p) => if (pred (x)) (x :: p._1, p._2) else (p._1, x :: p._2) } } @@ -136,7 +136,7 @@ object M3 { def adjoinRow(placement: Placement): List[Placement] = range(1, n) .filter (column => isSafe(column, placement)) - .map (column => Pair(row, column) :: placement); + .map (column => (row, column) :: placement); placeQueens(row - 1) flatMap adjoinRow } diff --git a/test/files/run/Course-2002-06.scala b/test/files/run/Course-2002-06.scala index e4fb86a966..908a934041 100644 --- a/test/files/run/Course-2002-06.scala +++ b/test/files/run/Course-2002-06.scala @@ -55,7 +55,7 @@ abstract class Graphics(_width: Double, _height: Double) { } /** Draw a list of segments on the picture.*/ - def drawSegments(frm: Frame)(segments: List[Pair[Vector, Vector]]): Unit = + def drawSegments(frm: Frame)(segments: List[Tuple2[Vector, Vector]]): Unit = if (segments.isEmpty) () else { drawSegment(frm)(segments.head._1, segments.head._2); diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala index 055ff74d81..2d9457653f 100644 --- a/test/files/run/Course-2002-07.scala +++ b/test/files/run/Course-2002-07.scala @@ -181,10 +181,10 @@ object M4 { object M5 { - def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = Pair(xs,ys) match { - case Pair(List(), _) => List() - case Pair(_, List()) => List() - case Pair(x :: xs1, y :: ys1) => Pair(x, y) :: zipFun(xs1, ys1) + def zipFun[a,b](xs:List[a], ys:List[b]):List[Tuple2[a,b]] = (xs,ys) match { + case (List(), _) => List() + case (_, List()) => List() + case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1) } def test_zipFun[a,b](xs: List[a], ys: List[b]) = { @@ -216,9 +216,9 @@ object M5 { object M6 { - def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = (Pair(xs,ys): @unchecked) match { - // !!! case Pair(List(), _), Pair(_, List()) => List() - case Pair(x :: xs1, y :: ys1) => Pair(x, y) :: zipFun(xs1, ys1) + def zipFun[a,b](xs:List[a], ys:List[b]):List[Tuple2[a,b]] = ((xs,ys): @unchecked) match { + // !!! case (List(), _), (_, List()) => List() + case (x :: xs1, y :: ys1) => (x, y) :: zipFun(xs1, ys1) } def test_zipFun[a,b](xs: List[a], ys: List[b]) = { @@ -374,9 +374,9 @@ object M9 { object MA { - def lookup[k,v](xs: List[Pair[k,v]], k: k): v = xs match { + def lookup[k,v](xs: List[Tuple2[k,v]], k: k): v = xs match { case List() => sys.error("no value for " + k) - case Pair(k1,v1) :: xs1 => if (k1 == k) v1 else lookup(xs1, k) + case (k1,v1) :: xs1 => if (k1 == k) v1 else lookup(xs1, k) } trait Expr { @@ -437,8 +437,8 @@ object MA { val g1 = g0 derive x; Console.println("g (x) = " + g0); Console.println("g'(x) = " + g1); - Console.println("g (3) = " + evalvars(List(Pair("x",3)))(g0)); - Console.println("g'(3) = " + evalvars(List(Pair("x",3)))(g1)); + Console.println("g (3) = " + evalvars(List(("x",3)))(g0)); + Console.println("g'(3) = " + evalvars(List(("x",3)))(g1)); Console.println; } @@ -453,26 +453,26 @@ object Utils { if (y == 1) x else if (y % 2 == 0) power0(x*x,y/2) else x*power0(x, y-1); def power(x: Int, y: Int): Int = (x,y) match { - case Pair(0,0) => sys.error("power(0,0)") - case Pair(0,_) => 0 - case Pair(1,_) => 1 - case Pair(_,0) => 1 - case Pair(_,1) => x - case Pair(_,2) => x*x - case Pair(_,_) => if (y < 0) 1/power0(x,y) else power0(x,y) + case (0,0) => sys.error("power(0,0)") + case (0,_) => 0 + case (1,_) => 1 + case (_,0) => 1 + case (_,1) => x + case (_,2) => x*x + case (_,_) => if (y < 0) 1/power0(x,y) else power0(x,y) } def lookup(entries: List[(String,Int)], key: String): Int = entries match { case List() => sys.error("no value for " + key) - case Pair(k,v) :: _ if (k == key) => v + case (k,v) :: _ if (k == key) => v case _ :: rest => lookup(rest, key) } def compare(xs: List[String], ys: List[String]): Int = (xs, ys) match { - case Pair(List(), List()) => 0 - case Pair(List(), _ ) => -1 - case Pair(_ , List()) => +1 - case Pair(x::xs , y::ys ) => { + case (List(), List()) => 0 + case (List(), _ ) => -1 + case (_ , List()) => +1 + case (x::xs , y::ys ) => { val diff = x.compareTo(y); if (diff != 0) diff else compare(xs,ys) } @@ -508,18 +508,18 @@ object MB { private def +< (that: Expr): Boolean = (this +<? that) < 0; private def +<= (that: Expr): Boolean = (this +<? that) <= 0; - private def +<? (that: Expr): Int = Pair(this,that) match { - case Pair(Add(_,_), _ ) => 0 - case Pair(_ , Add(_,_)) => 0 - case Pair(_ , _ ) => compare(this.vars,that.vars) + private def +<? (that: Expr): Int = (this,that) match { + case (Add(_,_), _ ) => 0 + case (_ , Add(_,_)) => 0 + case (_ , _ ) => compare(this.vars,that.vars) } - def + (that: Expr): Expr = if (that +<= this) Pair(this,that) match { - case Pair(_ , Lit(0) ) => this - case Pair(Lit(l) , Lit(r) ) => Lit(l + r) - case Pair(_ , Add(rl,rr)) => (this + rl) + rr - case Pair(Add(ll,lr), _ ) if (lr +<= that) => ll + (that + lr) - case Pair(_ , _ ) => { + def + (that: Expr): Expr = if (that +<= this) (this,that) match { + case (_ , Lit(0) ) => this + case (Lit(l) , Lit(r) ) => Lit(l + r) + case (_ , Add(rl,rr)) => (this + rl) + rr + case (Add(ll,lr), _ ) if (lr +<= that) => ll + (that + lr) + case (_ , _ ) => { val l = this.term; val r = that.term; if (l equ r) Lit(this.count + that.count) * r else Add(this, that) @@ -528,41 +528,41 @@ object MB { private def *< (that: Expr): Boolean = (this *<? that) < 0; private def *<= (that: Expr): Boolean = (this *<? that) <= 0; - private def *<? (that: Expr): Int = Pair(this,that) match { - case Pair(Mul(_,_), _ ) => 0 - case Pair(_ , Mul(_,_)) => 0 - case Pair(Add(_,_), Add(_,_)) => 0 - case Pair(Add(_,_), _ ) => -1 - case Pair(_ , Add(_,_)) => +1 - case Pair(Lit(_) , Lit(_) ) => 0 - case Pair(Lit(_) , _ ) => -1 - case Pair(_ , Lit(_) ) => +1 - case Pair(Var(l) , Var(r) ) => l.compareTo(r) - case Pair(Var(_) , Pow(r,_)) => if (this *<= r) -1 else +1 - case Pair(Pow(l,_), Var(_) ) => if (l *< that) -1 else +1 - case Pair(Pow(l,_), Pow(r,_)) => l *<? r + private def *<? (that: Expr): Int = (this,that) match { + case (Mul(_,_), _ ) => 0 + case (_ , Mul(_,_)) => 0 + case (Add(_,_), Add(_,_)) => 0 + case (Add(_,_), _ ) => -1 + case (_ , Add(_,_)) => +1 + case (Lit(_) , Lit(_) ) => 0 + case (Lit(_) , _ ) => -1 + case (_ , Lit(_) ) => +1 + case (Var(l) , Var(r) ) => l.compareTo(r) + case (Var(_) , Pow(r,_)) => if (this *<= r) -1 else +1 + case (Pow(l,_), Var(_) ) => if (l *< that) -1 else +1 + case (Pow(l,_), Pow(r,_)) => l *<? r } - def * (that: Expr): Expr = if (this *<= that) Pair(this,that) match { - case Pair(Lit(0) , _ ) => this - case Pair(Lit(1) , _ ) => that - case Pair(Mul(ll,lr), r ) => ll * (lr * r) - case Pair(Add(ll,lr), r ) => ll * r + lr * r - case Pair(Lit(l) , Lit(r) ) => Lit(l * r) - case Pair(Var(_) , Var(_) ) if (this equ that) => Pow(this,2) - case Pair(Var(_) , Pow(r,n) ) if (this equ r) => Pow(this,n + 1) - case Pair(Pow(ll,lr), Pow(rl,rr)) if (ll equ rl) => Pow(ll,lr + rr) - case Pair(l , Mul(rl,rr)) if (rl *<= l) => (rl * l) * rr - case Pair(_ , _ ) => Mul(this,that) + def * (that: Expr): Expr = if (this *<= that) (this,that) match { + case (Lit(0) , _ ) => this + case (Lit(1) , _ ) => that + case (Mul(ll,lr), r ) => ll * (lr * r) + case (Add(ll,lr), r ) => ll * r + lr * r + case (Lit(l) , Lit(r) ) => Lit(l * r) + case (Var(_) , Var(_) ) if (this equ that) => Pow(this,2) + case (Var(_) , Pow(r,n) ) if (this equ r) => Pow(this,n + 1) + case (Pow(ll,lr), Pow(rl,rr)) if (ll equ rl) => Pow(ll,lr + rr) + case (l , Mul(rl,rr)) if (rl *<= l) => (rl * l) * rr + case (_ , _ ) => Mul(this,that) } else that * this; def ^ (that: Int): Expr = (this,that) match { - case Pair(_ ,1) => this - case Pair(Lit(i) ,n) => Lit(power(i,n)) - case Pair(Var(_) ,n) => Pow(this,n) - case Pair(Add(_,_),n) => this * (this ^ (n - 1)) - case Pair(Mul(l,r),n) => (l ^ n) * (r ^ n) - case Pair(Pow(e,m),n) => Pow(e,m + n) + case (_ ,1) => this + case (Lit(i) ,n) => Lit(power(i,n)) + case (Var(_) ,n) => Pow(this,n) + case (Add(_,_),n) => this * (this ^ (n - 1)) + case (Mul(l,r),n) => (l ^ n) * (r ^ n) + case (Pow(e,m),n) => Pow(e,m + n) } def derive(v: Var): Expr = this match { @@ -581,12 +581,12 @@ object MB { case Pow(l, r) => power(l.evaluate(vars), r) } - def equ(that: Expr): Boolean = Pair(this,that) match { - case Pair(Lit(l) ,Lit(r)) => l == r - case Pair(Var(l) ,Var(r)) => l == r - case Pair(Add(ll,lr),Add(rl,rr)) => (ll equ rl) && (lr equ rr) - case Pair(Mul(ll,lr),Mul(rl,rr)) => (ll equ rl) && (lr equ rr) - case Pair(Pow(ll,lr),Pow(rl,rr)) => (ll equ rl) && (lr == rr) + def equ(that: Expr): Boolean = (this,that) match { + case (Lit(l) ,Lit(r)) => l == r + case (Var(l) ,Var(r)) => l == r + case (Add(ll,lr),Add(rl,rr)) => (ll equ rl) && (lr equ rr) + case (Mul(ll,lr),Mul(rl,rr)) => (ll equ rl) && (lr equ rr) + case (Pow(ll,lr),Pow(rl,rr)) => (ll equ rl) && (lr == rr) case _ => false } @@ -667,7 +667,7 @@ object MB { Console.println; def check(n: String, f: Expr, x: Int, e: Int) { - val a: Int = f.evaluate(List(Pair("x",x))); + val a: Int = f.evaluate(List(("x",x))); val s: String = if (a == e) "ok" else "KO(" + e + ")"; Console.println(n + "(" + x + ") = " + a + " " + s); } diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala index 38b8363661..5e21edaba3 100644 --- a/test/files/run/Course-2002-08.scala +++ b/test/files/run/Course-2002-08.scala @@ -163,7 +163,7 @@ object M5 { } abstract class Simulation() { - private type Agenda = List[Pair[Int, Action]]; + private type Agenda = List[Tuple2[Int, Action]]; private var agenda: Agenda = List(); private var curtime = 0; def currentTime: Int = curtime; @@ -171,17 +171,17 @@ object M5 { def afterDelay(delay: Int)(action: Action): Unit = { def insert(ag: Agenda, time: Int): Agenda = ag match { case List() => - List(Pair(time, action)) - case Pair(t, act) :: ag1 => - if (time < t) Pair(time, action) :: ag - else Pair(t, act) :: insert(ag1, time) + List((time, action)) + case (t, act) :: ag1 => + if (time < t) (time, action) :: ag + else (t, act) :: insert(ag1, time) } agenda = insert(agenda, curtime + delay) } private def next: Unit = agenda match { case List() => () - case Pair(time, action) :: ag1 => { + case (time, action) :: ag1 => { agenda = ag1; curtime = time; action(); @@ -413,7 +413,7 @@ object M5 { class Simulator() { type Action = () => Unit; - type Agenda = List[Pair[Int, Action]]; + type Agenda = List[Tuple2[Int, Action]]; private var agenda: Agenda = List(); private var curtime = 0; @@ -421,17 +421,17 @@ class Simulator() { def afterDelay(delay: Int)(action: Action) = { def insert(ag: Agenda, time: Int): Agenda = ag match { case List() => - List(Pair(time, action)) - case Pair(t, act) :: ag1 => - if (time < t) Pair(time, action) :: ag - else Pair(t, act) :: insert(ag1, time) + List((time, action)) + case (t, act) :: ag1 => + if (time < t) (time, action) :: ag + else (t, act) :: insert(ag1, time) } agenda = insert(agenda, curtime + delay) } def next: Unit = agenda match { case List() => () - case Pair(time, action) :: rest => { + case (time, action) :: rest => { agenda = rest; curtime = time; action(); @@ -567,8 +567,8 @@ class Main() extends CircuitSimulator() { demux(in, ctrl.reverse, out.reverse); probe("in", in); - for (Pair(x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) } - for (Pair(x,o) <- range(0,outNum) zip out) { probe("out" + x, o) } + for ((x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) } + for ((x,o) <- range(0,outNum) zip out) { probe("out" + x, o) } in.setSignal(true); run; diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala index 87f91111d8..704f2ec0aa 100644 --- a/test/files/run/Course-2002-09.scala +++ b/test/files/run/Course-2002-09.scala @@ -13,11 +13,11 @@ object NoConstraint extends Constraint { } class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint { - def newValue = Triple(a1.getValue, a2.getValue, sum.getValue) match { - case Triple(Some(x1), Some(x2), _ ) => sum.setValue(x1 + x2, this) - case Triple(Some(x1), _ , Some(r)) => a2.setValue(r - x1, this) - case Triple(_ , Some(x2), Some(r)) => a1.setValue(r - x2, this) - case _ => + def newValue = (a1.getValue, a2.getValue, sum.getValue) match { + case (Some(x1), Some(x2), _ ) => sum.setValue(x1 + x2, this) + case (Some(x1), _ , Some(r)) => a2.setValue(r - x1, this) + case (_ , Some(x2), Some(r)) => a1.setValue(r - x2, this) + case _ => } def dropValue: Unit = { a1.forgetValue(this); a2.forgetValue(this); sum.forgetValue(this); @@ -29,13 +29,13 @@ class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint { class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity) extends Constraint { - def newValue = Triple(m1.getValue, m2.getValue, prod.getValue) match { - case Triple(Some(0d), _ , _ ) => prod.setValue(0, this); - case Triple(_ , Some(0d), _ ) => prod.setValue(0, this); - case Triple(Some(x1), Some(x2), _ ) => prod.setValue(x1 * x2, this) - case Triple(Some(x1), _ , Some(r)) => m2.setValue(r / x1, this) - case Triple(_, Some(x2), Some(r)) => m1.setValue(r / x2, this) - case _ => + def newValue = (m1.getValue, m2.getValue, prod.getValue) match { + case (Some(0d), _ , _ ) => prod.setValue(0, this); + case (_ , Some(0d), _ ) => prod.setValue(0, this); + case (Some(x1), Some(x2), _ ) => prod.setValue(x1 * x2, this) + case (Some(x1), _ , Some(r)) => m2.setValue(r / x1, this) + case (_, Some(x2), Some(r)) => m1.setValue(r / x2, this) + case _ => } def dropValue: Unit = { m1.forgetValue(this); m2.forgetValue(this); prod.forgetValue(this); @@ -46,11 +46,11 @@ class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity) } class Squarer(square: Quantity, root: Quantity) extends Constraint { - def newValue: Unit = Pair(square.getValue, root.getValue) match { - case Pair(Some(x), _ )if (x < 0) => sys.error("Square of negative number") - case Pair(Some(x), _ ) => root.setValue(Math.sqrt(x), this) - case Pair(_ , Some(x)) => square.setValue(x*x, this) - case _ => + def newValue: Unit = (square.getValue, root.getValue) match { + case (Some(x), _ )if (x < 0) => sys.error("Square of negative number") + case (Some(x), _ ) => root.setValue(Math.sqrt(x), this) + case (_ , Some(x)) => square.setValue(x*x, this) + case _ => } def dropValue: Unit = { square.forgetValue(this); root.forgetValue(this); @@ -60,9 +60,9 @@ class Squarer(square: Quantity, root: Quantity) extends Constraint { } class Eq(a: Quantity, b: Quantity) extends Constraint { - def newValue = (Pair(a.getValue, b.getValue): @unchecked) match { - case Pair(Some(x), _ ) => b.setValue(x, this); - case Pair(_ , Some(y)) => a.setValue(y, this); + def newValue = ((a.getValue, b.getValue): @unchecked) match { + case (Some(x), _ ) => b.setValue(x, this); + case (_ , Some(y)) => a.setValue(y, this); } def dropValue { a.forgetValue(this); b.forgetValue(this); diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala index 4bd3614fb0..a596a33873 100644 --- a/test/files/run/Course-2002-13.scala +++ b/test/files/run/Course-2002-13.scala @@ -74,18 +74,18 @@ object Terms { val NoTerm = Con("<none>", List()); - def unify1(x: Term, y: Term, s: Subst): Option[Subst] = Pair(x, y) match { - case Pair(Var(a), Var(b)) if (a == b) => + def unify1(x: Term, y: Term, s: Subst): Option[Subst] = (x, y) match { + case (Var(a), Var(b)) if (a == b) => Some(s) - case Pair(Var(a), _) => lookup(s, a) match { + case (Var(a), _) => lookup(s, a) match { case Some(x1) => unify(x1, y, s) case None => if (y.tyvars contains a) None else Some(Binding(a, y) :: s) } - case Pair(_, Var(b)) => lookup(s, b) match { + case (_, Var(b)) => lookup(s, b) match { case Some(y1) => unify(x, y1, s) case None => if (x.tyvars contains b) None else Some(Binding(b, x) :: s) } - case Pair(Con(a, xs), Con(b, ys)) if (a == b) => + case (Con(a, xs), Con(b, ys)) if (a == b) => unify(xs, ys, s) case _ => None } @@ -96,9 +96,9 @@ object Terms { ss } - def unify(xs: List[Term], ys: List[Term], s: Subst): Option[Subst] = Pair(xs, ys) match { - case Pair(List(), List()) => Some(s) - case Pair(x :: xs1, y :: ys1) => + def unify(xs: List[Term], ys: List[Term], s: Subst): Option[Subst] = (xs, ys) match { + case (List(), List()) => Some(s) + case (x :: xs1, y :: ys1) => unify(x, y, s) match { case Some(s1) => unify(xs1, ys1, s1) case None => None diff --git a/test/files/run/bugs.scala b/test/files/run/bugs.scala index ba8449c299..02849b5817 100644 --- a/test/files/run/bugs.scala +++ b/test/files/run/bugs.scala @@ -46,7 +46,7 @@ object Bug135Test { def test(args: Array[String]) { val myMap:TreeMap[Int, String] = new TreeMap - val map1 = myMap + Pair(42, "The answer") + val map1 = myMap + ((42, "The answer")) println(map1.get(42)) } diff --git a/test/files/run/ctries-old/main.scala b/test/files/run/ctries-old/main.scala index f714bcdcdc..77161fed2f 100644 --- a/test/files/run/ctries-old/main.scala +++ b/test/files/run/ctries-old/main.scala @@ -38,7 +38,7 @@ trait Spec { var produced = false try body catch { - case e: Throwable => if (e.getClass == implicitly[ClassManifest[T]].erasure) produced = true + case e: Throwable => if (e.getClass == implicitly[ClassManifest[T]].runtimeClass) produced = true } finally { assert(produced, "Did not produce exception of type: " + implicitly[ClassManifest[T]]) } diff --git a/test/files/run/fors.check b/test/files/run/fors.check new file mode 100644 index 0000000000..b459f00b49 --- /dev/null +++ b/test/files/run/fors.check @@ -0,0 +1,28 @@ + +testOld +1 2 3 +2 +2 +3 +1 2 3 +1 2 3 +0 1 2 3 4 5 6 7 8 9 +0 2 4 6 8 +0 2 4 6 8 +a b c +b c +b c + +testNew +3 +1 2 3 +1 2 3 +0 1 2 3 4 5 6 7 8 9 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +0 2 4 6 8 +a b c diff --git a/test/files/run/fors.scala b/test/files/run/fors.scala new file mode 100644 index 0000000000..c778df3e24 --- /dev/null +++ b/test/files/run/fors.scala @@ -0,0 +1,84 @@ +//############################################################################ +// for-comprehensions (old and new syntax) +//############################################################################ + +//############################################################################ + +object Test extends App { + val xs = List(1, 2, 3) + val ys = List('a, 'b, 'c) + + def it = 0 until 10 + + val ar = "abc".toCharArray + + /////////////////// old syntax /////////////////// + + def testOld { + println("\ntestOld") + + // lists + for (x <- xs) print(x + " "); println + for (x <- xs; + if x % 2 == 0) print(x + " "); println + for {x <- xs + if x % 2 == 0} print(x + " "); println + var n = 0 + for (_ <- xs) n += 1; println(n) + for ((x, y) <- xs zip ys) print(x + " "); println + for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println + + // iterators + for (x <- it) print(x + " "); println + for (x <- it; + if x % 2 == 0) print(x + " "); println + for {x <- it + if x % 2 == 0} print(x + " "); println + + // arrays + for (x <- ar) print(x + " "); println + for (x <- ar; + if x.toInt > 97) print(x + " "); println + for {x <- ar + if x.toInt > 97} print(x + " "); println + + } + + /////////////////// new syntax /////////////////// + + def testNew { + println("\ntestNew") + + // lists + var n = 0 + for (_ <- xs) n += 1; println(n) + for ((x, y) <- xs zip ys) print(x + " "); println + for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println + + // iterators + for (x <- it) print(x + " "); println + for (x <- it if x % 2 == 0) print(x + " "); println + for (x <- it; if x % 2 == 0) print(x + " "); println + for (x <- it; + if x % 2 == 0) print(x + " "); println + for (x <- it + if x % 2 == 0) print(x + " "); println + for {x <- it + if x % 2 == 0} print(x + " "); println + for (x <- it; + y = 2 + if x % y == 0) print(x + " "); println + for {x <- it + y = 2 + if x % y == 0} print(x + " "); println + + // arrays + for (x <- ar) print(x + " "); println + + } + + //////////////////////////////////////////////////// + + testOld + testNew +} diff --git a/test/files/run/getClassTest-old.scala b/test/files/run/getClassTest-old.scala index 789dd4d162..cd1b6b07f6 100644 --- a/test/files/run/getClassTest-old.scala +++ b/test/files/run/getClassTest-old.scala @@ -53,7 +53,7 @@ class MoreAnyRefs { @deprecated("Suppress warnings", since="2.11") object Test { def returnTypes[T: Manifest] = ( - manifest[T].erasure.getMethods.toList + manifest[T].runtimeClass.getMethods.toList filter (_.getName startsWith "f") sortBy (_.getName) map (m => m.getName + ": " + m.getGenericReturnType.toString) diff --git a/test/files/run/map_test.scala b/test/files/run/map_test.scala index 1ea864ed58..b76dfb4577 100644 --- a/test/files/run/map_test.scala +++ b/test/files/run/map_test.scala @@ -20,7 +20,7 @@ object Test extends App { val map2 = map1.updated(17,"A small random number") val map3 = map2.updated(666,"A bigger random number") val map4 = map3.updated(4711,"A big random number") - map1 == myMap + Pair(42, "The answer") + map1 == myMap + ((42, "The answer")) var i = 0 var map = map4 while(i < 43) { diff --git a/test/files/run/mutable-anyrefmap.scala b/test/files/run/mutable-anyrefmap.scala new file mode 100644 index 0000000000..ff615d0daf --- /dev/null +++ b/test/files/run/mutable-anyrefmap.scala @@ -0,0 +1,91 @@ +object Test extends App { + + import scala.collection.mutable.HashMap; + import scala.collection.mutable.AnyRefMap; + + val keys = Array( + null, "perch", "herring", "salmon", "pike", "cod", "" + ) + + val rn = new scala.util.Random(42L) + var arm = AnyRefMap.empty[String, Int] + val hm = HashMap.empty[String, Int] + + def checkConsistent = hm.forall{ case (k,v) => arm.get(k).exists(_ == v) } + + assert { + (0 to 10000).forall{ i => + val k = keys(rn.nextInt(keys.length)) + if (rn.nextInt(100) < 2) arm = arm.clone() + if (rn.nextInt(100) < 5) arm.repack() + if (rn.nextBoolean) { + hm += ((k, i)) + rn.nextInt(6) match { + case 0 => arm += ((k, i)) + case 1 => arm += (k, i) + case 2 => arm(k) = i + case 3 => arm.put(k,i) + case 4 => arm ++= List((k,i)) + case _ => if (!arm.contains(k)) arm.getOrElseUpdate(k,i) + else arm += (k,i) + } + } + else { + hm -= k + rn.nextInt(2) match { + case 0 => arm -= k + case _ => arm --= List(k) + } + } + checkConsistent + } + } + + assert { + val mapped = + arm.map{ case (k,v) => (if (k==null) "" else k+k) -> v.toString } + mapped.getClass == arm.getClass + } + + assert { + val arm2 = new AnyRefMap[java.lang.Integer,Unit](2000000) + for (i <- 0 until 1000000) arm2(java.lang.Integer.valueOf(i)) = () + + arm2.size == 1000000 && + (0 to 1100000 by 100000).map(java.lang.Integer.valueOf).forall(i => (arm2 contains i) == i < 1000000) + } + + arm = AnyRefMap("heron" -> 22, "dove" -> 5, "budgie" -> 0) + + assert{ + var s = "" + arm.foreachKey(s += _) + + s.length == "herondovebudgie".length && + s.contains("heron") && + s.contains("dove") && + s.contains("budgie") + } + + assert{ var s = 0L; arm.foreachValue(s += _); s == 27L } + + assert { + val m2 = arm.mapValuesNow(_+2) + arm.transformValues(_+2) + m2 == arm && !(m2 eq arm) && (for ((_,v) <- arm) yield v).sum == 33L + } + + assert { + val arm2 = new AnyRefMap[String, String](x => if (x==null) "null" else x) + arm2 += ("cod" -> "fish", "Rarity" -> "unicorn") + val hm2 = (new HashMap[String,String]) ++= arm2 + + List(null, "cod", "sparrow", "Rarity").forall(i => + arm2.get(i) == hm2.get(i) && + arm2.getOrElse(i, "") == hm2.getOrElse(i, "") && + arm2(i) == hm2.get(i).getOrElse(if (i==null) "null" else i.toString) && + arm2.getOrNull(i) == hm2.get(i).orNull + ) + } +} + diff --git a/test/files/run/mutable-longmap.scala b/test/files/run/mutable-longmap.scala new file mode 100644 index 0000000000..07fd80f6f0 --- /dev/null +++ b/test/files/run/mutable-longmap.scala @@ -0,0 +1,79 @@ +object Test extends App { + + import scala.collection.mutable.HashMap; + import scala.collection.mutable.LongMap; + + val keys = Array( + Long.MinValue, Int.MinValue - 1L, Int.MinValue, -9127, -1, + 0, 1, 9127, Int.MaxValue, Long.MaxValue + ) + + val rn = new scala.util.Random(42L) + var lm = LongMap.empty[Long] + val hm = HashMap.empty[Long,Long] + + def checkConsistent = hm.forall{ case (k,v) => lm.get(k).exists(_ == v) } + + assert { + (0 to 10000).forall{ i => + val k = keys(rn.nextInt(keys.length)) + if (rn.nextInt(100) < 2) lm = lm.clone() + if (rn.nextInt(100) < 5) lm.repack() + if (rn.nextBoolean) { + hm += ((k, i)) + rn.nextInt(6) match { + case 0 => lm += ((k, i)) + case 1 => lm += (k, i) + case 2 => lm(k) = i + case 3 => lm.put(k,i) + case 4 => lm ++= List((k,i)) + case _ => if (!lm.contains(k)) lm.getOrElseUpdate(k,i) + else lm += (k,i) + } + } + else { + hm -= k + rn.nextInt(2) match { + case 0 => lm -= k + case _ => lm --= List(k) + } + } + checkConsistent + } + } + + assert { + lm.map{ case (k,v) => -k*k -> v.toString }.getClass == lm.getClass + } + + assert { + val lm2 = new LongMap[Unit](2000000) + for (i <- 0 until 1000000) lm2(i) = () + + lm2.size == 1000000 && + (0 to 1100000 by 100000).forall(i => (lm2 contains i) == i < 1000000) + } + + lm = LongMap(8L -> 22L, -5L -> 5L, Long.MinValue -> 0L) + + assert{ var s = 0L; lm.foreachKey(s += _); s == Long.MinValue + 3 } + assert{ var s = 0L; lm.foreachValue(s += _); s == 27L } + assert { + val m2 = lm.mapValuesNow(_+2) + lm.transformValues(_+2) + m2 == lm && !(m2 eq lm) && (for ((_,v) <- lm) yield v).sum == 33L + } + + assert { + val lm2 = new LongMap[String](_.toString) + lm2 += (5L -> "fish", 0L -> "unicorn") + val hm2 = (new HashMap[Long,String]) ++= lm2 + + List(Long.MinValue, 0L, 1L, 5L).forall(i => + lm2.get(i) == hm2.get(i) && + lm2.getOrElse(i, "") == hm2.getOrElse(i, "") && + lm2(i) == hm2.get(i).getOrElse(i.toString) && + lm2.getOrNull(i) == hm2.get(i).orNull + ) + } +} diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala index b212e10f8d..3c0d00dc6c 100644 --- a/test/files/run/patmatnew.scala +++ b/test/files/run/patmatnew.scala @@ -46,7 +46,7 @@ object Test { object SimpleUnapply { def run() { // from sortedmap, old version List((1, 2)).head match { - case kv@Pair(key, _) => kv.toString + " " + key.toString + case kv@(key, _) => kv.toString + " " + key.toString } } @@ -400,9 +400,9 @@ object Test { // these are exhaustive matches // should not generate any warnings def f[A](z: (Option[A], Option[A])) = z match { - case Pair(None, Some(x)) => 1 - case Pair(Some(x), None) => 2 - case Pair(Some(x), Some(y)) => 3 + case (None, Some(x)) => 1 + case (Some(x), None) => 2 + case (Some(x), Some(y)) => 3 case _ => 4 } @@ -419,9 +419,9 @@ object Test { } def h[A](x: (Option[A], Option[A])) = x match { - case Pair(None, _: Some[_]) => 1 - case Pair(_: Some[_], None) => 2 - case Pair(_: Some[_], _: Some[_]) => 3 + case (None, _: Some[_]) => 1 + case (_: Some[_], None) => 2 + case (_: Some[_], _: Some[_]) => 3 case _ => 4 } @@ -539,17 +539,17 @@ object Test { case class Operator(x: Int); val EQ = new Operator(2); - def analyze(x: Pair[Operator, Int]) = x match { - case Pair(EQ, 0) => "0" - case Pair(EQ, 1) => "1" - case Pair(EQ, 2) => "2" + def analyze(x: Tuple2[Operator, Int]) = x match { + case (EQ, 0) => "0" + case (EQ, 1) => "1" + case (EQ, 2) => "2" } def run() { - val x = Pair(EQ, 0); + val x = (EQ, 0); assertEquals("0", analyze(x)); // should print "0" - val y = Pair(EQ, 1); + val y = (EQ, 1); assertEquals("1", analyze(y)); // should print "1" - val z = Pair(EQ, 2); + val z = (EQ, 2); assertEquals("2", analyze(z)); // should print "2" } } diff --git a/test/files/run/repl-backticks.check b/test/files/run/repl-backticks.check new file mode 100644 index 0000000000..c0561abd7c --- /dev/null +++ b/test/files/run/repl-backticks.check @@ -0,0 +1,2 @@ +import java.lang.Thread.`yield` +import scala.`package`.Throwable diff --git a/test/files/run/repl-backticks.scala b/test/files/run/repl-backticks.scala new file mode 100644 index 0000000000..e40a8bc662 --- /dev/null +++ b/test/files/run/repl-backticks.scala @@ -0,0 +1,18 @@ +import scala.tools.nsc._ + +object Test { + val testCode = """ + import java.lang.Thread.`yield` + import scala.`package`.Throwable + + `yield` + """ + + def main(args: Array[String]) { + val settings = new Settings() + settings.classpath.value = System.getProperty("java.class.path") + val repl = new interpreter.IMain(settings) + repl.interpret(testCode) + } +} + diff --git a/test/files/run/t1500.check b/test/files/run/t1500.check new file mode 100644 index 0000000000..94a169333b --- /dev/null +++ b/test/files/run/t1500.check @@ -0,0 +1,3 @@ +defined class posingAs +resolve: [A, B](x: A @posingAs[B])B +x: Any = 7 diff --git a/test/files/run/t1500.scala b/test/files/run/t1500.scala new file mode 100644 index 0000000000..30c026f70f --- /dev/null +++ b/test/files/run/t1500.scala @@ -0,0 +1,46 @@ +import scala.tools.nsc._ + +object Test { + + /** + * Type inference overlooks constraints posed by type parameters in annotations on types. + */ + + val testCode = """ + + class posingAs[A] extends annotation.TypeConstraint + + def resolve[A,B](x: A @posingAs[B]): B = x.asInstanceOf[B] + + val x = resolve(7: @posingAs[Any]) + + """ + + def main(args: Array[String]) { + + val settings = new Settings() + settings.classpath.value = System.getProperty("java.class.path") + val tool = new interpreter.IMain(settings) + val global = tool.global + + import global._ + import definitions._ + + object checker extends AnnotationChecker { + + /** Check annotations to decide whether tpe1 <:< tpe2 */ + def annotationsConform(tpe1: Type, tpe2: Type): Boolean = { + + tpe1.annotations.forall(a1 => tpe2.annotations.forall(a2 => a1.atp <:< a2.atp)) + + } + } + + global.addAnnotationChecker(checker) + + tool.interpret(testCode) + + } + +} + diff --git a/test/files/run/t1501.check b/test/files/run/t1501.check new file mode 100644 index 0000000000..f0fa9112a5 --- /dev/null +++ b/test/files/run/t1501.check @@ -0,0 +1,3 @@ +defined class xyz +loopWhile: [T](cond: => Boolean)(body: => Unit @xyz[T])Unit @xyz[T] +test: ()Unit @xyz[Int] diff --git a/test/files/run/t1501.scala b/test/files/run/t1501.scala new file mode 100644 index 0000000000..ca6bf357fb --- /dev/null +++ b/test/files/run/t1501.scala @@ -0,0 +1,56 @@ +import scala.tools.nsc._ + +object Test { + + /** + * ... + */ + + val testCode = """ + + class xyz[A] extends annotation.TypeConstraint + + def loopWhile[T](cond: =>Boolean)(body: =>(Unit @xyz[T])): Unit @ xyz[T] = {{ + if (cond) {{ + body + loopWhile[T](cond)(body) + }} + }} + + def test() = {{ + var x = 7 + loopWhile(x != 0) {{ + x = x - 1 + (): @xyz[Int] + }} + }} + + """ + + def main(args: Array[String]) { + val settings = new Settings() + settings.classpath.value = System.getProperty("java.class.path") + val tool = new interpreter.IMain(settings) + val global = tool.global + + import global._ + import definitions._ + + object checker extends AnnotationChecker { + + /** Check annotations to decide whether tpe1 <:< tpe2 */ + def annotationsConform(tpe1: Type, tpe2: Type): Boolean = { + + tpe1.annotations.forall(a1 => tpe2.annotations.forall(a2 => a1.atp <:< a2.atp)) + + } + } + + global.addAnnotationChecker(checker) + + tool.interpret(testCode) + + } + +} + diff --git a/test/files/run/t3888.scala b/test/files/run/t3888.scala index 19771041fc..8701b42ff0 100644 --- a/test/files/run/t3888.scala +++ b/test/files/run/t3888.scala @@ -24,6 +24,6 @@ object Test { } } -class P extends Pair(1, 1) { +class P extends Tuple2(1, 1) { override def equals(x: Any) = true } diff --git a/test/files/run/t4124.check b/test/files/run/t4124.check new file mode 100644 index 0000000000..66a0092d93 --- /dev/null +++ b/test/files/run/t4124.check @@ -0,0 +1,4 @@ +hi +hi +bye +bye diff --git a/test/files/run/t4124.scala b/test/files/run/t4124.scala new file mode 100644 index 0000000000..9f35b57ce3 --- /dev/null +++ b/test/files/run/t4124.scala @@ -0,0 +1,24 @@ +import xml.Node + +object Test extends App { + val body: Node = <elem>hi</elem> + println ((body: AnyRef, "foo") match { + case (node: Node, "bar") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body, "foo") match { + case (node: Node, "bar") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body: AnyRef, "foo") match { + case (node: Node, "foo") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body: AnyRef, "foo") match { + case (node: Node, "foo") => "bye" + case (ser: Serializable, "foo") => "hi" + }) +} diff --git a/test/files/run/t6329_repl_bug.check b/test/files/run/t6329_repl_bug.check new file mode 100644 index 0000000000..44c41cfd03 --- /dev/null +++ b/test/files/run/t6329_repl_bug.check @@ -0,0 +1,17 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> import scala.reflect.runtime.universe._ +import scala.reflect.runtime.universe._ + +scala> import scala.reflect.runtime._ +import scala.reflect.runtime._ + +scala> classManifest[List[_]] +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +res0: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List[<?>] + +scala> scala.reflect.classTag[List[_]] +res1: scala.reflect.ClassTag[List[_]] = scala.collection.immutable.List + +scala> diff --git a/test/files/run/t6329_repl_bug.pending b/test/files/run/t6329_repl_bug.scala index 9997d1771e..9997d1771e 100644 --- a/test/files/run/t6329_repl_bug.pending +++ b/test/files/run/t6329_repl_bug.scala diff --git a/test/files/run/t6329_vanilla_bug.check b/test/files/run/t6329_vanilla_bug.check new file mode 100644 index 0000000000..640d168a8a --- /dev/null +++ b/test/files/run/t6329_vanilla_bug.check @@ -0,0 +1,3 @@ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +scala.collection.immutable.List[<?>] +scala.collection.immutable.List diff --git a/test/files/run/t6329_vanilla_bug.pending b/test/files/run/t6329_vanilla_bug.scala index 404f90bf6e..404f90bf6e 100644 --- a/test/files/run/t6329_vanilla_bug.pending +++ b/test/files/run/t6329_vanilla_bug.scala diff --git a/test/files/run/t7985.scala b/test/files/run/t7985.scala new file mode 100644 index 0000000000..5fe270f9c0 --- /dev/null +++ b/test/files/run/t7985.scala @@ -0,0 +1,3 @@ +object Test extends App { + Array(1) match { case _: Array[scala.Int] => } +} diff --git a/test/files/run/t7985b.scala b/test/files/run/t7985b.scala new file mode 100644 index 0000000000..aaf649eb28 --- /dev/null +++ b/test/files/run/t7985b.scala @@ -0,0 +1,5 @@ +class a { type X = Int } + +object Test extends App { + Array(1) match { case _: Array[a#X] => } +} diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala index e5d8891cc7..1653b14de9 100644 --- a/test/files/run/tailcalls.scala +++ b/test/files/run/tailcalls.scala @@ -169,7 +169,7 @@ class TailCall[S](s: S) { aux[T](x, y); } final def g3[T](x: Int, y: Int, zs: List[T]): Int = { - def aux[U](n: Int, v: Int, ls: List[Pair[T,U]]): Int = + def aux[U](n: Int, v: Int, ls: List[Tuple2[T,U]]): Int = if (n == 0) v else aux(n - 1, v - 1, ls); aux(x, y, Nil); } diff --git a/test/files/run/tcpoly_parseridioms.check b/test/files/run/tcpoly_parseridioms.check index ab829e0a0e..8bd0a086d6 100644 --- a/test/files/run/tcpoly_parseridioms.check +++ b/test/files/run/tcpoly_parseridioms.check @@ -4,8 +4,8 @@ It would fail on the following input: ParseResult() ^ tcpoly_parseridioms.scala:17: warning: match may not be exhaustive. It would fail on the following input: ParseResult() - def apply(in: Input): ParseResult[Pair[T, U]] = a(in) match { - ^ + def apply(in: Input): ParseResult[Tuple2[T, U]] = a(in) match { + ^ tcpoly_parseridioms.scala:30: warning: match may not be exhaustive. It would fail on the following input: ParseResult() case Failure(_, _) => b(in) match { diff --git a/test/files/run/tcpoly_parseridioms.scala b/test/files/run/tcpoly_parseridioms.scala index c8bcf693a1..d22f68b558 100644 --- a/test/files/run/tcpoly_parseridioms.scala +++ b/test/files/run/tcpoly_parseridioms.scala @@ -13,10 +13,10 @@ trait Parsers { } // sequence - def sq[T, U](a: => Parser[T], b: => Parser[U]): Parser[Pair[T, U]] = new Parser[Pair[T, U]] { - def apply(in: Input): ParseResult[Pair[T, U]] = a(in) match { + def sq[T, U](a: => Parser[T], b: => Parser[U]): Parser[Tuple2[T, U]] = new Parser[Tuple2[T, U]] { + def apply(in: Input): ParseResult[Tuple2[T, U]] = a(in) match { case Success(next, x) => b(next) match { - case Success(next2, y) => Success(next2, Pair(x,y)) + case Success(next2, y) => Success(next2, (x,y)) case Failure(_, msg) => Failure(in, msg) } case Failure(_, msg) => Failure(in, msg) @@ -49,7 +49,7 @@ trait Parsers { } } - def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Pair[s=>tt, s], tt]({case Pair(f, a) => f(a)})(sq(fun, arg)) + def apply_++[s, tt](fun: Parser[s => tt], arg: Parser[s]): Parser[tt] = lift[Tuple2[s=>tt, s], tt]({case (f, a) => f(a)})(sq(fun, arg)) def success[u](v: u): Parser[u] = new Parser[u] { def apply(in: Input) = Success(in, v) diff --git a/test/files/run/withIndex.scala b/test/files/run/withIndex.scala index 910b1f1f9e..ebf1941c95 100644 --- a/test/files/run/withIndex.scala +++ b/test/files/run/withIndex.scala @@ -11,7 +11,7 @@ object Test { Console.println(str.zipWithIndex.toList) assert { ary.zipWithIndex match { - case _: Array[Pair[_,_]] => true + case _: Array[Tuple2[_,_]] => true case _ => false } } diff --git a/test/files/scalacheck/CheckCollections.scala b/test/files/scalacheck/CheckCollections.scala index 108040b900..329d505b47 100644 --- a/test/files/scalacheck/CheckCollections.scala +++ b/test/files/scalacheck/CheckCollections.scala @@ -1,4 +1,4 @@ -import org.scalacheck.{ ConsoleReporter, Properties } +import org.scalacheck.Properties import org.scalacheck.Prop._ import scala.reflect.internal.util.Collections._ @@ -49,11 +49,4 @@ object Test extends Properties("reflect.internal.util.Collections") { for { (label, prop) <- tests } property(label) = prop - - import org.scalacheck.{ Test => STest } - - def runTests() = - STest.checkProperties( - STest.Params(testCallback = ConsoleReporter(0)), this) - } diff --git a/test/files/scalacheck/CheckEither.scala b/test/files/scalacheck/CheckEither.scala index 4d0cab4693..48f732a22d 100644 --- a/test/files/scalacheck/CheckEither.scala +++ b/test/files/scalacheck/CheckEither.scala @@ -1,10 +1,8 @@ -import org.scalacheck.{ Arbitrary, ConsoleReporter, Prop, Properties } +import org.scalacheck.{ Arbitrary, Prop, Properties } import org.scalacheck.Arbitrary.{arbitrary, arbThrowable} import org.scalacheck.Gen.oneOf -import org.scalacheck.util.StdRand import org.scalacheck.Prop._ -import org.scalacheck.Test.{Params, check} -import org.scalacheck.ConsoleReporter.testStatsEx +import org.scalacheck.Test.check import Function.tupled object Test extends Properties("Either") { @@ -178,10 +176,4 @@ object Test extends Properties("Either") { for ((label, prop) <- tests) { property(label) = prop } - - import org.scalacheck.{ Test => STest } - - def runTests() = { - STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), this) - } } diff --git a/test/files/scalacheck/array-new.scala b/test/files/scalacheck/array-new.scala index e13a47a5d5..d8c69ead78 100644 --- a/test/files/scalacheck/array-new.scala +++ b/test/files/scalacheck/array-new.scala @@ -1,4 +1,4 @@ -import scala.reflect.{ClassTag, classTag} +import scala.reflect.ClassTag // new style: use ClassTag import org.scalacheck._ import Prop._ import Gen._ diff --git a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala index c4b93dae48..7905a2ca15 100644 --- a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala +++ b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala @@ -222,7 +222,7 @@ trait ArbitraryTreesAndNames { yield ValDef(mods, name, tpt, rhs) def genTree(size: Int): Gen[Tree] = - if (size <= 1) oneOf(EmptyTree, genTreeIsTerm(size), genTreeIsType(size)) + if (size <= 1) oneOf(EmptyTree: Gen[Tree], genTreeIsTerm(size), genTreeIsType(size)) else oneOf(genTree(1), // these trees are neither terms nor types genPackageDef(size - 1), genModuleDef(size - 1), @@ -273,8 +273,8 @@ trait ArbitraryTreesAndNames { def apply(universe: Universe, value: TreeIsType): universe.Tree = value.tree.asInstanceOf[universe.Tree] } - implicit def treeIsTerm2tree(tit: TreeIsTerm) = tit.tree - implicit def treeIsType2tree(tit: TreeIsType) = tit.tree + implicit def treeIsTerm2tree(tit: TreeIsTerm): Tree = tit.tree + implicit def treeIsType2tree(tit: TreeIsType): Tree = tit.tree implicit val arbConstant: Arbitrary[Constant] = Arbitrary(genConstant) implicit val arbModifiers: Arbitrary[Modifiers] = Arbitrary(genModifiers) diff --git a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala index b2bce124ee..b331c4b6b6 100644 --- a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala +++ b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala @@ -18,13 +18,12 @@ trait Helpers { object simplify extends Transformer { object SimplifiedName { - def unapply[T <: Name](name: T): Option[T] = - name.toString.split("\\$").toSeq match { - case first :+ last if scala.util.Try(last.toInt).isSuccess && first.nonEmpty => - val value = first.mkString("", "$", "$") - Some((if (name.isTermName) TermName(value) else TypeName(value)).asInstanceOf[T]) - case _ => None - } + val st = scala.reflect.runtime.universe.asInstanceOf[scala.reflect.internal.SymbolTable] + val FreshName = new st.FreshNameExtractor + def unapply[T <: Name](name: T): Option[T] = name.asInstanceOf[st.Name] match { + case FreshName(prefix) => + Some((if (name.isTermName) TermName(prefix) else TypeName(prefix)).asInstanceOf[T]) + } } override def transform(tree: Tree): Tree = tree match { @@ -59,7 +58,7 @@ trait Helpers { } def assertThrows[T <: AnyRef](f: => Any)(implicit manifest: Manifest[T]): Unit = { - val clazz = manifest.erasure.asInstanceOf[Class[T]] + val clazz = manifest.runtimeClass.asInstanceOf[Class[T]] val thrown = try { f diff --git a/test/files/scalacheck/si4147.scala b/test/files/scalacheck/si4147.scala index 05507b1b18..72f6e9afd5 100644 --- a/test/files/scalacheck/si4147.scala +++ b/test/files/scalacheck/si4147.scala @@ -1,8 +1,6 @@ import org.scalacheck.Prop.{forAll, throws} import org.scalacheck.Properties -import org.scalacheck.ConsoleReporter.testStatsEx import org.scalacheck.Gen -import org.scalacheck.ConsoleReporter import collection.mutable @@ -66,5 +64,5 @@ object Test extends Properties("Mutable TreeSet") { } property("ordering must not be null") = - throws(mutable.TreeSet.empty[Int](null), classOf[NullPointerException]) + throws(classOf[NullPointerException])(mutable.TreeSet.empty[Int](null)) } diff --git a/test/files/scalacheck/t2460.scala b/test/files/scalacheck/t2460.scala index 196b43789f..ab2911447a 100644 --- a/test/files/scalacheck/t2460.scala +++ b/test/files/scalacheck/t2460.scala @@ -1,6 +1,5 @@ import org.scalacheck.Prop.forAll import org.scalacheck.Properties -import org.scalacheck.ConsoleReporter.testStatsEx import org.scalacheck.{Test => SCTest} import org.scalacheck.Gen @@ -25,8 +24,4 @@ object Test extends Properties("Regex : Ticket 2460") { ("numberOfGroup", numberOfGroup), ("nameOfGroup", nameOfGroup) ) - - /*tests foreach { - case (name, p) => testStatsEx(name, SCTest.check(p)) - }*/ } diff --git a/test/files/scalacheck/treeset.scala b/test/files/scalacheck/treeset.scala index 7fca3ed5e4..4b9b77dd7e 100644 --- a/test/files/scalacheck/treeset.scala +++ b/test/files/scalacheck/treeset.scala @@ -151,5 +151,5 @@ object Test extends Properties("TreeSet") { } property("ordering must not be null") = - throws(TreeSet.empty[Int](null), classOf[NullPointerException]) + throws(classOf[NullPointerException])(TreeSet.empty[Int](null)) } |