paulk-asert commented on PR #3265:
URL: https://github.com/apache/groovy/pull/3265#issuecomment-7084748052

   Thanks Daniel, I've pushed an updated commit that takes your points:
   
   - **Same-class and `import static` calls** now get the target type too. They 
are converted to `StaticMethodCallExpression`, so I added the same 
enclosing-call tracking there, with the pop in a `finally`.
   - **`? super X` and `? extends X`** targets give `X` as the witness, and a 
witness is only taken if it satisfies the bounds of `T`. An unbounded `?` still 
determines nothing.
   - **Conditional expressions:** the target now reaches both ternary branches, 
including elvis and nested ones.
   - **Method references** are excluded, since GROOVY-12755 already checks 
them. With the target applied to them as well, an invalid bounded case was 
accepted by STC and then failed in static compilation.
   - **Cast hook:** I added a comment saying it is intentional. javac rejects 
`(Beh<String>) setup(...)`, but the result here is sound.
   - **Tightening:** the lambda parameter is now `Ctx<Integer>` instead of 
`Ctx<?>` when the target is concrete. So `Integer s = conv(c -> { c.value = 
'x'; 1 })` now fails, as it does in javac. It compiled before, but it polluted 
the heap.
   
   I've left these for follow-up issues: a target type for a generic call 
passed as a method argument, the target in `inferReturnTypeGenerics` and 
constructors, a better diagnostic when `Map<T,T>` gets conflicting targets, and 
GROOVY-11446. The same goes for the existing leniency around unbounded type 
parameters, which is identical on 5.1.3 and 6.0.0.
   
   The stc and sc suites, groovy-macro, groovy-contracts and groovy-ginq pass.


-- 
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