Repository navigation
GROOVY-12727: STC: infer a generic method's type arguments from the c… - #3265
paulk-asert wants to merge 1 commit into
Conversation
…all's target type when a lambda or closure argument needs them
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3265 +/- ##
==================================================
+ Coverage 74.4085% 74.4101% +0.0016%
- Complexity 44367 44386 +19
==================================================
Files 1699 1699
Lines 151050 151075 +25
Branches 28783 28792 +9
==================================================
+ Hits 112394 112415 +21
- Misses 28376 28378 +2
- Partials 10280 10282 +2
🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: 60711c7 Learn more about TestLens at testlens.app/docs. |
|
REQUEST_CHANGES The Pekko assignment and return both type-check, for a lambda and for a closure, and GenericsSTCTest is green including the three new methods. The witness is written onto StaticMethodCallExpression and then read only from the enclosing-call stack, which visitStaticMethodCallExpression never pushes. By INSTRUCTION_SELECTION, StaticImportVisitor has already turned a same-class static call and an javac accepts that. Please push/pop the static call in visitStaticMethodCallExpression the same way visitMethodCallExpression does, and add those two calls beside testReturnTypeInferenceWithClosure5. makeArgumentList returns the same ArgumentListExpression the parser stored, so the identity check in extractGenericsConnectionsFromCallTarget will then succeed. A few targets the helper’s comment says it determines are still unresolved. I compared them with javac on this tip:
GROOVY-11446 still type-checks ( I would keep Closure7 as the unbounded-wildcard rejection, and add: same-class static and import static; T extends CharSequence against List; List<List> and Map<A,B>; Beh<? super String> must pass; the Map<T,T> / Map<String,Integer> conflict must fail; one ternary and one argument context. String as a target is a weak assertion on its own, because STC will accept almost any value as a String. The Bot constructor in Closure5 is the right kind of check. The ReturnAdder widening looks safe: the listener constructor does not rewrite the method, and an explicit return is stamped only from visitReturnStatement. I do not see a merge conflict with the PECS work on the lines this patch adds; that branch is not an ancestor of 60711c7. Once a ? super bound is stored as a witness, it will meet the tighter compatibleConnection on that branch and should be rechecked. |
…all's target type when a lambda or closure argument needs them