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

SAM coercion doesn't work with abstract classes in @CompileStatic

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.4.13, 2.5.0-rc-1
    • Fix Version/s: None
    • Labels:
      None

      Description

      import groovy.transform.CompileStatic
      
      abstract class A1 {
          def abstract foo()
      }
      
      @CompileStatic
      def m() {
          A1 a = { print this } //Groovyc: [Static type checking] - Cannot assign value of type groovy.lang.Closure <java.lang.Void> to variable of type A1
      }
      

      Looks like it should work as in dynamic mode.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Alexey Afanasiev Alexey Afanasiev
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: