diff options
author | Som Snytt <som.snytt@gmail.com> | 2015-06-26 21:32:29 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2015-06-27 01:55:45 -0700 |
commit | 96b012aa48e3d91f8ec6d5221df2f455f278c9e0 (patch) | |
tree | e78a49eeeb01ca4a516385d316062b6b83358ee3 /test | |
parent | 5b8073676cc77c2c889ed690f12bb6a99e790769 (diff) | |
download | scala-96b012aa48e3d91f8ec6d5221df2f455f278c9e0.tar.gz scala-96b012aa48e3d91f8ec6d5221df2f455f278c9e0.tar.bz2 scala-96b012aa48e3d91f8ec6d5221df2f455f278c9e0.zip |
Improved message for missing argument list
Clarifies the language and rules for eta-expansion.
A missing argument in a list, as opposed to a missing
argument list, results in a different message.
The comical expansion in parens does not attempt to show
what was already applied, but succeeds in showing at a
glance the shape of the method in question.
```
scala> def m(i: Int, j: Int)(x: Int) = ???
m: (i: Int, j: Int)(x: Int)Nothing
scala> m
<console>:12: error: missing argument list for method m
Unapplied methods are only converted to functions when a function type is expected.
You can make this conversion explicit by writing `m _` or `m(_,_)(_)` instead of `m`.
m
^
```
The original submission was due to sschaef and the wording due
to adriaanm, with a minor tweak.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/macro-invalidshape.check | 5 | ||||
-rw-r--r-- | test/files/neg/missing-arg-list.check | 21 | ||||
-rw-r--r-- | test/files/neg/missing-arg-list.scala | 13 |
3 files changed, 37 insertions, 2 deletions
diff --git a/test/files/neg/macro-invalidshape.check b/test/files/neg/macro-invalidshape.check index aa694df6d6..5093b87598 100644 --- a/test/files/neg/macro-invalidshape.check +++ b/test/files/neg/macro-invalidshape.check @@ -8,8 +8,9 @@ macro [<static object>].<method name>[[<type args>]] or macro [<macro bundle>].<method name>[[<type args>]] def foo2(x: Any) = macro Impls.foo(null)(null) ^ -Macros_Test_2.scala:4: error: missing arguments for method foo in object Impls; -follow this method with `_' if you want to treat it as a partially applied function +Macros_Test_2.scala:4: error: missing argument list for method foo in object Impls +Unapplied methods are only converted to functions when a function type is expected. +You can make this conversion explicit by writing `foo _` or `foo(_)(_)` instead of `foo`. def foo3(x: Any) = macro {2; Impls.foo} ^ Macros_Test_2.scala:7: error: macro implementation reference has wrong shape. required: diff --git a/test/files/neg/missing-arg-list.check b/test/files/neg/missing-arg-list.check new file mode 100644 index 0000000000..5a011c36f2 --- /dev/null +++ b/test/files/neg/missing-arg-list.check @@ -0,0 +1,21 @@ +missing-arg-list.scala:9: error: missing argument list for method id in trait T +Unapplied methods are only converted to functions when a function type is expected. +You can make this conversion explicit by writing `id _` or `id(_)` instead of `id`. + val w = id + ^ +missing-arg-list.scala:10: error: missing argument list for method f in trait T +Unapplied methods are only converted to functions when a function type is expected. +You can make this conversion explicit by writing `f _` or `f(_)(_)` instead of `f`. + val x = f + ^ +missing-arg-list.scala:11: error: missing argument list for method g in trait T +Unapplied methods are only converted to functions when a function type is expected. +You can make this conversion explicit by writing `g _` or `g(_,_,_)` instead of `g`. + val y = g + ^ +missing-arg-list.scala:12: error: missing argument list for method h in trait T +Unapplied methods are only converted to functions when a function type is expected. +You can make this conversion explicit by writing `h _` or `h(_,_,_)(_)` instead of `h`. + val z = h + ^ +four errors found diff --git a/test/files/neg/missing-arg-list.scala b/test/files/neg/missing-arg-list.scala new file mode 100644 index 0000000000..c422dd32fe --- /dev/null +++ b/test/files/neg/missing-arg-list.scala @@ -0,0 +1,13 @@ + +trait T { + + def id(i: Int) = i + def f(i: Int)(j: Int) = i+j + def g(i: Int, j: Int, k: Int) = i+j+k + def h(i: Int, j: Int, k: Int)(implicit s: String) = s*(i+j+k) + + val w = id + val x = f + val y = g + val z = h +} |