You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/07/24 11:39:00 UTC
[jira] [Resolved] (GROOVY-9648) Bad error message when attempting
to call a missing constructor
[ https://issues.apache.org/jira/browse/GROOVY-9648?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King resolved GROOVY-9648.
-------------------------------
Fix Version/s: 3.0.6
4.0.0-alpha-1
Assignee: Paul King
Resolution: Fixed
Proposed PR merged.
> 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
> Assignee: Paul King
> Priority: Major
> Fix For: 4.0.0-alpha-1, 3.0.6
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> 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)