summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-06-05 15:57:59 +0000
committerMartin Odersky <odersky@gmail.com>2007-06-05 15:57:59 +0000
commite51207992f525ed9e32a7a9a39512b4d7e503c03 (patch)
treeb9440d03aed294fde3f8aaa293f60ed98b5de0c1 /test/files
parente060c61b6127ceb2de0e4ce5d3f3d685bc542804 (diff)
downloadscala-e51207992f525ed9e32a7a9a39512b4d7e503c03.tar.gz
scala-e51207992f525ed9e32a7a9a39512b4d7e503c03.tar.bz2
scala-e51207992f525ed9e32a7a9a39512b4d7e503c03.zip
deprecated &f, .f, requires.
Added existential types.
Diffstat (limited to 'test/files')
-rw-r--r--test/files/jvm/protectedacc.scala4
-rw-r--r--test/files/neg/bug1001.scala2
-rw-r--r--test/files/neg/bug1024.check4
-rw-r--r--test/files/neg/bug1024.scala3
-rw-r--r--test/files/neg/bug343.scala2
-rw-r--r--test/files/neg/bug648.check4
-rw-r--r--test/files/neg/bug648.scala14
-rw-r--r--test/files/neg/bug752.check4
-rw-r--r--test/files/neg/bug752.scala2
-rw-r--r--test/files/neg/bug783.scala2
-rw-r--r--test/files/neg/bug845.scala2
-rw-r--r--test/files/neg/bug846.scala2
-rw-r--r--test/files/neg/bug987.scala2
-rw-r--r--test/files/neg/escapes.check4
-rw-r--r--test/files/neg/escapes.scala6
-rw-r--r--test/files/neg/saito.scala2
-rw-r--r--test/files/pos/bug0039.scala2
-rw-r--r--test/files/pos/bug210.scala4
-rw-r--r--test/files/pos/bug211.scala2
-rw-r--r--test/files/pos/bug267.scala8
-rw-r--r--test/files/pos/bug360.scala4
-rw-r--r--test/files/pos/bug361.scala2
-rw-r--r--test/files/pos/bug372.scala2
-rw-r--r--test/files/pos/bug592.scala2
-rw-r--r--test/files/pos/bug780.scala2
-rw-r--r--test/files/pos/pat_iuli.scala4
-rw-r--r--test/files/pos/philippe4.scala2
-rw-r--r--test/files/pos/scoping1.scala2
-rw-r--r--test/files/pos/scoping3.scala3
-rw-r--r--test/files/pos/unapplyContexts2.scala2
-rw-r--r--test/files/run/Course-2002-02.scala12
-rw-r--r--test/files/run/amp.scala4
-rw-r--r--test/files/run/collections.scala8
-rw-r--r--test/files/run/ctor-order.scala2
-rw-r--r--test/files/run/imports.scala6
-rw-r--r--test/files/run/patmatnew.scala2
-rw-r--r--test/files/run/tuples.scala4
37 files changed, 52 insertions, 86 deletions
diff --git a/test/files/jvm/protectedacc.scala b/test/files/jvm/protectedacc.scala
index 53e43d75a4..50fd66c0b5 100644
--- a/test/files/jvm/protectedacc.scala
+++ b/test/files/jvm/protectedacc.scala
@@ -84,7 +84,7 @@ package p {
Console.println("meth3 = " + meth3.getClass);
- val inc = &meth2(1);
+ val inc = meth2(1)_;
Console.println("100 = " + inc("10"));
getA.x;
@@ -111,7 +111,7 @@ package p {
Console.println("meth1(1) = " + meth1(1));
Console.println("meth2(1)(1) = " + meth2(1)("1"));
- val inc = &meth2(1);
+ val inc = meth2(1)_;
Console.println("100 = " + inc("10"));
getA.x;
diff --git a/test/files/neg/bug1001.scala b/test/files/neg/bug1001.scala
index 139ade366c..1b909fb2ad 100644
--- a/test/files/neg/bug1001.scala
+++ b/test/files/neg/bug1001.scala
@@ -7,7 +7,7 @@ abstract class A
protected val data: List[A]
}
-trait B[T <: B[T]] requires T extends A {}
+trait B[T <: B[T]] extends A { self: T => }
abstract class C extends A
{
diff --git a/test/files/neg/bug1024.check b/test/files/neg/bug1024.check
deleted file mode 100644
index c70ff47ec0..0000000000
--- a/test/files/neg/bug1024.check
+++ /dev/null
@@ -1,4 +0,0 @@
-bug1024.scala:2: error: type _ escapes its defining scope as part of type (List[_], Int)
- val (a: List[_], b) = (List(1 ,2 ,3 ), 4)
- ^
-one error found
diff --git a/test/files/neg/bug1024.scala b/test/files/neg/bug1024.scala
deleted file mode 100644
index bddb21f727..0000000000
--- a/test/files/neg/bug1024.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test {
- val (a: List[_], b) = (List(1 ,2 ,3 ), 4)
-}
diff --git a/test/files/neg/bug343.scala b/test/files/neg/bug343.scala
index d04e1479f7..ed57d2eef7 100644
--- a/test/files/neg/bug343.scala
+++ b/test/files/neg/bug343.scala
@@ -5,6 +5,8 @@ class C {
def get:Foo = new Foo();
}
+
+
object Test {
def main(args:Array[String]) = {
val c = new C().get;
diff --git a/test/files/neg/bug648.check b/test/files/neg/bug648.check
deleted file mode 100644
index 5323f86c42..0000000000
--- a/test/files/neg/bug648.check
+++ /dev/null
@@ -1,4 +0,0 @@
-bug648.scala:7: error: value newAcc escapes its defining scope as part of type newAcc.type
- List[Symbol]() map { sym =>
- ^
-one error found
diff --git a/test/files/neg/bug648.scala b/test/files/neg/bug648.scala
deleted file mode 100644
index 6b8d70ff0d..0000000000
--- a/test/files/neg/bug648.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-import scala.tools.nsc.transform.Transform
-
-abstract class Detach extends Transform {
- import global._
- class DetachTransformer extends Transformer {
- def foo: Scope = newScope(
- List[Symbol]() map { sym =>
- val newAcc = sym.cloneSymbol
- // def setFlag(mask: long): this.type
- newAcc.setFlag(0)
- }
- )
- }
-}
diff --git a/test/files/neg/bug752.check b/test/files/neg/bug752.check
index 7559a497ce..dddab530e4 100644
--- a/test/files/neg/bug752.check
+++ b/test/files/neg/bug752.check
@@ -1,6 +1,6 @@
bug752.scala:6: error: type mismatch;
found : (String) => Unit
required: (Int) => Unit
- f(&g)
- ^
+ f(g _)
+ ^
one error found
diff --git a/test/files/neg/bug752.scala b/test/files/neg/bug752.scala
index aae0d5f4a7..00f45e323c 100644
--- a/test/files/neg/bug752.scala
+++ b/test/files/neg/bug752.scala
@@ -3,6 +3,6 @@ object Test
def f(x : Int => Unit) : Unit = ()
def g(x : String) : Unit = ()
def main(argv : Array[String]) = {
- f(&g)
+ f(g _)
}
}
diff --git a/test/files/neg/bug783.scala b/test/files/neg/bug783.scala
index 0180d3d634..3818910b8e 100644
--- a/test/files/neg/bug783.scala
+++ b/test/files/neg/bug783.scala
@@ -6,7 +6,7 @@ object Main extends Application {
Console.println("outer: " + Global.this);
}
}
- trait Contexts requires Analyzer {
+ trait Contexts { self: Analyzer =>
val xxx : global.Template = {
assert(globalInit0 != null);
globalInit0.Template(10, 20);
diff --git a/test/files/neg/bug845.scala b/test/files/neg/bug845.scala
index c8a2faa671..26c2df52dc 100644
--- a/test/files/neg/bug845.scala
+++ b/test/files/neg/bug845.scala
@@ -11,6 +11,6 @@ object Test extends Application {
if (a != null) f(a) else null;
val bob : Bob = null;
- val bar = ifn(bob)(.bar);
+ val bar = ifn(bob)(_.bar);
assert(bar == null);
}
diff --git a/test/files/neg/bug846.scala b/test/files/neg/bug846.scala
index be105a71aa..acf8462030 100644
--- a/test/files/neg/bug846.scala
+++ b/test/files/neg/bug846.scala
@@ -8,6 +8,6 @@ trait Test {
def ifn[A,B](a : A)(f : A => B): B =
if (a != null) f(a) else null
val bob : Bob = null;
- val bar = ifn(bob)(.bar);
+ val bar = ifn(bob)(_.bar);
assert(bar == null);
}
diff --git a/test/files/neg/bug987.scala b/test/files/neg/bug987.scala
index dcd3ce1d07..fc66a6f874 100644
--- a/test/files/neg/bug987.scala
+++ b/test/files/neg/bug987.scala
@@ -5,7 +5,7 @@
class A {}
-trait B[T <: B[T]] requires T {}
+trait B[T <: B[T]] { self: T => }
abstract class C extends A with B[C]
{
diff --git a/test/files/neg/escapes.check b/test/files/neg/escapes.check
deleted file mode 100644
index 3c4473e6b6..0000000000
--- a/test/files/neg/escapes.check
+++ /dev/null
@@ -1,4 +0,0 @@
-escapes.scala:2: error: type t escapes its defining scope as part of type t
- def f(x: Any) = x match { case y: Cell[t] => y.elem }
- ^
-one error found
diff --git a/test/files/neg/escapes.scala b/test/files/neg/escapes.scala
deleted file mode 100644
index 3a280e8d0a..0000000000
--- a/test/files/neg/escapes.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-object Test {
- def f(x: Any) = x match { case y: Cell[t] => y.elem }
- class C3[T](val elem: T)
- class D3[T](val elemD: T) extends C3[T](elemD)
- def f[T](x: C3[T]) = x match { case d: D3[t] => d.elemD }
-}
diff --git a/test/files/neg/saito.scala b/test/files/neg/saito.scala
index a8bcc79d65..b4fcd598e4 100644
--- a/test/files/neg/saito.scala
+++ b/test/files/neg/saito.scala
@@ -1,5 +1,5 @@
class B {}
-class A requires B {
+class A { self: B =>
def m(): B = {
this
}
diff --git a/test/files/pos/bug0039.scala b/test/files/pos/bug0039.scala
index e1fc62f40f..652c606b0e 100644
--- a/test/files/pos/bug0039.scala
+++ b/test/files/pos/bug0039.scala
@@ -1,4 +1,4 @@
-abstract class Extensible[A, This <: Extensible[A, This]](x: A, xs: This) requires This {
+abstract class Extensible[A, This <: Extensible[A, This]](x: A, xs: This) { self: This =>
def mkObj(x: A, xs: This): This;
}
class Fixed[A](x: A, xs: Fixed[A]) extends Extensible[A, Fixed[A]](x, xs) {
diff --git a/test/files/pos/bug210.scala b/test/files/pos/bug210.scala
index efcad531d9..9a7ef62cd9 100644
--- a/test/files/pos/bug210.scala
+++ b/test/files/pos/bug210.scala
@@ -1,13 +1,13 @@
trait Lang1 {
trait Exp;
trait Visitor { def f(left: Exp): unit; }
- class Eval1 requires Visitor extends Visitor {
+ class Eval1 extends Visitor { self: Visitor =>
def f(left: Exp) = ();
}
}
trait Lang2 extends Lang1 {
- class Eval2 requires Visitor extends Eval1;
+ class Eval2 extends Eval1 { self: Visitor => }
}
/*
object Main with Application {
diff --git a/test/files/pos/bug211.scala b/test/files/pos/bug211.scala
index 424a396ea1..1c2c54934d 100644
--- a/test/files/pos/bug211.scala
+++ b/test/files/pos/bug211.scala
@@ -1,6 +1,6 @@
trait A;
trait B;
-class Foo requires (A with B) extends A with B;
+class Foo extends A with B { self: A with B => }
object Test extends Application {
new Foo();
Console.println("bug211 completed");
diff --git a/test/files/pos/bug267.scala b/test/files/pos/bug267.scala
index 66add083f7..92282f77a2 100644
--- a/test/files/pos/bug267.scala
+++ b/test/files/pos/bug267.scala
@@ -11,7 +11,7 @@ trait Base {
trait Exp {
def eval: int
}
- class Num(v: int) requires exp extends Exp {
+ class Num(v: int) extends Exp { self: exp =>
val value = v;
def eval = value
}
@@ -26,7 +26,7 @@ object testBase extends Application with Base {
/** Data extension: An extension of `Base' with `Plus' expressions
*/
trait BasePlus extends Base {
- class Plus(l: exp, r: exp) requires exp extends Exp {
+ class Plus(l: exp, r: exp) extends Exp { self: exp =>
val left = l;
val right = r;
def eval = left.eval + right.eval
@@ -41,7 +41,7 @@ trait Show extends Base {
trait Exp1 extends Exp {
def show: String;
}
- class Num1(v: int) requires (exp with Num1) extends Num(v) with Exp1 {
+ class Num1(v: int) extends Num(v) with Exp1 { self: exp with Num1 =>
def show = value.toString();
}
}
@@ -49,7 +49,7 @@ trait Show extends Base {
/** Operation extension: An extension of `BasePlus' with 'show' methods.
*/
trait ShowPlus extends BasePlus with Show {
- class Plus1(l: exp, r: exp) requires (exp with Plus1) extends Plus(l, r) with Exp1 {
+ class Plus1(l: exp, r: exp) extends Plus(l, r) with Exp1 { self: exp with Plus1 =>
def show = left.show + " + " + right.show
}
}
diff --git a/test/files/pos/bug360.scala b/test/files/pos/bug360.scala
index 0860eb8ee3..64a02519cc 100644
--- a/test/files/pos/bug360.scala
+++ b/test/files/pos/bug360.scala
@@ -1,9 +1,9 @@
// $Id$
-abstract class Bug360A requires Bug360C {
+abstract class Bug360A { self: Bug360C =>
def f: String = "hello";
}
-trait Bug360B requires Bug360C {
+trait Bug360B { self: Bug360C =>
object d {
Console.println(f);
}
diff --git a/test/files/pos/bug361.scala b/test/files/pos/bug361.scala
index b12097e2cb..1e490c3812 100644
--- a/test/files/pos/bug361.scala
+++ b/test/files/pos/bug361.scala
@@ -2,7 +2,7 @@
class Bug361Global extends Bug361Trees;
-abstract class Bug361Trees requires Bug361Global {
+abstract class Bug361Trees { self: Bug361Global =>
abstract class Tree {
var pos: int = 0;
diff --git a/test/files/pos/bug372.scala b/test/files/pos/bug372.scala
index 162248657b..44c248bcd1 100644
--- a/test/files/pos/bug372.scala
+++ b/test/files/pos/bug372.scala
@@ -1,4 +1,4 @@
// $Id$
class Bug372Names;
-class Bug372Symbols requires (Bug372Symbols with Bug372Names);
+class Bug372Symbols { self: Bug372Symbols with Bug372Names => }
diff --git a/test/files/pos/bug592.scala b/test/files/pos/bug592.scala
index 4d41f112ee..6a941ef51a 100644
--- a/test/files/pos/bug592.scala
+++ b/test/files/pos/bug592.scala
@@ -22,7 +22,7 @@ abstract class DirectedGraph extends Graph {
override def toString = ""+origin+" --> "+dest
}
- class NodeImpl requires Node extends NodeIntf {
+ class NodeImpl extends NodeIntf { self: Node =>
val id = ids
ids = ids + 1
def connectWith(node: Node): Edge = {
diff --git a/test/files/pos/bug780.scala b/test/files/pos/bug780.scala
index 0b4601c219..7ed6745d9f 100644
--- a/test/files/pos/bug780.scala
+++ b/test/files/pos/bug780.scala
@@ -1,2 +1,2 @@
class B extends A { protected val x = false }
-trait A requires B { x }
+trait A { self: B => x }
diff --git a/test/files/pos/pat_iuli.scala b/test/files/pos/pat_iuli.scala
index 9d5d1c4776..46356ff588 100644
--- a/test/files/pos/pat_iuli.scala
+++ b/test/files/pos/pat_iuli.scala
@@ -1,4 +1,4 @@
-trait Ops requires MyCodes {
+trait Ops { self: MyCodes =>
abstract class Instru
object opcodes {
case class SWITCH(i:Int) extends Instru
@@ -6,7 +6,7 @@ trait Ops requires MyCodes {
}
}
-trait Blox requires MyCodes {
+trait Blox { self: MyCodes =>
import opcodes._
class Basick {
var foo: Instru = null
diff --git a/test/files/pos/philippe4.scala b/test/files/pos/philippe4.scala
index c98aa2236e..9ce3691f5e 100644
--- a/test/files/pos/philippe4.scala
+++ b/test/files/pos/philippe4.scala
@@ -1,3 +1,3 @@
-trait Foo[t <: Foo[t]] requires t {
+trait Foo[t <: Foo[t]] { self: t =>
def foo(that: t): Boolean;
}
diff --git a/test/files/pos/scoping1.scala b/test/files/pos/scoping1.scala
index ee714af1b0..c72df7fa8b 100644
--- a/test/files/pos/scoping1.scala
+++ b/test/files/pos/scoping1.scala
@@ -2,7 +2,7 @@ object This extends Application {
trait A {
def foo(): unit;
}
- class C requires A {
+ class C { self: A =>
def bar() = this.foo();
}
class D extends C with A {
diff --git a/test/files/pos/scoping3.scala b/test/files/pos/scoping3.scala
index 7f45723ce2..c1a65e287f 100644
--- a/test/files/pos/scoping3.scala
+++ b/test/files/pos/scoping3.scala
@@ -15,8 +15,7 @@ object CI {
trait TreeDisplayFinal extends TreeDisplay with TreeDisplayExp {
type TreeNode <: ITreeNode with ITreeNodeExp;
}
- abstract class SimpleTreeDisplay requires TreeDisplayFinal extends
-TreeDisplay {
+ abstract class SimpleTreeDisplay extends TreeDisplay { self: TreeDisplayFinal =>
def display() = { this.getRoot().display(); }
}
}
diff --git a/test/files/pos/unapplyContexts2.scala b/test/files/pos/unapplyContexts2.scala
index fcf1e2ff62..1db8c5160f 100644
--- a/test/files/pos/unapplyContexts2.scala
+++ b/test/files/pos/unapplyContexts2.scala
@@ -2,7 +2,7 @@ trait Analyzer {
val WILDCARD = "23"
}
-trait Contexts2 requires Analyzer {
+trait Contexts2 { self: Analyzer =>
class Context {
def collect(sels: List[String]): List[String] = sels match {
case List(WILDCARD) => val dummy = WILDCARD; Nil
diff --git a/test/files/run/Course-2002-02.scala b/test/files/run/Course-2002-02.scala
index 9d8b8da389..e688850f9a 100644
--- a/test/files/run/Course-2002-02.scala
+++ b/test/files/run/Course-2002-02.scala
@@ -140,9 +140,9 @@ object M6 {
if (a > b) 0
else f(a) + sum(f)(a + 1, b);
- def sumInts = &sum(x => x)
- def sumCubes = &sum(x => x * x * x)
- def sumReciprocals = &sum(x => 1.0/x)
+ def sumInts = sum(x => x)_
+ def sumCubes = sum(x => x * x * x)_
+ def sumReciprocals = sum(x => 1.0/x)_
def sumPi = { n: Int => 4 + sum(x => 4.0/(4*x+1) - 4.0/(4*x-1))(1, n) }
Console.println(sumInts(1,4))
@@ -163,9 +163,9 @@ object M7 {
iter(a, 0)
}
- def sumInts = &sum(x => x)
- def sumCubes = &sum(x => x * x * x)
- def sumReciprocals = &sum(x => 1.0/x)
+ def sumInts = sum(x => x)_
+ def sumCubes = sum(x => x * x * x)_
+ def sumReciprocals = sum(x => 1.0/x)_
def sumPi = { n: Int => 4 + sum(x => 4.0/(4*x+1) - 4.0/(4*x-1))(1, n) }
Console.println(sumInts(1,4))
diff --git a/test/files/run/amp.scala b/test/files/run/amp.scala
index 62451b62ba..d46461ba20 100644
--- a/test/files/run/amp.scala
+++ b/test/files/run/amp.scala
@@ -2,12 +2,12 @@ object Test extends Application {
def foo() = {
def f: int = 1
- val x = &f
+ val x = f _
x
}
def bar(g: => int) = {
- &g
+ g _
}
Console.println((bar{ Console.println("g called"); 42 })())
diff --git a/test/files/run/collections.scala b/test/files/run/collections.scala
index f0a005d198..3f3bfb6b06 100644
--- a/test/files/run/collections.scala
+++ b/test/files/run/collections.scala
@@ -54,10 +54,10 @@ object Test extends Application {
var s = s0
s = s + (2 -> 2)
s = s + (3 -> 3, 4000 -> 4000, 10000 -> 10000)
- Console.println("test1: "+sum(s map (._2)))
+ Console.println("test1: "+sum(s map (_._2)))
time {
s = s ++ (List.range(0, iters) map (x => x * 2 -> x * 2))
- Console.println("test2: "+sum(s map (._2))+", iters = "+iters)
+ Console.println("test2: "+sum(s map (_._2))+", iters = "+iters)
}
time {
var x = 0
@@ -89,10 +89,10 @@ object Test extends Application {
var s = s0
s = s + (2 -> 2)
s = s + (3 -> 3, 4000 -> 4000, 10000 -> 10000)
- Console.println("test1: "+sum(s map (._2)))
+ Console.println("test1: "+sum(s map (_._2)))
time {
s = s ++ (List.range(0, iters) map (x => x * 2 -> x * 2))
- Console.println("test2: "+sum(s map (._2))+", iters = "+iters)
+ Console.println("test2: "+sum(s map (_._2))+", iters = "+iters)
}
time {
var x = 0
diff --git a/test/files/run/ctor-order.scala b/test/files/run/ctor-order.scala
index 53b580cb02..6201a4b70f 100644
--- a/test/files/run/ctor-order.scala
+++ b/test/files/run/ctor-order.scala
@@ -14,7 +14,7 @@ class Outer {
val outer = Outer.this;
}
- trait M1 requires X {
+ trait M1 { self: X =>
Console.println(global.x);
Console.println(outer.global.x);
}
diff --git a/test/files/run/imports.scala b/test/files/run/imports.scala
index d976478d8b..22e6fa9ca5 100644
--- a/test/files/run/imports.scala
+++ b/test/files/run/imports.scala
@@ -6,11 +6,11 @@
//############################################################################
object checker {
- def check(where: String, what: String, value: Any): Unit = {
- Console.print("In " + where + ", " + what + ".toString() returns ");
+ def check(location: String, what: String, value: Any): Unit = {
+ Console.print("In " + location + ", " + what + ".toString() returns ");
Console.flush;
val string: String = if (value == null) "null" else value.toString();
- val test = if (string == where) "ok" else "KO";
+ val test = if (string == location) "ok" else "KO";
Console.println(string + " -> " + test);
Console.flush;
}
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala
index 4f6649f8b6..f8216177cd 100644
--- a/test/files/run/patmatnew.scala
+++ b/test/files/run/patmatnew.scala
@@ -1,4 +1,4 @@
-trait Treez requires Shmeez {
+trait Treez { self: Shmeez =>
abstract class Tree
case class Beez(i:Int) extends Tree
case object HagbardCeline extends Tree
diff --git a/test/files/run/tuples.scala b/test/files/run/tuples.scala
index 857b166917..b03167adee 100644
--- a/test/files/run/tuples.scala
+++ b/test/files/run/tuples.scala
@@ -13,9 +13,9 @@ object Test extends Application {
def params = (2, "xxx", 3.14159) // (*****)
- tupled(&func)(params) // call the function with all the params at once
+ tupled(func _)(params) // call the function with all the params at once
func(2, "xxx", 3.14159) // the same call
- (&func).apply(2, "xxx", 3.14159) // the same call
+ (func _).apply(2, "xxx", 3.14159) // the same call
// Composing a tuple
def t = (1, "Hello", false)