Daniel Sun created GROOVY-12714:
-----------------------------------

             Summary: `@CompileStatic` PECS wildcard containment diverges from 
javac (JLS 4.5.1)
                 Key: GROOVY-12714
                 URL: https://issues.apache.org/jira/browse/GROOVY-12714
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
    Affects Versions: 5.0.3, 4.0.29
            Reporter: Daniel Sun


h2. Problem
Under {{@CompileStatic}}, Groovy's generics / wildcard containment was more 
permissive than javac for several JLS 4.5.1 PECS cases, including:
* adding a non-subtype into {{List<? super Integer>}} (e.g. {{add(Double)}})
* treating {{? extends Number}} as contained in {{? extends Integer}} (and the 
dual lower-bound mistake)
* assigning a wildcard producer {{List<? extends Number>}} to an invariant 
{{List<Number>}}

h2. Fix
Align containment and capture write checks with JLS SE 25 ยงยง4.5.1, 4.5.2, 
4.10.2, 5.1.10 so {{@CompileStatic}} matches javac.

h2. Tests
Extend {{gls.generics.GenericsJavaCompatibilityTest}} with PECS containment / 
transfer / negative cases that both compilers must agree on.

h2. PR
https://github.com/apache/groovy/pull/3246



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to