Skip to content

Commit 1802077

Browse files
committed
Unwind progressive "too many args" message
1 parent 2beea80 commit 1802077

File tree

12 files changed

+34
-42
lines changed

12 files changed

+34
-42
lines changed

src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -622,16 +622,8 @@ trait ContextErrors {
622622
case (c @ Literal(Constant(()))) :: Nil if c.hasAttachment[SyntheticUnitAttachment.type] =>
623623
s"can't supply unit value with infix notation because nullary $target takes no arguments; use dotted invocation instead: ${show(treeCopy.Apply(tree, fun, Nil))}"
624624
case _ => s"no arguments allowed for nullary $target"
625-
}
626-
else if (excess < 3 && expected <= 5) s"too many arguments ($supplied) for $target"
627-
else if (expected > 10) s"$supplied arguments but expected $expected for $target"
628-
else {
629-
val more =
630-
if (excess == 1) "one more argument"
631-
else if (excess > 0) s"$excess more arguments"
632-
else "too many arguments"
633-
s"$more than can be applied to $target"
634-
}
625+
} else
626+
s"too many arguments ($supplied, expected $expected) for $target"
635627
}
636628
val unknowns = (namelessArgs zip args) collect {
637629
case (_: Assign, NamedArg(Ident(name), _)) => name

test/files/neg/eta-expand-star.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
eta-expand-star.scala:6: error: too many arguments (2) for method apply: (v1: Seq[T]): Unit in trait Function1
1+
eta-expand-star.scala:6: error: too many arguments (2, expected 1) for method apply: (v1: Seq[T]): Unit in trait Function1
22
g(1, 2)
33
^
44
1 error

test/files/neg/macro-invalidusage-badargs.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Macros_Test_2.scala:9: error: not enough arguments for macro method foo: (x: Int
1313
Unspecified value parameter x.
1414
foo()
1515
^
16-
Macros_Test_2.scala:10: error: too many arguments (2) for macro method foo: (x: Int): Int
16+
Macros_Test_2.scala:10: error: too many arguments (2, expected 1) for macro method foo: (x: Int): Int
1717
foo(4, 2)
1818
^
1919
5 errors

test/files/neg/multi-array.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
multi-array.scala:9: error: too many arguments (2) for constructor Array: (_length: Int): Array[T]
1+
multi-array.scala:9: error: too many arguments (2, expected 1) for constructor Array: (_length: Int): Array[T]
22
val a: Array[Int] = new Array(10, 10)
33
^
44
1 error

test/files/neg/t10207.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
t10207.scala:14: error: too many arguments (2) for method apply: (key: Int): scala.collection.mutable.ArrayBuffer[String] in trait MapOps
1+
t10207.scala:14: error: too many arguments (2, expected 1) for method apply: (key: Int): scala.collection.mutable.ArrayBuffer[String] in trait MapOps
22
m(1, (_ => empty)) ++= AB("eins", "uno")
33
^
44
1 error

test/files/neg/t1112.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
t1112.scala:12: error: too many arguments (2) for method call: (p: Int)(f: => Test.this.Type1): Unit
1+
t1112.scala:12: error: too many arguments (2, expected 1) for method call: (p: Int)(f: => Test.this.Type1): Unit
22
call(0,() => System.out.println("here we are"))
33
^
44
1 error

test/files/neg/t1523.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
t1523.scala:4: error: 25 more arguments than can be applied to method bug: (x: Any): Any
1+
t1523.scala:4: error: too many arguments (26, expected 1) for method bug: (x: Any): Any
22
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")
33
^
44
1 error

test/files/neg/t6920.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
t6920.scala:9: error: too many arguments (2) for method applyDynamicNamed: (values: Seq[(String, Any)]): String
1+
t6920.scala:9: error: too many arguments (2, expected 1) for method applyDynamicNamed: (values: Seq[(String, Any)]): String
22
error after rewriting to CompilerError.this.test.applyDynamicNamed("crushTheCompiler")(scala.Tuple2("a", 1), scala.Tuple2("b", 2))
33
possible cause: maybe a wrong Dynamic method signature?
44
test.crushTheCompiler(a = 1, b = 2)

test/files/neg/t7157.check

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ Test_2.scala:9: error: not enough arguments for macro method m1_1_1: (x: Int): U
1111
Unspecified value parameter x.
1212
m1_1_1()
1313
^
14-
Test_2.scala:11: error: too many arguments (2) for macro method m1_1_1: (x: Int): Unit
14+
Test_2.scala:11: error: too many arguments (2, expected 1) for macro method m1_1_1: (x: Int): Unit
1515
m1_1_1(1, 2)
1616
^
17-
Test_2.scala:12: error: too many arguments (3) for macro method m1_1_1: (x: Int): Unit
17+
Test_2.scala:12: error: too many arguments (3, expected 1) for macro method m1_1_1: (x: Int): Unit
1818
m1_1_1(1, 2, 3)
1919
^
2020
Test_2.scala:14: error: not enough arguments for macro method m1_2_2: (x: Int, y: Int): Unit.
@@ -25,7 +25,7 @@ Test_2.scala:15: error: not enough arguments for macro method m1_2_2: (x: Int, y
2525
Unspecified value parameter y.
2626
m1_2_2(1)
2727
^
28-
Test_2.scala:17: error: too many arguments (3) for macro method m1_2_2: (x: Int, y: Int): Unit
28+
Test_2.scala:17: error: too many arguments (3, expected 2) for macro method m1_2_2: (x: Int, y: Int): Unit
2929
m1_2_2(1, 2, 3)
3030
^
3131
Test_2.scala:24: error: not enough arguments for macro method m1_1_inf: (x: Int, y: Int*): Unit.
@@ -53,10 +53,10 @@ Test_2.scala:39: error: not enough arguments for macro method m2_1_1: (x: Int):
5353
Unspecified value parameter x.
5454
m2_1_1()()
5555
^
56-
Test_2.scala:41: error: too many arguments (2) for macro method m2_1_1: (x: Int): Unit
56+
Test_2.scala:41: error: too many arguments (2, expected 1) for macro method m2_1_1: (x: Int): Unit
5757
m2_1_1()(1, 2)
5858
^
59-
Test_2.scala:42: error: too many arguments (3) for macro method m2_1_1: (x: Int): Unit
59+
Test_2.scala:42: error: too many arguments (3, expected 1) for macro method m2_1_1: (x: Int): Unit
6060
m2_1_1()(1, 2, 3)
6161
^
6262
Test_2.scala:44: error: not enough arguments for macro method m2_2_2: (x: Int, y: Int): Unit.
@@ -67,7 +67,7 @@ Test_2.scala:45: error: not enough arguments for macro method m2_2_2: (x: Int, y
6767
Unspecified value parameter y.
6868
m2_2_2()(1)
6969
^
70-
Test_2.scala:47: error: too many arguments (3) for macro method m2_2_2: (x: Int, y: Int): Unit
70+
Test_2.scala:47: error: too many arguments (3, expected 2) for macro method m2_2_2: (x: Int, y: Int): Unit
7171
m2_2_2()(1, 2, 3)
7272
^
7373
Test_2.scala:54: error: not enough arguments for macro method m2_1_inf: (x: Int, y: Int*): Unit.

test/files/neg/t8006.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
t8006.scala:3: error: too many arguments (2) for method applyDynamicNamed: (value: (String, Any)): String
1+
t8006.scala:3: error: too many arguments (2, expected 1) for method applyDynamicNamed: (value: (String, Any)): String
22
error after rewriting to X.this.d.applyDynamicNamed("meth")(scala.Tuple2("value1", 10), scala.Tuple2("value2", 100))
33
possible cause: maybe a wrong Dynamic method signature?
44
d.meth(value1 = 10, value2 = 100) // two arguments here, but only one is allowed

test/files/neg/t8667.check

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
t8667.scala:6: error: unknown parameter name: c
22
def c2 = new C(a = 42, b = 17, c = 5)
33
^
4-
t8667.scala:6: error: too many arguments (3) for constructor C: (a: Int, b: Int): C
4+
t8667.scala:6: error: too many arguments (3, expected 2) for constructor C: (a: Int, b: Int): C
55
def c2 = new C(a = 42, b = 17, c = 5)
66
^
77
t8667.scala:7: error: unknown parameter name: c
88
def c3 = new C(b = 42, a = 17, c = 5)
99
^
10-
t8667.scala:7: error: too many arguments (3) for constructor C: (a: Int, b: Int): C
10+
t8667.scala:7: error: too many arguments (3, expected 2) for constructor C: (a: Int, b: Int): C
1111
def c3 = new C(b = 42, a = 17, c = 5)
1212
^
1313
t8667.scala:8: error: positional after named argument.
1414
def c4 = new C(b = 42, a = 17, 5)
1515
^
16-
t8667.scala:8: error: too many arguments (3) for constructor C: (a: Int, b: Int): C
16+
t8667.scala:8: error: too many arguments (3, expected 2) for constructor C: (a: Int, b: Int): C
1717
def c4 = new C(b = 42, a = 17, 5)
1818
^
1919
t8667.scala:9: error: unknown parameter name: c
@@ -22,19 +22,19 @@ t8667.scala:9: error: unknown parameter name: c
2222
t8667.scala:10: error: unknown parameter name: c
2323
def c6 = new C(a = 42, c = 17, b = 5)
2424
^
25-
t8667.scala:10: error: too many arguments (3) for constructor C: (a: Int, b: Int): C
25+
t8667.scala:10: error: too many arguments (3, expected 2) for constructor C: (a: Int, b: Int): C
2626
def c6 = new C(a = 42, c = 17, b = 5)
2727
^
2828
t8667.scala:11: error: unknown parameter name: c
2929
def c7 = new C(c = 42, a = 17, b = 5)
3030
^
31-
t8667.scala:11: error: too many arguments (3) for constructor C: (a: Int, b: Int): C
31+
t8667.scala:11: error: too many arguments (3, expected 2) for constructor C: (a: Int, b: Int): C
3232
def c7 = new C(c = 42, a = 17, b = 5)
3333
^
3434
t8667.scala:12: error: parameter 'b' is already specified at parameter position 2
3535
def c8 = new C(42, 17, b = 5)
3636
^
37-
t8667.scala:12: error: too many arguments (3) for constructor C: (a: Int, b: Int): C
37+
t8667.scala:12: error: too many arguments (3, expected 2) for constructor C: (a: Int, b: Int): C
3838
def c8 = new C(42, 17, b = 5)
3939
^
4040
t8667.scala:13: error: unknown parameter name: c
@@ -43,7 +43,7 @@ t8667.scala:13: error: unknown parameter name: c
4343
t8667.scala:13: error: unknown parameter name: d
4444
def c9 = new C(a = 42, c = 17, d = 3, b = 5)
4545
^
46-
t8667.scala:13: error: too many arguments (4) for constructor C: (a: Int, b: Int): C
46+
t8667.scala:13: error: too many arguments (4, expected 2) for constructor C: (a: Int, b: Int): C
4747
def c9 = new C(a = 42, c = 17, d = 3, b = 5)
4848
^
4949
t8667.scala:14: error: unknown parameter name: d
@@ -52,25 +52,25 @@ t8667.scala:14: error: unknown parameter name: d
5252
t8667.scala:14: error: unknown parameter name: c
5353
def c0 = new C(42, 17, d = 3, c = 5)
5454
^
55-
t8667.scala:14: error: too many arguments (4) for constructor C: (a: Int, b: Int): C
55+
t8667.scala:14: error: too many arguments (4, expected 2) for constructor C: (a: Int, b: Int): C
5656
def c0 = new C(42, 17, d = 3, c = 5)
5757
^
5858
t8667.scala:25: error: no arguments allowed for nullary method f0: (): Int
5959
f0(1)
6060
^
61-
t8667.scala:26: error: too many arguments (2) for method f1: (i: Int): Int
61+
t8667.scala:26: error: too many arguments (2, expected 1) for method f1: (i: Int): Int
6262
f1(1, 2)
6363
^
64-
t8667.scala:27: error: too many arguments (3) for method f1: (i: Int): Int
64+
t8667.scala:27: error: too many arguments (3, expected 1) for method f1: (i: Int): Int
6565
f1(1, 2, 3)
6666
^
67-
t8667.scala:28: error: 3 more arguments than can be applied to method f1: (i: Int): Int
67+
t8667.scala:28: error: too many arguments (4, expected 1) for method f1: (i: Int): Int
6868
f1(1, 2, 3, 4)
6969
^
7070
t8667.scala:29: error: unknown parameter name: j
7171
f1(1, j = 2, 3, 4)
7272
^
73-
t8667.scala:29: error: 3 more arguments than can be applied to method f1: (i: Int): Int
73+
t8667.scala:29: error: too many arguments (4, expected 1) for method f1: (i: Int): Int
7474
f1(1, j = 2, 3, 4)
7575
^
7676
t8667.scala:30: error: unknown parameter name: j
@@ -79,22 +79,22 @@ t8667.scala:30: error: unknown parameter name: j
7979
t8667.scala:30: error: unknown parameter name: k
8080
f1(1, j = 2, k = 3, 4)
8181
^
82-
t8667.scala:30: error: 3 more arguments than can be applied to method f1: (i: Int): Int
82+
t8667.scala:30: error: too many arguments (4, expected 1) for method f1: (i: Int): Int
8383
f1(1, j = 2, k = 3, 4)
8484
^
8585
t8667.scala:31: error: unknown parameter name: k
8686
f2(k = 1, i = 2, j = 3)
8787
^
88-
t8667.scala:31: error: too many arguments (3) for method f2: (i: Int, j: Int): Int
88+
t8667.scala:31: error: too many arguments (3, expected 2) for method f2: (i: Int, j: Int): Int
8989
f2(k = 1, i = 2, j = 3)
9090
^
91-
t8667.scala:32: error: one more argument than can be applied to method f6: (i: Int, j: Int, k: Int, l: Int, m: Int, n: Int): Int
91+
t8667.scala:32: error: too many arguments (7, expected 6) for method f6: (i: Int, j: Int, k: Int, l: Int, m: Int, n: Int): Int
9292
f6(1, 2, 3, 4, 5, 6, 7)
9393
^
94-
t8667.scala:33: error: 2 more arguments than can be applied to method f6: (i: Int, j: Int, k: Int, l: Int, m: Int, n: Int): Int
94+
t8667.scala:33: error: too many arguments (8, expected 6) for method f6: (i: Int, j: Int, k: Int, l: Int, m: Int, n: Int): Int
9595
f6(1, 2, 3, 4, 5, 6, 7, 8)
9696
^
97-
t8667.scala:34: error: 15 arguments but expected 12 for method f12: (i: Int, j: Int, k: Int, l: Int, m: Int, n: Int, o: Int, p: Int, q: Int, r: Int, s: Int, t: Int): Int
97+
t8667.scala:34: error: too many arguments (15, expected 12) for method f12: (i: Int, j: Int, k: Int, l: Int, m: Int, n: Int, o: Int, p: Int, q: Int, r: Int, s: Int, t: Int): Int
9898
f12(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
9999
^
100100
t8667.scala:42: error: can't supply unit value with infix notation because nullary method f0: (): Int takes no arguments; use dotted invocation instead: x.f0()

test/files/neg/t876.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
t876.scala:25: error: too many arguments (2) for method apply: (key: AssertionError.A): manager.B in class HashMap
1+
t876.scala:25: error: too many arguments (2, expected 1) for method apply: (key: AssertionError.A): manager.B in class HashMap
22
assert(manager.map(A2) == List(manager.map(A2, A1)))
33
^
44
1 error

0 commit comments

Comments
 (0)