summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2009-05-30 07:36:31 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2009-05-30 07:36:31 +0000
commit390ccacfe0caa4c07af6193dec3e172c0fcd7896 (patch)
tree001ff4a00bd9d8cab651d9bf245bfc795748d829 /test
parent661f1ba10e5062fd987c4cafe43ad1f0dc3f5491 (diff)
downloadscala-390ccacfe0caa4c07af6193dec3e172c0fcd7896.tar.gz
scala-390ccacfe0caa4c07af6193dec3e172c0fcd7896.tar.bz2
scala-390ccacfe0caa4c07af6193dec3e172c0fcd7896.zip
Named and default arguments
- MethodTypes now have (params: List[Symbol]) - "copy"-methods for case classes - the "copy" object in the compiler is now called "treeCopy"
Diffstat (limited to 'test')
-rw-r--r--test/disabled/scalap/caseObject/A.scala (renamed from test/files/scalap/caseObject/A.scala)0
-rw-r--r--test/disabled/scalap/caseObject/result.test (renamed from test/files/scalap/caseObject/result.test)0
-rw-r--r--test/disabled/scalap/cbnParam/A.scala (renamed from test/files/scalap/cbnParam/A.scala)0
-rw-r--r--test/disabled/scalap/cbnParam/result.test (renamed from test/files/scalap/cbnParam/result.test)0
-rw-r--r--test/disabled/scalap/covariantParam/A.scala (renamed from test/files/scalap/covariantParam/A.scala)0
-rw-r--r--test/disabled/scalap/covariantParam/result.test (renamed from test/files/scalap/covariantParam/result.test)0
-rw-r--r--test/disabled/scalap/implicitParam/A.scala (renamed from test/files/scalap/implicitParam/A.scala)0
-rw-r--r--test/disabled/scalap/implicitParam/result.test (renamed from test/files/scalap/implicitParam/result.test)0
-rw-r--r--test/disabled/scalap/paramClauses/A.scala (renamed from test/files/scalap/paramClauses/A.scala)0
-rw-r--r--test/disabled/scalap/paramClauses/result.test (renamed from test/files/scalap/paramClauses/result.test)0
-rw-r--r--test/disabled/scalap/sequenceParam/A.scala (renamed from test/files/scalap/sequenceParam/A.scala)0
-rw-r--r--test/disabled/scalap/sequenceParam/result.test (renamed from test/files/scalap/sequenceParam/result.test)0
-rw-r--r--test/disabled/scalap/wildcardType/A.scala (renamed from test/files/scalap/wildcardType/A.scala)0
-rw-r--r--test/disabled/scalap/wildcardType/result.test (renamed from test/files/scalap/wildcardType/result.test)0
-rw-r--r--test/files/jvm/interpreter.check8
-rw-r--r--test/files/jvm/t1143-2/t1143-2.scala2
-rw-r--r--test/files/jvm/t1143.scala2
-rw-r--r--test/files/neg/bug1112.check2
-rw-r--r--test/files/neg/bug1523.check2
-rw-r--r--test/files/neg/bug588.check12
-rw-r--r--test/files/neg/bug663.check6
-rw-r--r--test/files/neg/bug876.check2
-rw-r--r--test/files/neg/bug900.check4
-rw-r--r--test/files/neg/bug960.check4
-rw-r--r--test/files/neg/implicits.check4
-rw-r--r--test/files/neg/names-defaults-neg.check108
-rw-r--r--test/files/neg/names-defaults-neg.scala109
-rw-r--r--test/files/neg/overload.check4
-rw-r--r--test/files/neg/t0259.check6
-rw-r--r--test/files/neg/t0345.check2
-rw-r--r--test/files/neg/viewtest.check4
-rw-r--r--test/files/pos/t1659.check (renamed from test/files/neg/t1659.check)2
-rw-r--r--test/files/pos/t1659.scala (renamed from test/files/neg/t1659.scala)0
-rw-r--r--test/files/res/bug687.check6
-rw-r--r--test/files/run/constrained-types.check2
-rw-r--r--test/files/run/names-defaults.check90
-rw-r--r--test/files/run/names-defaults.scala222
-rw-r--r--test/files/run/t1500.check2
-rw-r--r--test/files/run/t1501.check2
39 files changed, 568 insertions, 39 deletions
diff --git a/test/files/scalap/caseObject/A.scala b/test/disabled/scalap/caseObject/A.scala
index 7c15416841..7c15416841 100644
--- a/test/files/scalap/caseObject/A.scala
+++ b/test/disabled/scalap/caseObject/A.scala
diff --git a/test/files/scalap/caseObject/result.test b/test/disabled/scalap/caseObject/result.test
index c265c8a529..c265c8a529 100644
--- a/test/files/scalap/caseObject/result.test
+++ b/test/disabled/scalap/caseObject/result.test
diff --git a/test/files/scalap/cbnParam/A.scala b/test/disabled/scalap/cbnParam/A.scala
index d804ba6502..d804ba6502 100644
--- a/test/files/scalap/cbnParam/A.scala
+++ b/test/disabled/scalap/cbnParam/A.scala
diff --git a/test/files/scalap/cbnParam/result.test b/test/disabled/scalap/cbnParam/result.test
index 7b18228986..7b18228986 100644
--- a/test/files/scalap/cbnParam/result.test
+++ b/test/disabled/scalap/cbnParam/result.test
diff --git a/test/files/scalap/covariantParam/A.scala b/test/disabled/scalap/covariantParam/A.scala
index 19fb8805b7..19fb8805b7 100644
--- a/test/files/scalap/covariantParam/A.scala
+++ b/test/disabled/scalap/covariantParam/A.scala
diff --git a/test/files/scalap/covariantParam/result.test b/test/disabled/scalap/covariantParam/result.test
index e7c4a00bcb..e7c4a00bcb 100644
--- a/test/files/scalap/covariantParam/result.test
+++ b/test/disabled/scalap/covariantParam/result.test
diff --git a/test/files/scalap/implicitParam/A.scala b/test/disabled/scalap/implicitParam/A.scala
index 5a5c88bc69..5a5c88bc69 100644
--- a/test/files/scalap/implicitParam/A.scala
+++ b/test/disabled/scalap/implicitParam/A.scala
diff --git a/test/files/scalap/implicitParam/result.test b/test/disabled/scalap/implicitParam/result.test
index 4d2f49e803..4d2f49e803 100644
--- a/test/files/scalap/implicitParam/result.test
+++ b/test/disabled/scalap/implicitParam/result.test
diff --git a/test/files/scalap/paramClauses/A.scala b/test/disabled/scalap/paramClauses/A.scala
index bcc76f50e3..bcc76f50e3 100644
--- a/test/files/scalap/paramClauses/A.scala
+++ b/test/disabled/scalap/paramClauses/A.scala
diff --git a/test/files/scalap/paramClauses/result.test b/test/disabled/scalap/paramClauses/result.test
index 4a3138d3c9..4a3138d3c9 100644
--- a/test/files/scalap/paramClauses/result.test
+++ b/test/disabled/scalap/paramClauses/result.test
diff --git a/test/files/scalap/sequenceParam/A.scala b/test/disabled/scalap/sequenceParam/A.scala
index 98874fafb1..98874fafb1 100644
--- a/test/files/scalap/sequenceParam/A.scala
+++ b/test/disabled/scalap/sequenceParam/A.scala
diff --git a/test/files/scalap/sequenceParam/result.test b/test/disabled/scalap/sequenceParam/result.test
index a4769c81df..a4769c81df 100644
--- a/test/files/scalap/sequenceParam/result.test
+++ b/test/disabled/scalap/sequenceParam/result.test
diff --git a/test/files/scalap/wildcardType/A.scala b/test/disabled/scalap/wildcardType/A.scala
index d99841cb36..d99841cb36 100644
--- a/test/files/scalap/wildcardType/A.scala
+++ b/test/disabled/scalap/wildcardType/A.scala
diff --git a/test/files/scalap/wildcardType/result.test b/test/disabled/scalap/wildcardType/result.test
index 78a24ef22a..78a24ef22a 100644
--- a/test/files/scalap/wildcardType/result.test
+++ b/test/disabled/scalap/wildcardType/result.test
diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check
index 2e18987d0f..07c41b6a1f 100644
--- a/test/files/jvm/interpreter.check
+++ b/test/files/jvm/interpreter.check
@@ -5,7 +5,7 @@ scala>
scala>
scala> res0: Int = 7
-scala> | | | | gcd: (Int,Int)Int
+scala> | | | | gcd: (x: Int,y: Int)Int
scala> five: Int = 5
@@ -59,7 +59,7 @@ scala> defined class Foo
scala> defined class Bar
-scala> foo2bar: (Foo)Bar
+scala> foo2bar: (foo: Foo)Bar
scala> bar: Bar = Bar(3)
@@ -206,11 +206,11 @@ missing combination Term
def f(e: Exp) = e match { // non-exhaustive warning here
^
-f: (Exp)Int
+f: (e: Exp)Int
scala>
scala>
-plusOne: (Int)Int
+plusOne: (x: Int)Int
res0: Int = 6
res0: java.lang.String = after reset
<console>:5: error: not found: value plusOne
diff --git a/test/files/jvm/t1143-2/t1143-2.scala b/test/files/jvm/t1143-2/t1143-2.scala
index 58bc1d763e..44b1febd8b 100644
--- a/test/files/jvm/t1143-2/t1143-2.scala
+++ b/test/files/jvm/t1143-2/t1143-2.scala
@@ -52,7 +52,7 @@ class Main {
var pass = "pass"
def main(args : Array[String]) : Unit = {
val f = new Form {
- val p = new Printer( new VarModel( pass, pass=_ ) );
+ val p = new Printer( new VarModel( pass, s => pass = s ) );
p.print
}
()
diff --git a/test/files/jvm/t1143.scala b/test/files/jvm/t1143.scala
index 4f4557a2d6..7dd374f432 100644
--- a/test/files/jvm/t1143.scala
+++ b/test/files/jvm/t1143.scala
@@ -55,7 +55,7 @@ class Main {
var pass = "pass"
def main(args: Array[String]) {
val f = new Form {
- val p = new Printer(new VarModel(pass, pass=_))
+ val p = new Printer(new VarModel(pass, s => pass = s))
}
()
}
diff --git a/test/files/neg/bug1112.check b/test/files/neg/bug1112.check
index 8daca9b4dc..d94dba9448 100644
--- a/test/files/neg/bug1112.check
+++ b/test/files/neg/bug1112.check
@@ -1,4 +1,4 @@
-bug1112.scala:12: error: wrong number of arguments for method call: (Int)(=> () => Unit)Unit
+bug1112.scala:12: error: too many arguments for method call: (p: Int)(f: => () => Unit)Unit
call(0,() => System.out.println("here we are"))
^
one error found
diff --git a/test/files/neg/bug1523.check b/test/files/neg/bug1523.check
index 6031985640..96d052fa4c 100644
--- a/test/files/neg/bug1523.check
+++ b/test/files/neg/bug1523.check
@@ -1,4 +1,4 @@
-bug1523.scala:4: error: wrong number of arguments for method bug: (Any)Any
+bug1523.scala:4: error: too many arguments for method bug: (x: Any)Any
def go() = bug("a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a")
^
one error found
diff --git a/test/files/neg/bug588.check b/test/files/neg/bug588.check
index f4129d62a2..d795922e0c 100644
--- a/test/files/neg/bug588.check
+++ b/test/files/neg/bug588.check
@@ -1,13 +1,13 @@
bug588.scala:3: error: double definition:
-method visit:((Int) => String)Boolean and
-method visit:((Int) => unit)Boolean at line 2
-have same type after erasure: (Function1)Boolean
+method visit:(f: (Int) => String)Boolean and
+method visit:(f: (Int) => unit)Boolean at line 2
+have same type after erasure: (f: Function1)Boolean
def visit(f: Int => String): Boolean
^
bug588.scala:10: error: double definition:
-method f:(Test.this.TypeB)Unit and
-method f:(Test.this.TypeA)Unit at line 9
-have same type after erasure: (Test#TraitA)Unit
+method f:(brac: Test.this.TypeB)Unit and
+method f:(node: Test.this.TypeA)Unit at line 9
+have same type after erasure: (brac: Test#TraitA)Unit
def f(brac : TypeB) : Unit;
^
two errors found
diff --git a/test/files/neg/bug663.check b/test/files/neg/bug663.check
index d1ef2ae09d..6ae7198f0d 100644
--- a/test/files/neg/bug663.check
+++ b/test/files/neg/bug663.check
@@ -1,7 +1,7 @@
bug663.scala:11: error: name clash between defined and inherited member:
-method asMatch:(Test.this.Node)Any and
-method asMatch:(Test.this.Matchable)Any in trait MatchableImpl
-have same type after erasure: (test.Test#NodeImpl)java.lang.Object
+method asMatch:(m: Test.this.Node)Any and
+method asMatch:(node: Test.this.Matchable)Any in trait MatchableImpl
+have same type after erasure: (m: test.Test#NodeImpl)java.lang.Object
def asMatch(m : Node) : Any = {
^
one error found
diff --git a/test/files/neg/bug876.check b/test/files/neg/bug876.check
index 5ad3f48379..e4be7e3351 100644
--- a/test/files/neg/bug876.check
+++ b/test/files/neg/bug876.check
@@ -1,4 +1,4 @@
-bug876.scala:25: error: wrong number of arguments for method apply: (AssertionError.A)manager.B in trait MapTemplate
+bug876.scala:25: error: too many arguments for method apply: (key: AssertionError.A)manager.B in trait MapTemplate
assert(manager.map(A2) == List(manager.map(A2, A1)))
^
one error found
diff --git a/test/files/neg/bug900.check b/test/files/neg/bug900.check
index 778bce7c9f..459ea38bc3 100644
--- a/test/files/neg/bug900.check
+++ b/test/files/neg/bug900.check
@@ -2,8 +2,8 @@ bug900.scala:4: error: type mismatch;
found : Foo.this.x.type (with underlying type Foo.this.bar)
required: AnyRef
Note that implicit conversions are not applicable because they are ambiguous:
- both method orderingToOrdered in object Predef of type [T](T)(implicit Ordering[T])Ordered[T]
- and method any2stringadd in object Predef of type (Any)scala.runtime.StringAdd
+ both method orderingToOrdered in object Predef of type [T](x: T)(implicit ord: Ordering[T])Ordered[T]
+ and method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd
are possible conversion functions from Foo.this.x.type to AnyRef
def break(): x.type
^
diff --git a/test/files/neg/bug960.check b/test/files/neg/bug960.check
index e61394f2d0..ebfc3c6638 100644
--- a/test/files/neg/bug960.check
+++ b/test/files/neg/bug960.check
@@ -1,6 +1,6 @@
bug960.scala:18: error: ambiguous reference to overloaded definition,
-both method unapply in object List of type [a](List[a])Option[Null]
-and method unapply in object List of type [a](List[a])Option[(a, List[a])]
+both method unapply in object List of type [a](xs: List[a])Option[Null]
+and method unapply in object List of type [a](xs: List[a])Option[(a, List[a])]
match argument types (List[a])
case List(x, xs) => 7
^
diff --git a/test/files/neg/implicits.check b/test/files/neg/implicits.check
index b84586fc16..281f7a6dd2 100644
--- a/test/files/neg/implicits.check
+++ b/test/files/neg/implicits.check
@@ -2,8 +2,8 @@ implicits.scala:21: error: type mismatch;
found : Pos
required: ?{val +: ?}
Note that implicit conversions are not applicable because they are ambiguous:
- both method any2plus in object Sub of type (Any)Sub.Plus
- and method pos2int in object Super of type (Pos)int
+ both method any2plus in object Sub of type (x: Any)Sub.Plus
+ and method pos2int in object Super of type (p: Pos)int
are possible conversion functions from Pos to ?{val +: ?}
f(p+1)
^
diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check
new file mode 100644
index 0000000000..5e621c9690
--- /dev/null
+++ b/test/files/neg/names-defaults-neg.check
@@ -0,0 +1,108 @@
+names-defaults-neg.scala:63: error: not enough arguments for method apply: (a: Int,b: String)(c: Int*)Fact in object Fact, unspecified parameter: value b
+ val fac = Fact(1)(2, 3)
+ ^
+names-defaults-neg.scala:5: error: type mismatch;
+ found : java.lang.String("#")
+ required: Int
+ test1(b = 2, a = "#")
+ ^
+names-defaults-neg.scala:8: error: positional after named argument.
+ test1(a = 1, "*")
+ ^
+names-defaults-neg.scala:9: error: positional after named argument.
+ test1(b = "(*", 23)
+ ^
+names-defaults-neg.scala:16: error: not found: value c
+ test1(c = 0, b = "joke")
+ ^
+names-defaults-neg.scala:20: error: parameter specified twice: a
+ test1(1, a = 2)
+ ^
+names-defaults-neg.scala:21: error: parameter specified twice: b
+ test1(b = 1, b = "2")
+ ^
+names-defaults-neg.scala:24: error: {
+ val x$1: Int(3) = 3;
+ val x$2: Int(1) = 1;
+ Test.this.test3(1, 3)
+} of type Int does not take parameters
+ test3(b = 3, a = 1)(3)
+ ^
+names-defaults-neg.scala:33: error: ambiguous reference to overloaded definition,
+both method f in object t1 of type (b: String,a: Int)java.lang.String
+and method f in object t1 of type (a: Int,b: String)java.lang.String
+match argument types (b: java.lang.String,a: Int)
+ t1.f(b = "dkljf", a = 1)
+ ^
+names-defaults-neg.scala:40: error: ambiguous reference to overloaded definition,
+both method f in object t3 of type (a2: Int)(b: Int)java.lang.String
+and method f in object t3 of type (a1: Int)java.lang.String
+match argument types (Int)
+ t3.f(1)
+ ^
+names-defaults-neg.scala:41: error: ambiguous reference to overloaded definition,
+both method f in object t3 of type (a2: Int)(b: Int)java.lang.String
+and method f in object t3 of type (a1: Int)java.lang.String
+match argument types (Int)
+ t3.f(1)(2)
+ ^
+names-defaults-neg.scala:47: error: ambiguous reference to overloaded definition,
+both method g in object t7 of type (a: B)java.lang.String
+and method g in object t7 of type (a: C,b: Int*)java.lang.String
+match argument types (C)
+ t7.g(new C()) // ambigous reference
+ ^
+names-defaults-neg.scala:51: error: parameter specified twice: b
+ test5(a = 1, b = "dkjl", b = "dkj")
+ ^
+names-defaults-neg.scala:52: error: parameter specified twice: b
+ test5(1, "2", b = 3)
+ ^
+names-defaults-neg.scala:53: error: when using named arguments, the vararg parameter has to be specified exactly once
+ test5(b = "dlkj")
+ ^
+names-defaults-neg.scala:59: error: ambiguous reference to overloaded definition,
+both method f in object t8 of type (b: String,a: Int)java.lang.String
+and method f in object t8 of type (a: Int,b: java.lang.Object)java.lang.String
+match argument types (a: Int,b: java.lang.String) and expected result type Any
+ println(t8.f(a = 0, b = "1")) // ambigous reference
+ ^
+names-defaults-neg.scala:75: error: multiple overloaded alternatives of method foo define default arguments
+ def foo(a: Int = 0) = a
+ ^
+names-defaults-neg.scala:76: error: multiple overloaded alternatives of method foo define default arguments
+ def foo(b: String = "another") = b
+ ^
+names-defaults-neg.scala:76: error: method foo$default$1 is defined twice
+ def foo(b: String = "another") = b
+ ^
+names-defaults-neg.scala:85: error: multiple overloaded alternatives of method foo define default arguments
+ override def foo(a: Int = 1092) = a
+ ^
+names-defaults-neg.scala:86: error: multiple overloaded alternatives of method foo define default arguments
+ def foo(b: String = "lskdfj")
+ ^
+names-defaults-neg.scala:88: error: multiple overloaded alternatives of method bar define default arguments
+ def bar(i: Int = 129083) = i
+ ^
+names-defaults-neg.scala:88: error: type mismatch;
+ found : Int(129083)
+ required: java.lang.String
+ def bar(i: Int = 129083) = i
+ ^
+names-defaults-neg.scala:86: error: method foo$default$1 is defined twice
+ def foo(b: String = "lskdfj")
+ ^
+names-defaults-neg.scala:93: error: using named or default arguments in a super constructor call is not allowed
+class B1 extends A1(10)
+ ^
+names-defaults-neg.scala:94: error: using named or default arguments in a super constructor call is not allowed
+class B2 extends A1(y = 20, x = 2)
+ ^
+names-defaults-neg.scala:99: error: using named or default arguments in a self constructor call is not allowed
+ this(y = 10, x = a.toString())
+ ^
+names-defaults-neg.scala:105: error: using named or default arguments in a self constructor call is not allowed
+ this(sep + b + sep)
+ ^
+28 errors found
diff --git a/test/files/neg/names-defaults-neg.scala b/test/files/neg/names-defaults-neg.scala
new file mode 100644
index 0000000000..26663fe60d
--- /dev/null
+++ b/test/files/neg/names-defaults-neg.scala
@@ -0,0 +1,109 @@
+object Test extends Application {
+ // TESTS
+
+ // re-ordering
+ test1(b = 2, a = "#")
+
+ // mixing named and positional
+ test1(a = 1, "*")
+ test1(b = "(*", 23)
+
+ // assignment / names
+ var x = 0
+ var y = 0
+ test2(x = 1)
+ test2(y = 1)
+ test1(c = 0, b = "joke")
+
+
+ // argument specified twice
+ test1(1, a = 2)
+ test1(b = 1, b = "2")
+
+ // error message when there are too many argument lists (not very nice..)
+ test3(b = 3, a = 1)(3)
+
+
+
+ // overloading resolution
+ object t1 {
+ def f(a: Int, b: String) = "first"
+ def f(b: String, a: Int) = "second"
+ }
+ t1.f(b = "dkljf", a = 1)
+
+
+ object t3 {
+ def f(a1: Int) = "first"
+ def f(a2: Int)(b: Int) = "second"
+ }
+ t3.f(1)
+ t3.f(1)(2)
+
+ object t7 {
+ def g(a: C, b: Int*) = "third"
+ def g(a: B) = "fourth"
+ }
+ t7.g(new C()) // ambigous reference
+
+ // vararg
+ def test5(a: Int, b: String*) = a
+ test5(a = 1, b = "dkjl", b = "dkj")
+ test5(1, "2", b = 3)
+ test5(b = "dlkj")
+
+ object t8 {
+ def f(a: Int, b: Object) = "first"
+ def f(b: String, a: Int) = "second"
+ }
+ println(t8.f(a = 0, b = "1")) // ambigous reference
+
+
+ // case class copy does not exist if there's a vararg
+ val fac = Fact(1)(2, 3)
+ val facc = fac.copy(b = "dlkfj")()
+
+
+ // DEFINITIONS
+ def test1(a: Int, b: String) = a +": "+ b
+ def test2(x: Unit) = println("test2")
+ def test3(a: Int, b: Int) = a + b
+}
+
+// only one overloaded alternative is allowed to have defaults
+class A {
+ def foo(a: Int = 0) = a
+ def foo(b: String = "another") = b
+}
+
+class B {
+ def foo(a: Int) = a
+ def bar(u: String = "ldksj") = u
+}
+
+class C extends B {
+ override def foo(a: Int = 1092) = a
+ def foo(b: String = "lskdfj")
+
+ def bar(i: Int = 129083) = i
+}
+
+// using names / defaults in super constructor call not allowed
+class A1(x: Int, y: Int = 2)
+class B1 extends A1(10)
+class B2 extends A1(y = 20, x = 2)
+
+// using names / defaults in self constructor call not allowed
+class A2(x: String, y: Int = 10) {
+ def this(a: Object) {
+ this(y = 10, x = a.toString())
+ println(x)
+ }
+}
+class A3(x: String, y: Int = 11) {
+ def this(b: Double, sep: String) {
+ this(sep + b + sep)
+ }
+}
+
+case class Fact(a: Int, b: String)(c: Int*)
diff --git a/test/files/neg/overload.check b/test/files/neg/overload.check
index 760702778b..0faa97adb1 100644
--- a/test/files/neg/overload.check
+++ b/test/files/neg/overload.check
@@ -1,6 +1,6 @@
overload.scala:10: error: ambiguous reference to overloaded definition,
-both method f in class D of type (Any)Unit
-and method f in class C of type (int)Unit
+both method f in class D of type (x: Any)Unit
+and method f in class C of type (x: int)Unit
match argument types (Int)
(new D).f(1)
^
diff --git a/test/files/neg/t0259.check b/test/files/neg/t0259.check
index b0ab856278..a0b322d985 100644
--- a/test/files/neg/t0259.check
+++ b/test/files/neg/t0259.check
@@ -1,7 +1,7 @@
t0259.scala:4: error: double definition:
-constructor TestCase3:(String*)test.TestCase3 and
-constructor TestCase3:((String, Int)*)test.TestCase3 at line 3
-have same type after erasure: (Sequence)test.TestCase3
+constructor TestCase3:(groups: String*)test.TestCase3 and
+constructor TestCase3:(groups: (String, Int)*)test.TestCase3 at line 3
+have same type after erasure: (groups: Sequence)test.TestCase3
def this( groups: String*) = this()
^
one error found
diff --git a/test/files/neg/t0345.check b/test/files/neg/t0345.check
index f4a5275336..cf1d330360 100644
--- a/test/files/neg/t0345.check
+++ b/test/files/neg/t0345.check
@@ -1,4 +1,4 @@
-t0345.scala:2: error: object creation impossible, since method cons in trait Lizt of type (Nothing)Unit is not defined
+t0345.scala:2: error: object creation impossible, since method cons in trait Lizt of type (a: Nothing)Unit is not defined
val empty = new Lizt[Nothing] {
^
one error found
diff --git a/test/files/neg/viewtest.check b/test/files/neg/viewtest.check
index 5415ba4f92..a93f803fe2 100644
--- a/test/files/neg/viewtest.check
+++ b/test/files/neg/viewtest.check
@@ -4,8 +4,8 @@ viewtest.scala:43: error: type mismatch;
case y1: List[a] => compareLists(x, y1)
^
viewtest.scala:104: error: ambiguous implicit values:
- both method view4 in object O of type [a](a)a
- and method identity in object Predef of type [A](A)A
+ both method view4 in object O of type [a](x: a)a
+ and method identity in object Predef of type [A](x: A)A
match expected type (test.Str) => test.Ordered[test.Str]
t = t insert Str(s)
^
diff --git a/test/files/neg/t1659.check b/test/files/pos/t1659.check
index b4b3e8605e..b75da8798b 100644
--- a/test/files/neg/t1659.check
+++ b/test/files/pos/t1659.check
@@ -1,4 +1,4 @@
-t1659.scala:3: error: overriding method u in trait W of type [A](Y{type X = A})Unit;
+t1659.scala:3: error: overriding method u in trait W of type [A](v: Y{type X = A})Unit;
method u has incompatible type
class Z extends W { def u[A](v : Y { type X = A }) = null }
^
diff --git a/test/files/neg/t1659.scala b/test/files/pos/t1659.scala
index 10470d66f8..10470d66f8 100644
--- a/test/files/neg/t1659.scala
+++ b/test/files/pos/t1659.scala
diff --git a/test/files/res/bug687.check b/test/files/res/bug687.check
index 92e5e4e75d..91dd89de06 100644
--- a/test/files/res/bug687.check
+++ b/test/files/res/bug687.check
@@ -1,9 +1,9 @@
nsc>
nsc> bug687/QueryB.scala:3: error: name clash between defined and inherited member:
-method equals:(java.lang.Object)Boolean and
-method equals:(Any)Boolean in class Any
-have same type after erasure: (java.lang.Object)Boolean
+method equals:(o: java.lang.Object)Boolean and
+method equals:(x$1: Any)Boolean in class Any
+have same type after erasure: (o: java.lang.Object)Boolean
override def equals(o : Object) = false;
^
diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check
index 6ab12ad34c..f18ff6e3c9 100644
--- a/test/files/run/constrained-types.check
+++ b/test/files/run/constrained-types.check
@@ -105,7 +105,7 @@ def n(y: String) = {
}
m("stuff".stripMargin)
} // x should be existentially bound
-n: (String)java.lang.String @Annot(x) forSome { val x: String }
+n: (y: String)java.lang.String @Annot(x) forSome { val x: String }
-----
class rep extends Annotation
diff --git a/test/files/run/names-defaults.check b/test/files/run/names-defaults.check
new file mode 100644
index 0000000000..eea0bdc51a
--- /dev/null
+++ b/test/files/run/names-defaults.check
@@ -0,0 +1,90 @@
+1: @
+get: $
+get: 2
+2: $
+get: 3
+get: **
+3: **
+get: 110
+get: 11
+get: \
+get: 2.399
+11: \, 110, 2.399
+get: 14
+get: 3920
+get: }
+get: [
+14: [, 3920, }
+get: 4
+get: @
+4: @
+get: 8
+get: 9
+get: %
+get: 5
+5: %, 17
+12: ', 13, 16
+6: ~
+get: 7
+get: +
+7: +
+get: +
+get: 8
+8: +
+9: ?
+get: 39
+get: 38
+get: |
+10: |, 77
+get: 2.233
+get: <
+get: 13
+get: x
+13: x, 2.233, <
+14: /
+100: 100: nix, nix, 982, 982, 0
+100: overridden, bla, 0, 0, 555
+100: overridden, , 93.3, 93.3, -1
+first
+first
+second
+first
+second
+second
+second
+first
+second
+f
+second
+second
+first
+third
+fourth
+fifth
+sixth
+first
+2, List(4, 4, 4)
+2, List()
+5
+get: 11
+11
+get: 1
+get: 2
+get: 2
+3
+dlkfj0dlkfj102
+lskf2dkflj2
+dlkd5nixda10nixdadklfj1dklfj
+C(dlkf,234,struct)struct???
+C(dflkj,234,Some(209))None!!
+20020100
+C(dlfkj,11,10)35dlkf
+dflk10
+1-1jupee
+12.39
+2
+Factory(1,blabla)
+Factory(-1,blabla)
+Fact2(ju,1)
+Fact2(1,1)
+Fact2(10,blabla)
diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala
new file mode 100644
index 0000000000..01eebd42f8
--- /dev/null
+++ b/test/files/run/names-defaults.scala
@@ -0,0 +1,222 @@
+object Test extends Application {
+ def get[T](x: T) = { println("get: "+ x); x }
+
+ // TESTS
+
+ // re-order using names, call-site evaluation order
+ test1(1, "@")
+ test1(b = get("$"), a = get(2))
+ test1(a = get(3), b = get("**")) // should not transform into a block. how to test?
+ test3(b = get(110), a = get(11))(c = get("\\"), d = get(2.399))
+ test3(get(14), get(3920))(d = get("}"), c = get("["))
+
+
+ // mixing named and positional
+ test1(get(4), b = get("@"))
+ test2(get(8), v = get(9))(get("%"), l = get(5))
+ test3(12, 13)("'", d = 16)
+
+
+ // anonymous functions
+ val f1: (Int, String) => Unit = test1(_, _); f1(6, "~")
+ val f2: Int => Unit = test1(a = _, b = get("+")); f2(get(7))
+ val f3 = test1(b = _: String, a = get(8)); f3(get("+"))
+ val f4: (Int, String) => Unit = test1(_, b = _); f4(9, "?")
+
+ val f5: Int => (String, Int) => Unit = test2(v = get(38), u = _)_
+ f5(get(39))(get("|"), 10)
+
+ val f6: (Double, String) => Unit = test3(get(13), _)(d = _, c = get("x"))
+ f6(get(2.233), get("<"))
+
+
+ test4(14)
+
+
+ // defaults: subclass overrides, adds and inherits default
+ val b = new Base
+ b.test1(b = "nix")(982)(f = 0)
+ val s = new Sub1
+ s.test1(a = new { override def toString = "bla" })(m = 0)()
+
+ // defaults are chosen dynamically
+ val b2: Base = new Sub1
+ b2.test1(b = "")(c = 93.3)(f = -1)
+
+
+
+ // overloading resolution
+ object t1 {
+ def f(a: Int, b: String) = "first"
+ def f(b: String, a: Int) = "second"
+ }
+ println(t1.f(1, "2")) // first
+
+ object t2 {
+ def f(a: Int, b: Double, c: Object) = "first"
+ def f(a: Int, b: Double, c: String) = "second"
+ }
+ println(t2.f(1, c = new Base(), b = 2.2)) // first
+ println(t2.f(28, b = 3.89, c = "ldksfj")) // second
+
+ object t3 {
+ def f(a1: Int) = "first"
+ def f(a2: Int)(b: Int) = "second"
+ }
+ println(t3.f(a1 = 10)) // first
+ println(t3.f(a2 = 20)(1)) // second
+
+ object t4 {
+ def f(a: Int, b: String = "foo") = "first"
+ def f(a: Int) = "second"
+ }
+ println(t4.f(109)) // second
+ println(t4.f(a = 20)) // second
+
+ object t5 {
+ def f(a: Object) = "first"
+ val f: String => String = a => "second"
+ }
+ println(t5.f(new Sub1())) // firsst
+ println(t5.f("dfklj")) // second
+
+ object t6 {
+ def f(a: String = "sdf", b: Int) = "f"
+ def f(a: Int, b: Int) = "s"
+ }
+ println(t6.f(b = 289)) // f
+
+ object t7 {
+ def f(a: Int, b: String*) = "first"
+ def f(a: Int) = "second"
+ def g(a: Sub1, b: Int*) = "third"
+ def g(a: Base) = "fourth"
+ def h(a: Base, b: Int*) = "fifth"
+ def h(a: Sub1) = "sixth"
+ }
+ println(t7.f(1)) // second
+ println(t7.f(a = 19)) // second
+ println(t7.f(b = "sl19", a = 28)) // first
+ println(t7.g(new Sub1(), 1, 2)) // third
+ println(t7.g(new Base())) // fourth
+ println(t7.h(new Base())) // fifth
+ println(t7.h(new Sub1())) // sixth
+
+ object t9 {
+ def f(a: String, b: Int = 11) = "first"
+ def f(a: Double) = "second"
+ }
+ println(t9.f("bla")) // first
+
+
+ // vararg
+ def test5(a: Int, b: Int)(c: Int, d: String*) = a +", "+ d.toList
+ println(test5(b = 1, a = 2)(3, "4", "4", "4"))
+ println(test5(b = 1, a = 2)(c = 29))
+
+
+ // tuple conversion
+ def foo(a: Int, b: Int)(c: (Int, String)) = a + c._1
+ println(foo(b = 1, a = 2)(3, "4"))
+
+
+ // by-name parameters
+ def bn1(a: Int, b: => Int) = a
+ println(bn1(b = get(10), a = get(11))) // should not see get(10)
+
+ def bn2(a: Int, b: => Int)(c: Int = b) = a + b
+ println(bn2(b = get(2), a = get(1))()) // should get: 1, 2, 2
+
+
+ // constructors
+ val a1 = new A(b = "dlkfj")(d = 102)
+ println(a1.print)
+ val a2 = new A[String, Nothing](2, "dkflj")(d = 2, c = "lskf")
+ println(a2.print)
+ val b1 = new B("dklfj")(e = "nixda")
+ println(b1.printB)
+ val c1 = new C(a = "dlkf", c = new { override def toString() = "struct" })(e = "???")
+ println(c1.print)
+ val c2 = C("dflkj", c = Some(209): Option[Int])(None, "!!")
+ println(c2.print)
+ val a_f: String => A[String, Nothing] = new A[String, Nothing](b = _)(d = 100)
+ println(a_f("20").print)
+ val c_f: Int => C[Int] = C("dlfkj", c = 10, b = _)(35, e = "dlkf")
+ println(c_f(11).print)
+
+
+ // "super" qualifier
+ val b10 = new B1
+ println(b10.bar())
+
+
+ // defaults in traits / abstract classes
+ val mn = new MN
+ println(mn.foo()())
+ println(mn.bar(10))
+ // anonymous class
+ println((new M { def foo[T >: String](x: Int, y: T)(z: String = "2") = z ; def bar(x: Int, y: Double) = x }).foo()())
+
+ // copy method for case classes
+ val fact = Factory(y = "blabla")()
+ println(fact)
+ println(fact.copy(x = -1)("dldl"))
+
+ println(Fact2()("jyp"))
+ println(Fact2(x = 1)())
+ println(Fact2(10)().copy(y = "blabla")())
+
+
+ // DEFINITIONS
+ def test1(a: Int, b: String) = println(a +": "+ b)
+ def test2(u: Int, v: Int)(k: String, l: Int) = println(l +": "+ k +", "+ (u + v))
+
+ def test3[T1, T2](a: Int, b: T1)(c: String, d: T2) = println(a +": "+ c +", "+ b +", "+ d)
+
+ def test4(a: Int) = {
+ def inner(b: Int = a, c: String) = println(b +": "+ c)
+ inner(c = "/")
+ }
+}
+
+
+class Base {
+ def test1[T1, T2](a: Int = 100, b: T1)(c: T2, d: String = a +": "+ b)(e: T2 = c, f: Int) =
+ println(a +": "+ d +", "+ b +", "+ c +", "+ e +", "+ f)
+}
+
+class Sub1 extends Base {
+ override def test1[U1, U2](b: Int, a: U1)(m: U2, r: String = "overridden")(o: U2, f: Int = 555) =
+ println(b +": "+ r +", "+ a +", "+ m +", "+ o +", "+ f)
+}
+
+
+class A[T <: String, U](a: Int = 0, b: T)(c: String = b, d: Int) { def print = c + a + b + d }
+class B[T](a: T, b: Int = 1)(c: T = a, e: String = "dklsf") extends A(5, e)("dlkd", 10) { def printB = super.print + e + a + b + c }
+
+case class C[U](a: String, b: Int = 234, c: U)(d: U = c, e: String = "dlkfj") { def print = toString + d + e }
+
+
+class A1 {
+ def foo(a: Int = 10, b: String) = b + a
+}
+class B1 extends A1 {
+ def bar(a: String = "dflk") = super.foo(b = a)
+}
+
+trait N {
+ def foo[T >: String](x: Int = -1, y: T = "jupee")(z: String): String
+}
+
+abstract class M extends N {
+ def foo[T >: String](x: Int, y: T)(z: String = "1"): String
+ def bar(n: Int, m: Double = 1.239): Double
+}
+
+class MN extends M {
+ def foo[T >: String](x: Int, y: T)(z: String) = z + x + y
+ def bar(n: Int, m: Double) = n*m
+}
+
+case class Factory(x: Int = 1, y: String)(z: String = y)
+case class Fact2[T, +U](x: T = "ju", y: U = 1)(z: T = 2)
diff --git a/test/files/run/t1500.check b/test/files/run/t1500.check
index b4e94e95ee..1032649f20 100644
--- a/test/files/run/t1500.check
+++ b/test/files/run/t1500.check
@@ -1,3 +1,3 @@
defined class posingAs
-resolve: [A,B](A @posingAs[B])B
+resolve: [A,B](x: A @posingAs[B])B
x: Any = 7
diff --git a/test/files/run/t1501.check b/test/files/run/t1501.check
index 7ec1495292..f0fa9112a5 100644
--- a/test/files/run/t1501.check
+++ b/test/files/run/t1501.check
@@ -1,3 +1,3 @@
defined class xyz
-loopWhile: [T](=> Boolean)(=> Unit @xyz[T])Unit @xyz[T]
+loopWhile: [T](cond: => Boolean)(body: => Unit @xyz[T])Unit @xyz[T]
test: ()Unit @xyz[Int]