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

@CompileStatic does not infer the type of caught exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.6
    • 2.1.0
    • Static Type Checker
    • None

    Description

      This fails with Groovyc: Access to java.lang.Object#message is forbidden

      class Test {
          @groovy.transform.CompileStatic
          public static void main(String[] args) {
              try {
                  println "foobar"
              } catch (e) {
                  println e.message
              }
      
          }
      }
      

      This passes:

      class Test {
          @groovy.transform.CompileStatic
          public static void main(String[] args) {
              try {
                  println "foobar"
              } catch (Throwable e) {
                  println e.message
              }
      
          }
      }
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            ddimitrov Dimitar Dimitrov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: