You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nameless args are caught early
Since 2.13, named args with a bad name error early.
When concocting messages for arity mismatches, there
is no longer any need to consider badly named args.
// pick a caret. For f(k=1,i=2,j=3), argPos[0,-1,1] b/c `k=1` taken as arg0
@@ -614,27 +614,20 @@ trait ContextErrors {
614
614
if (i <0) tree else args(i min (supplied -1))
615
615
}
616
616
valmsg= {
617
-
valbadappl={
618
-
valexcess= supplied - expected
619
-
valtarget= treeSymTypeMsg(fun)
620
-
621
-
if (expected ==0) args match {
622
-
case (c @Literal(Constant(()))) ::Nilif c.hasAttachment[SyntheticUnitAttachment.type] =>
623
-
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))}"
624
-
case _ =>s"no arguments allowed for nullary $target"
625
-
} else
626
-
s"too many arguments ($supplied, expected $expected) for $target"
case (c @Literal(Constant(()))) ::Nilif c.hasAttachment[SyntheticUnitAttachment.type] =>
624
+
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))}"
625
+
case _ =>s"no arguments allowed for nullary $target"
626
+
}
627
+
case1if isTupleType(formals.head) =>s"too many arguments (found $supplied, expected ${formals.head.typeArgs.size}-tuple) for $target"
628
+
case1if supplied >MaxTupleArity&& isAutoTuplable =>s"too many arguments (found $supplied, which exceeds the largest Tuple) for $target"
629
+
case_ =>s"too many arguments (found $supplied, expected $expected) for $target"
630
630
}
631
-
valsuppl=
632
-
unknowns.size match {
633
-
case0=>""
634
-
case1=>s"\nNote that '${unknowns.head}' is not a parameter name of the invoked method."
635
-
case _ => unknowns.mkString("\nNote that '", "', '", "' are not parameter names of the invoked method.")
t10207.scala:14: error: too many arguments (2, expected 1) for method apply: (key: Int): scala.collection.mutable.ArrayBuffer[String] in trait MapOps
1
+
t10207.scala:14: error: too many arguments (found 2, expected 1) for method apply: (key: Int): scala.collection.mutable.ArrayBuffer[String] in trait MapOps
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()
100
+
t8667.scala:46: error: too many arguments (found 22, expected 1) for method mini: (x: A): Int
t8667.scala:64: error: too many arguments (found 3, expected 2-tuple) for method t: (t: (Int, Int)): Nothing
119
+
def z = t(42, 27, 17)
120
+
^
121
+
t8667.scala:70: error: unknown parameter name: c
122
+
def x = f(c = "hello, world")
123
+
^
124
+
t8667.scala:76: error: can't supply unit value with infix notation because nullary method f0: (): Int takes no arguments; use dotted invocation instead: x.f0()
101
125
x f0 ()
102
126
^
103
-
t8667.scala:43: error: no arguments allowed for nullary method f0: (): Int
127
+
t8667.scala:77: error: no arguments allowed for nullary method f0: (): Int
0 commit comments