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 2019/07/22 04:22:02 UTC
[jira] [Closed] (GROOVY-9176) Syntactic sugar for set method calls
in conflict with class member declarations
[ https://issues.apache.org/jira/browse/GROOVY-9176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-9176.
-----------------------------
> Syntactic sugar for set method calls in conflict with class member declarations
> -------------------------------------------------------------------------------
>
> Key: GROOVY-9176
> URL: https://issues.apache.org/jira/browse/GROOVY-9176
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 3.0.0-beta-1
> Reporter: David Ekholm
> Assignee: Paul King
> Priority: Minor
> Fix For: 2.5.8, 3.0.0-beta-2
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Groovy 3.0.0 beta 1 has broken code that earlier worked in Alpha 4:
> Say you have a Java class with a setTitle(String) method. Now you override this class with a Groovy class. In it you declare the following member variable:
> JLabel title = new JLabel("skin");
> This breaks the Groovy compiler in v3.0.0 beta 1 (but not alpha 4) with the following error:
> The return type of javax.swing.JLabel getTitle() in Script34$1$12 is incompatible with java.lang.String in se.datadosen.component.ControlPanel
> . At [-1:-1] @ line -1, column -1.
> Two things are noteworthy here:
> 1) The line number references (-1) are broken
> 2) Instead of letting the declared "title" variable hide the ability to call setTitle on the base class using the syntactic sugar of Groovy (foo = being syntactic sugar for setFoo(...)), it now bails out with this error, breaking Java compatibility. I expected this declaration to be allowed and simply hide the ability to call setTitle on the base class via that syntactic sugar.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)