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

Inconsistent class file - undefined type parameter for trait implementer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.15, 2.5.2
    • 3.0.0-rc-1, 2.5.22
    • None
    • None

    Description

      When compiling the following classes, the Service class ends up with an incomplete type parameter in it. This causes errors for the IDE: "Inconsistent classfile encountered: The undefined type parameter T is referenced from within Service"

      import java.util.function.Consumer
      import groovy.transform.CompileStatic
      
      class Event<T> {
        Event(String id, T payload) {
        }
        Event<T> setReplyTo(Object replyTo) {
        }
      }
      
      @CompileStatic
      trait Events {
        def <E extends Event<?>> Registration<Object, Consumer<E>> on(Class key, Closure consumer) {
        }
      }
      
      interface Registration<K, V> {
      }
      
      class Service implements Events {
      }
      

      javap output for Events shows:

        public abstract <E extends Event<?>> Registration<java.lang.Object,java.util.function.Consumer<E>> on(java.lang.Class, groovy.lang.Closure);
      

      javap output for Service shows:

        public <E extends Event<T>> Registration<java.lang.Object, java.util.function.Consumer<E>> on(java.lang.Class, groovy.lang.Closure);
        public <E extends Event<?>> Registration<java.lang.Object, java.util.function.Consumer<E>> Eventstrait$super$on(java.lang.Class, groovy.lang.Closure);
      

      It is this "T" in the trait method that is not defined. I think it should be "?" instead when looking at the original method's and the trait bridge method's type parameters.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              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 - 50m
                  50m