You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Pascal Schumacher (JIRA)" <ji...@apache.org> on 2015/10/15 20:08:05 UTC

[jira] [Comment Edited] (GROOVY-7328) Base class setter chosen over private variable

    [ https://issues.apache.org/jira/browse/GROOVY-7328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14959316#comment-14959316 ] 

Pascal Schumacher edited comment on GROOVY-7328 at 10/15/15 6:07 PM:
---------------------------------------------------------------------

Closing this as Cédric could not reproduce. Please reopen if you can post a self-contained example.


was (Author: pascalschumacher):
Closing this a, Cédric could not reproduce. Please reopen if you can post a self-contained example.

> Base class setter chosen over private variable
> ----------------------------------------------
>
>                 Key: GROOVY-7328
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7328
>             Project: Groovy
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.4.0
>            Reporter: Maciej Górski
>            Assignee: Cédric Champeau
>            Priority: Minor
>
> On Android, the following code crashes with exception:
> Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'boom!' with class 'java.lang.String' to class 'int'
> {code}
> @CompileStatic
> public final class HomeActivity extends ActionBarActivity {
>   private String result
>   @Override
>   protected void onCreate(Bundle savedInstanceState) {
>     super.onCreate(savedInstanceState)
>     this.result = "boom!"
>   }
> }
> {code}
> The reason is a base class declares `setResult` method: http://developer.android.com/reference/android/app/Activity.html#setResult%28int%29
> Crash only happens when using
> {{this.result = "boom!"}}
> and not when
> {{result = "boom!"}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)