You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "David Ekholm (JIRA)" <ji...@apache.org> on 2019/06/17 20:33:00 UTC

[jira] [Created] (GROOVY-9176) Syntactic sugar for set method calls in conflict with class member declarations

David Ekholm created GROOVY-9176:
------------------------------------

             Summary: 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


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.3#76005)