[
https://issues.apache.org/jira/browse/GROOVY-7767?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15166943#comment-15166943
]
Jochen Theodorou commented on GROOVY-7767:
------------------------------------------
I am pretty sure we have an issue for this already somewhere. The current MOP
defines this behaviour, so it is really intended to work like that. But for the
uncertain-when-to-come MOP 2 we do intend to change this. To document that and
ensure it is not forgotten, I made this a subtask of a MOP 2 collections task.
Should I find the original issue, I may close this one here as duplicate though
> Single-parameter method chosen zero parameters passed
> -----------------------------------------------------
>
> Key: GROOVY-7767
> URL: https://issues.apache.org/jira/browse/GROOVY-7767
> Project: Groovy
> Issue Type: Sub-task
> Affects Versions: 2.4.6
> Reporter: Mike Martin
>
> When there is a single variant of a given method name, and that method has a
> single parameter, then calls to that method with zero arguments will result
> in a call to the method with a value of {{null}}, even though the no argument
> is present in the actual method call. This is surprising and leads to silent
> errors. Instead, I would expect groovy to throw an error saying that no
> matching method could be found.
> Example:
> {code}
> new A()
> class A {
> A(){
> m()
> }
> void m(String param){
> println "param: $param"
> }
> }
> {code}
> Running the code above yields:
> {code}
> param: null
> {code}
> But I would expect it to yield something like:
> {code}
> Caught: groovy.lang.MissingMethodException: No signature of method: A.m() is
> applicable for argument types: () values: []
> Possible solutions: m(java.lang.String), is(java.lang.Object), dump(), any(),
> any(groovy.lang.Closure), use([Ljava.lang.Object;)
> groovy.lang.MissingMethodException: No signature of method: A.m() is
> applicable for argument types: () values: []
> Possible solutions: m(java.lang.String), is(java.lang.Object), dump(), any(),
> any(groovy.lang.Closure), use([Ljava.lang.Object;)
> at A.<init>(testClass2.groovy:8)
> at testClass2.run(testClass2.groovy:3)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)