Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7328

Base class setter chosen over private variable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Cannot Reproduce
    • 2.4.0
    • None
    • Android
    • None

    Description

      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'

      @CompileStatic
      public final class HomeActivity extends ActionBarActivity {
      
        private String result
      
        @Override
        protected void onCreate(Bundle savedInstanceState) {
      
          super.onCreate(savedInstanceState)
      
          this.result = "boom!"
      
        }
      
      }
      

      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!"

      Attachments

        Activity

          People

            melix Cédric Champeau
            mg6maciej Maciej Górski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: