You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (JIRA)" <ji...@apache.org> on 2018/10/06 13:54:00 UTC

[jira] [Updated] (GROOVY-8832) Type parameters for trait method and its bridge method

     [ https://issues.apache.org/jira/browse/GROOVY-8832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-8832:
--------------------------------
    Description: 
This is related to GROOVY-8815.  When compiling a class that implements the trait {{grails.events.Events}} I am seeing different results for the type parameters.  I'm not sure what the correct generics signatures should be.  *What are the correct generics for this scenario?*

{code:groovy}
import grails.events.Events
class Service implements Events {}
{code}
And the relevant excerpt from Events:
{code:groovy}
def <E extends Event<?>> Bus notify(Object key, Closure<E> supplier)
{code}

When {{Service}} is compiled with Gradle, the following methods are created in the class file.  The synthetic method generics look okay, but the bridge method generics have {{E}} as {{java.lang.Object}}.
{code}
  // Method descriptor #96 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
  // Signature: <E:Lreactor/bus/Event<+Ljava/lang/Object;>;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
  // Stack: 8, Locals: 4
  public synthetic reactor.bus.Bus grails_events_Eventstrait$super$notify(java.lang.Object param0, groovy.lang.Closure param1);

  // Method descriptor #96 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
  // Signature: <E:Ljava/lang/Object;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
  // Stack: 5, Locals: 4
  @org.codehaus.groovy.transform.trait.Traits.TraitBridge(traitClass=grails.events.Events,
    desc="(Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;")
  public reactor.bus.Bus notify(java.lang.Object arg1, groovy.lang.Closure arg2);
{code}

By contrast, when {{Service}} is compiled with Groovy-Eclipse, the following methods are created in the class file.  Again the synthetic method looks okay -- in fact, more accurate to the original.  However the generics for the bridge method contain the unresolved type parameter {{T}}.  This is the actual bug I'm chasing, but I can't say what the right generics should be and why Gradle/Groovyc and Groovy-Eclipse have different answers for both methods.
{code}
  // Method descriptor #150 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
  // Signature: <E:Lreactor/bus/Event<*>;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
  // Stack: 8, Locals: 4
  public synthetic reactor.bus.Bus grails_events_Eventstrait$super$notify(java.lang.Object arg0, groovy.lang.Closure arg1);

  // Method descriptor #150 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
  // Signature: <E:Lreactor/bus/Event<TT;>;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
  // Stack: 5, Locals: 4
  @org.codehaus.groovy.transform.trait.Traits.TraitBridge(traitClass=grails.events.Events,
    desc="(Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;")
  public reactor.bus.Bus notify(java.lang.Object arg1, groovy.lang.Closure arg2);
{code}

  was:
This is related to GROOVY-8815.  When compiling a class that implements the trait {{grails.events.Events}} I am seeing different results for the type parameters.  I'm not sure what the correct generics signatures should be.  *What are the correct generics for this scenario?*

{code:groovy}
import grails.events.Events
class Service implements Events {}
{code}
And the relevant excerpt from Events:
{code:groovy}
def <E extends Event<?>> Bus notify(Object key, Closure<E> supplier)
{code}

When {{Service}} is compiled with Gradle, the following methods are created in the class file.  The synthetic method generics look okay, but the bridge method generics have {{E}} as {{java.lang.Object}}.
{code}
  // Method descriptor #96 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
  // Signature: <E:Lreactor/bus/Event<+Ljava/lang/Object;>;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
  // Stack: 8, Locals: 4
  public synthetic reactor.bus.Bus grails_events_Eventstrait$super$notify(java.lang.Object param0, groovy.lang.Closure param1);

  // Method descriptor #96 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
  // Signature: <E:Ljava/lang/Object;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
  // Stack: 5, Locals: 4
  @org.codehaus.groovy.transform.trait.Traits.TraitBridge(traitClass=grails.events.Events,
    desc="(Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;")
  public reactor.bus.Bus notify(java.lang.Object arg1, groovy.lang.Closure arg2);
{code}

By contrast, when {{Service}} is compiled with Groovy-Eclipse, the following methods are created in the class file.  Again the synthetic method looks okay -- in fact, more accurate to the original.  However the generics for the bridge method contain the unresolved type parameter {{T}}.  This is the actual bug I'm chasing, but I can't say what the right generics should be and why Gradle/Groovyc and Groovy-Eclipse have different answers for both methods.
{code}
// Method descriptor #150 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
  // Signature: <E:Lreactor/bus/Event<*>;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
  // Stack: 8, Locals: 4
  public synthetic reactor.bus.Bus grails_events_Eventstrait$super$notify(java.lang.Object arg0, groovy.lang.Closure arg1);

  // Method descriptor #150 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
  // Signature: <E:Lreactor/bus/Event<TT;>;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
  // Stack: 5, Locals: 4
  @org.codehaus.groovy.transform.trait.Traits.TraitBridge(traitClass=grails.events.Events,
    desc="(Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;")
  public reactor.bus.Bus notify(java.lang.Object arg1, groovy.lang.Closure arg2);
{code}


> Type parameters for trait method and its bridge method
> ------------------------------------------------------
>
>                 Key: GROOVY-8832
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8832
>             Project: Groovy
>          Issue Type: Question
>          Components: Compiler
>    Affects Versions: 2.4.15, 2.5.3
>            Reporter: Eric Milles
>            Priority: Major
>         Attachments: Events.zip
>
>
> This is related to GROOVY-8815.  When compiling a class that implements the trait {{grails.events.Events}} I am seeing different results for the type parameters.  I'm not sure what the correct generics signatures should be.  *What are the correct generics for this scenario?*
> {code:groovy}
> import grails.events.Events
> class Service implements Events {}
> {code}
> And the relevant excerpt from Events:
> {code:groovy}
> def <E extends Event<?>> Bus notify(Object key, Closure<E> supplier)
> {code}
> When {{Service}} is compiled with Gradle, the following methods are created in the class file.  The synthetic method generics look okay, but the bridge method generics have {{E}} as {{java.lang.Object}}.
> {code}
>   // Method descriptor #96 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
>   // Signature: <E:Lreactor/bus/Event<+Ljava/lang/Object;>;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
>   // Stack: 8, Locals: 4
>   public synthetic reactor.bus.Bus grails_events_Eventstrait$super$notify(java.lang.Object param0, groovy.lang.Closure param1);
>   // Method descriptor #96 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
>   // Signature: <E:Ljava/lang/Object;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
>   // Stack: 5, Locals: 4
>   @org.codehaus.groovy.transform.trait.Traits.TraitBridge(traitClass=grails.events.Events,
>     desc="(Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;")
>   public reactor.bus.Bus notify(java.lang.Object arg1, groovy.lang.Closure arg2);
> {code}
> By contrast, when {{Service}} is compiled with Groovy-Eclipse, the following methods are created in the class file.  Again the synthetic method looks okay -- in fact, more accurate to the original.  However the generics for the bridge method contain the unresolved type parameter {{T}}.  This is the actual bug I'm chasing, but I can't say what the right generics should be and why Gradle/Groovyc and Groovy-Eclipse have different answers for both methods.
> {code}
>   // Method descriptor #150 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
>   // Signature: <E:Lreactor/bus/Event<*>;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
>   // Stack: 8, Locals: 4
>   public synthetic reactor.bus.Bus grails_events_Eventstrait$super$notify(java.lang.Object arg0, groovy.lang.Closure arg1);
>   // Method descriptor #150 (Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;
>   // Signature: <E:Lreactor/bus/Event<TT;>;>(Ljava/lang/Object;Lgroovy/lang/Closure<TE;>;)Lreactor/bus/Bus;
>   // Stack: 5, Locals: 4
>   @org.codehaus.groovy.transform.trait.Traits.TraitBridge(traitClass=grails.events.Events,
>     desc="(Ljava/lang/Object;Lgroovy/lang/Closure;)Lreactor/bus/Bus;")
>   public reactor.bus.Bus notify(java.lang.Object arg1, groovy.lang.Closure arg2);
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)