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

Parameterless closure to SAM coercion causes NPE during instruction selection with STC

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.5
    • 2.4.6
    • Static Type Checker
    • None
    • Java 1.8.0_60, OSX 10.10

    Description

      Coercion of parameterless closures (lazy eval blocks) to SAM type arguments results in an NPE during static type checking.

      Example:

      interface SamType {
          int sam()
      }
      
      int foo(SamType samt) {
          samt.sam()
      }
      
      @groovy.transform.TypeChecked
      void doFoo() {
          assert foo { -> 1 } == 1
      }
      
      doFoo()
      

      Results in:

      BUG! exception in phase 'instruction selection' in source unit 'ConsoleScript19' unexpected NullpointerException
      Caused by: java.lang.NullPointerException
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            shils Shil Sinha
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: