[ 
https://issues.apache.org/jira/browse/GROOVY-9648?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King updated GROOVY-9648:
------------------------------
    Description: 
For this class here:
{code}
class Person {
    String name
    Person(String name)  {
        this.name = name
   }
}
{code}
Attempting to construct an instance but supplying the incorrect type yields 
expected error messages:
{code}
new Person(new Date()) // groovy.lang.GroovyRuntimeException: Could not find 
matching constructor for: Person(Date)
new Person(name: new Date()) // groovy.lang.GroovyRuntimeException: failed to 
invoke constructor: public Person(java.lang.String) with arguments: [] reason: 
java.lang.IllegalArgumentException: wrong number of arguments
{code}
The second is using normal named args which needs a no-arg constructor.

But when swapping to indy we get:
{code}
new Person(new Date()) // groovy.lang.GroovyRuntimeException: Could not find 
matching constructor for: Person(Date) [Same]
new Person(name: new Date()) // java.lang.invoke.WrongMethodTypeException: 
cannot convert MethodHandle(String)Person to ()Object [Bad Message]
{code}



> Bad error message when attempting to call a missing constructor
> ---------------------------------------------------------------
>
>                 Key: GROOVY-9648
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9648
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.5
>            Reporter: Paul King
>            Priority: Major
>
> For this class here:
> {code}
> class Person {
>     String name
>     Person(String name)  {
>         this.name = name
>    }
> }
> {code}
> Attempting to construct an instance but supplying the incorrect type yields 
> expected error messages:
> {code}
> new Person(new Date()) // groovy.lang.GroovyRuntimeException: Could not find 
> matching constructor for: Person(Date)
> new Person(name: new Date()) // groovy.lang.GroovyRuntimeException: failed to 
> invoke constructor: public Person(java.lang.String) with arguments: [] 
> reason: java.lang.IllegalArgumentException: wrong number of arguments
> {code}
> The second is using normal named args which needs a no-arg constructor.
> But when swapping to indy we get:
> {code}
> new Person(new Date()) // groovy.lang.GroovyRuntimeException: Could not find 
> matching constructor for: Person(Date) [Same]
> new Person(name: new Date()) // java.lang.invoke.WrongMethodTypeException: 
> cannot convert MethodHandle(String)Person to ()Object [Bad Message]
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to