daniellansun opened a new pull request, #3246:
URL: https://github.com/apache/groovy/pull/3246

   JIRA: https://issues.apache.org/jira/browse/GROOVY-12714
   
   ## Summary
   
   Extends `GenericsJavaCompatibilityTest` with the JLS 4.5.1 / 4.5.2 / 4.10.2 
PECS rows that were not already a dedicated case, and aligns `@CompileStatic` 
with javac where those cases diverged.
   
   ## New tests
   
   - `testPecsContainmentMatrix` — legal containment assignments, including 
`List<? super Integer>` to `List<? extends Object>`
   - `testPecsTransfer` — `<E> void transfer(List<? extends E>, List<? super 
E>)` with an `Integer` producer and a `Number` consumer
   - `testPecsContravariantPredicateAndConsumer` — `Predicate<? super 
CharSequence>` and `Consumer<? super Number>` accept a more specific value
   - `testPecsWildcardExtendsReturn` — a method may return `List<? extends 
Number>`; the caller reads `Number`
   - `testPecsNegativeReadIntegerFromSuper` / 
`testPecsNegativeReadIntegerFromExtends`
   - `testPecsNegativeAddDoubleToSuperInteger`
   - `testPecsNegativeAssignExtendsToInvariantList` — `List<? extends Number>` 
is not a `List<Number>`
   - `testPecsNegativeAssignStringListToExtendsNumber`
   - `testPecsNegativeAssignExtendsNumberToExtendsInteger`
   - `testPecsNegativeAssignSuperIntegerToSuperNumber`
   - `testPecsNegativeAssignSuperToExtendsNumber` / 
`testPecsNegativeAssignExtendsToSuperInteger`
   - `testPecsNegativeTransferWrongPolarity`
   
   ## Static type checking
   
   - Capture of `? super T` accepts a concrete element only when it is a 
subtype of `T` (`StaticTypeCheckingSupport`).
   - `? extends A` is contained in `? extends B` only when `A` is a subtype of 
`B`; `? super A` is contained in `? super S` only when `S` is a subtype of `A` 
(`GenericsType`).
   - Assignment rejects a wildcard stored in a concrete type argument 
(`List<Number> = List<? extends Number>`), while a type variable may still 
capture a wildcard (`StaticTypeCheckingVisitor`).
   
   Checked with `./gradlew :test --tests 
gls.generics.GenericsJavaCompatibilityTest` and 
`groovy.transform.stc.GenericsSTCTest`. The oracle is this environment's javac; 
the cases follow JLS SE 25 sections 4.5.1, 4.5.2, 4.10.2 and 5.1.10.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to