You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2018/11/05 14:00:04 UTC
[jira] [Commented] (GROOVY-8815) Inconsistent class file -
undefined type parameter for trait implementer
[ https://issues.apache.org/jira/browse/GROOVY-8815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16675185#comment-16675185 ]
Paul King commented on GROOVY-8815:
-----------------------------------
Unwinding the GROOVY-8757 change and instead applying the {{asGenericsType/applyGenericsContextToPlaceHolders}} solution breaks the following test:
{noformat}
groovy.bugs.groovy8757.UsageTest > testAccessingPrecompiledTraitWithMethodGenerics FAILED
java.lang.VerifyError: Bad return type
Exception Details:
Location:
C0.foo(Ljava/lang/Class;)Ljava/lang/Number; @5: areturn
Reason:
Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'java/lang/Number' (from method signature)
Current Frame:
bci: @5
flags: { }
locals: { 'C0', 'java/lang/Class' }
stack: { 'java/lang/Object' }
Bytecode:
0x0000000: 2a2b b600 89b0
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getDeclaredConstructors(Class.java:2020)
at org.codehaus.groovy.reflection.CachedClass$2$1.run(CachedClass.java:88)
...
{noformat}
> Inconsistent class file - undefined type parameter for trait implementer
> ------------------------------------------------------------------------
>
> Key: GROOVY-8815
> URL: https://issues.apache.org/jira/browse/GROOVY-8815
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.4.15, 2.5.2
> Reporter: Eric Milles
> Priority: Major
>
> 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"
> {code}
> 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 {
> }
> {code}
> javap output for Events shows:
> {code:java}
> public abstract <E extends Event<?>> Registration<java.lang.Object,java.util.function.Consumer<E>> on(java.lang.Class, groovy.lang.Closure);
> {code}
> javap output for Service shows:
> {code:java}
> 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);
> {code}
> 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.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)