[ 
https://issues.apache.org/jira/browse/GROOVY-12301?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18108276#comment-18108276
 ] 

ASF GitHub Bot commented on GROOVY-12301:
-----------------------------------------

paulk-asert opened a new pull request, #2833:
URL: https://github.com/apache/groovy/pull/2833

   …ited generic method it delegates to
   
   Some compilers (ECJ for one) redeclare inherited generic methods as erased 
synthetic bridge methods directly on the subclass. The synthetic-override guard 
in removeCovariantsAndInterfaceEquivalents was meant to keep the generic 
original in that case, but a type variable's ClassNode compares equal to its 
own erasure via redirect, so the guard never fired and the bridge's raw return 
type was inferred (e.g. weld-spock's self-recursive Builder: "Cannot assign 
value of type AbstractWeldInitiator$AbstractBuilder to variable of type 
WeldInitiator$Builder").




> STC does not resolve generic return type properly
> -------------------------------------------------
>
>                 Key: GROOVY-12301
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12301
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 6.0.0-alpha-1, 5.0.3, 4.0.31
>            Reporter: Björn Kautler
>            Priority: Major
>
> Given this snippet:
> {code:java}
> @Grab('org.jboss.weld:weld-spock:4.0.4.Final')
> import org.jboss.weld.spock.WeldInitiator
> import org.jboss.weld.spock.WeldInitiator.Builder
>   
> @groovy.transform.CompileStatic
> class Foo {
>   def foo() {
>     Builder builder = 
> WeldInitiator.from(WeldInitiator.createWeld()).inject(this)
>     println(builder)
>   }
> }
> new Foo().foo() {code}
> STC complains
> {code:java}
> Cannot assign value of type 
> org.jboss.weld.junit.AbstractWeldInitiator$AbstractBuilder to variable of 
> type org.jboss.weld.spock.WeldInitiator$Builder {code}
> IntelliJ knows the type of the {{inject}} result properly as {{{}Builder{}}}, 
> and in Java it also compiles fine.
> (This time I verified it still happens in 6.0.0-alpha-1 which is available in 
> groovyconsole.dev :))



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to