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

Using a method reference causes a compiler error

    XMLWordPrintableJSON

Details

    Description

      This appears to be distinct from GROOVY-9798 though appearing in similar circumstances.

      When using static compilation (only; @TypeChecked works fine), using a method reference as a parameter expecting a Function results in a compiler error:

      Error occurred while calling a method on a Groovy class from classpath.: InvocationTargetException: BUG! exception in phase 'class generation' in source unit '/home/christopher/gnomes/src/main/groovy/com/example/gnomes/GnomeController.groovy' ClassNode#getTypeClass for com.example.gnomes.Gnome called before the type class is set
      

      This error occurs both when using static GnomeDto from(Gnome g) as GnomeDto::from (correctly marked as a static reference in Eclipse, in case relevant) and when using GnomeDto toDto() as Gnome::toDto. In both cases explicitly adding as Function to the method reference resolves the problem.

      Attachments

        1. Groovy9799.groovy
          0.3 kB
          Christopher Smith

        Activity

          People

            emilles Eric Milles
            chrylis Christopher Smith
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m