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

Frank Pavageau updated GROOVY-7719:
-----------------------------------
    Summary: Type incompatibility of generic placeholders not detected for 
method called on field  (was: Generic type incompatibility not detected for 
method called on field)

> Type incompatibility of generic placeholders not detected for method called 
> on field
> ------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7719
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7719
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.4.5
>            Reporter: Frank Pavageau
>            Assignee: Cédric Champeau
>
> While reading the test case for GROOVY-5839, I noticed it did not actually 
> match the reported problem, which is about a method-level generic type 
> shadowing a class-level generic type. However, the real problem is that the 
> code compiles even without the shadowing of the generic type of the class by 
> the method:
> {code}
> class GoodCodeRed<T> {
>     Collection<GoodCodeRed<T>> attached = []
>     public <U> void attach(GoodCodeRed<U> toAttach) {
>         attached.add(toAttach)
>     }
> }
> def g1 = new GoodCodeRed<Integer>()
> def g2 = new GoodCodeRed<Integer>()
> g1.attach(g2)
> {code}
> {{T}} and {{U}} are unrelated, the {{attached.add(toAttach)}} call should not 
> compile.
> Once that is fixed, we can see if the shadowing of the type is also an issue, 
> simply by renaming {{U}} to {{T}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to