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 2022/02/03 22:35:00 UTC
[jira] [Closed] (GROOVY-4320) Joint compiler + @Delegate fail to recognize method signature with default value
[ https://issues.apache.org/jira/browse/GROOVY-4320?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-4320.
-----------------------------
> Joint compiler + @Delegate fail to recognize method signature with default value
> --------------------------------------------------------------------------------
>
> Key: GROOVY-4320
> URL: https://issues.apache.org/jira/browse/GROOVY-4320
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 1.7.4
> Environment: MacOSX Snow Leopard, Groovy 1.7.4, Java 1.6.0_17
> Reporter: Andres Almiray
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-beta-1
>
> Attachments: GROOVY-4320.patch
>
>
> Spotted this problem when upgrading Griffon to Groovy 1.7.4.
> Start with a base contract defined in java
> {code}
> import java.util.List;
> public interface IApp {
> void event(String name);
> void event(String name, List params);
> }
> {code}
> Implement said contract in Groovy
> {code}
> class BaseApp implements IApp {
> private IApp appDelegate
> BaseApp(IApp app) {
> this.appDelegate = app
> }
> void event(String name, List params = []) {
> // empty
> }
> }
> {code}
> Now create a Groovy class where the previous will be used as delegate
> {code}
> class RealApp {
> @Delegate BaseApp _base
> RealApp() {
> _base = new BaseApp(this)
> }
> }
> {code}
> Compile the code
> {code}
> groovyc IApp.java BaseApp.groovy RealApp.groovy
> {code}
> With Groovy 1.7.3 you get the following method signatures
> {code}
> $ javap BaseApp | grep event
> public void event(java.lang.String, java.util.List);
> public void event(java.lang.String);
> $ javap RealApp | grep event
> public void event(java.lang.String);
> public void event(java.lang.String, java.util.List);
> {code}
> However 1.7.4 fails to recognize that the second argument to event() has a default value
> {code}
> $ groovy -version
> Groovy Version: 1.7.4 JVM: 1.6.0_17
> $ groovyc IApp.java BaseApp.groovy RealApp.groovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> RealApp.groovy: 1: Can't have an abstract method in a non-abstract class. The class 'RealApp' must be declared abstract or the method 'void event(java.lang.String)' must be implemented.
> @ line 1, column 1.
> class RealApp {
> ^
> 1 error
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)