You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Xiaoguang Wang (JIRA)" <ji...@apache.org> on 2019/03/30 06:13:01 UTC
[jira] [Comment Edited] (GROOVY-9059) Failed to parse/compile
generic methods with "extends"
[ https://issues.apache.org/jira/browse/GROOVY-9059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16805652#comment-16805652 ]
Xiaoguang Wang edited comment on GROOVY-9059 at 3/30/19 6:12 AM:
-----------------------------------------------------------------
Sorry I messed different problems together.
The main problem here is about
{code:java}
interface Y<T> {
public <O extends T> O foo(O o);
}
def y2 = new Y<String>() {
@Override
String foo(String o) { return o }
}
{code}
It compiles in Java, and such code appears in Srping's code, eg: `org.springframework.security.config.annotation.ObjectPostProcessor<T>` which has `{{<O extends [T|https://docs.spring.io/spring-security/site/docs/4.2.10.RELEASE/apidocs/org/springframework/security/config/annotation/ObjectPostProcessor.html]>}} {{[postProcess|https://docs.spring.io/spring-security/site/docs/4.2.10.RELEASE/apidocs/org/springframework/security/config/annotation/ObjectPostProcessor.html#postProcess-O-](O object)}}`
Such different behavior (groovy's error) makes developers do not know how to use Groovy with Spring.
was (Author: wxiaoguang):
Sorry I messed different problems together.
The main problem here is about
interface Y<T> { public <O extends T> O foo(O o);
}
def y2 = new Y<String>() \{
@Override
String foo(String o) { return o }
}
It compiles in Java, and such code appears in Srping's code, eg: `org.springframework.security.config.annotation.ObjectPostProcessor<T>` which has `{{<O extends [T|https://docs.spring.io/spring-security/site/docs/4.2.10.RELEASE/apidocs/org/springframework/security/config/annotation/ObjectPostProcessor.html]>}} {{[postProcess|https://docs.spring.io/spring-security/site/docs/4.2.10.RELEASE/apidocs/org/springframework/security/config/annotation/ObjectPostProcessor.html#postProcess-O-](O object)}}`
Such different behavior makes developers do not know how to use Groovy with Spring.
> Failed to parse/compile generic methods with "extends"
> ------------------------------------------------------
>
> Key: GROOVY-9059
> URL: https://issues.apache.org/jira/browse/GROOVY-9059
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 2.4.16, 3.0.0-alpha-4, 2.5.6
> Reporter: Xiaoguang Wang
> Priority: Major
> Attachments: image-2019-03-30-13-10-20-819.png
>
>
>
> {code:java}
> import groovy.transform.CompileStatic
> // This bug affects: groovy-2.4.16, groovy-2.5.6, groovy-3.0.0-alpha-4
> // This bug also affect IDEA's syntax parser
> interface X<T> {
> // Intellij IDEA reports that 'public' is not necessary
> // BUT without the 'public' modifier, there is a syntax error
> public <T> T foo(T o);
> }
> interface Y<T> {
> public <O extends T> O foo(O o);
> }
> @CompileStatic
> class TestGroovyGeneric {
> static void main(String[] args) {
> def x = new X<String>() {
> // it compiles
> // BUT: Intellij IDEA reports: ERROR: Method 'foo' is not implemented
> @Override
> String foo(String o) { return o }
> }
> // Strangely, such code compiles
> // BUT: Intellij IDEA reports: ERROR: Method 'foo' is not implemented
> def y1 = new Y<String>() {
> @Override
> public <String> String foo(String o) { return o }
> }
> // Can not compile:
> // BUT: Intellij IDEA reports no error ....
> def y2 = new Y<String>() {
> @Override
> String foo(String o) { return o }
> }
> }
> }
> {code}
> !image-2019-03-30-13-10-20-819.png!
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)