[
https://issues.apache.org/jira/browse/GROOVY-7719?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Sun reassigned GROOVY-7719:
----------------------------------
Assignee: Daniel Sun (was: Eric Milles)
> 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: Daniel Sun
> Priority: Major
>
> 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
(v10.3.26#10030026)