You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2019/12/20 19:46:23 UTC
[groovy] branch GROOVY-9347 created (now 5e54d15)
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a change to branch GROOVY-9347
in repository https://gitbox.apache.org/repos/asf/groovy.git.
at 5e54d15 GROOVY-9347: extract super-interface generics information for SAM coerce
This branch includes the following new commits:
new 5e54d15 GROOVY-9347: extract super-interface generics information for SAM coerce
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[groovy] 01/01: GROOVY-9347: extract super-interface generics
information for SAM coerce
Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY-9347
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 5e54d154076a46e14d5f0f75685b6b868996b448
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Fri Dec 20 13:45:51 2019 -0600
GROOVY-9347: extract super-interface generics information for SAM coerce
['x'].forEach(e -> e._) // forEach(Consumer<? super T>) from Iterable<T>
List<X> redirects to List<E> extends Collection<E> extends Iterable<T>
---
.../codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java | 8 +++++++-
src/test/groovy/transform/stc/LambdaTest.groovy | 3 +--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 81bb15d..fea37f6 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -248,6 +248,7 @@ import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDG
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findSetters;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findTargetVariable;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.fullyResolveType;
+import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getCorrectedClassNode;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getGenericsWithoutArray;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getOperationName;
import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf;
@@ -2749,7 +2750,12 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
private void inferSAMType(final Parameter param, final ClassNode receiver, final MethodNode methodWithSAMParameter, final ArgumentListExpression originalMethodCallArguments, final ClosureExpression openBlock) {
// first we try to get as much information about the declaration class through the receiver
Map<GenericsTypeName, GenericsType> targetMethodConnections = new HashMap<>();
- extractGenericsConnections(targetMethodConnections, receiver, receiver.redirect());
+ for (ClassNode face : receiver.getAllInterfaces()) {
+ extractGenericsConnections(targetMethodConnections, getCorrectedClassNode(receiver, face, true), face.redirect());
+ }
+ if (!receiver.isInterface()) {
+ extractGenericsConnections(targetMethodConnections, receiver, receiver.redirect());
+ }
// then we use the method with the SAM-type parameter to get more information about the declaration
Parameter[] parametersOfMethodContainingSAM = methodWithSAMParameter.getParameters();
diff --git a/src/test/groovy/transform/stc/LambdaTest.groovy b/src/test/groovy/transform/stc/LambdaTest.groovy
index 0f33f84..fd37f63 100644
--- a/src/test/groovy/transform/stc/LambdaTest.groovy
+++ b/src/test/groovy/transform/stc/LambdaTest.groovy
@@ -18,7 +18,6 @@
*/
package groovy.transform.stc
-import groovy.test.NotYetImplemented
import groovy.transform.CompileStatic
import org.junit.Test
@@ -1081,7 +1080,7 @@ final class LambdaTest {
'''
}
- @Test @NotYetImplemented // GROOVY-9347
+ @Test // GROOVY-9347
void testStaticInitializeBlocks2() {
assertScript '''
@groovy.transform.CompileStatic