Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
4.0.0
-
None
-
None
Description
This is a follow-up to GROOVY-10049. After the issue there had been fixed I was able to progress further with a chain of Stream method calls. However, the fix doesn't seem to cover the following case:
import java.util.stream.Collectors; class Test { static interface Named { String getName(); } <T extends Named> Map<String, List<T>> group(Set<T> namedObjects) { return namedObjects.stream() .collect(Collectors.groupingBy(named -> named.getName())); } }
With static type checking enabled, an error is produced:
Script_ce61a645759c941d687680111f9bedbd.groovy: 11: [Static type checking] - Cannot find matching method java.lang.Object#getName(). Please check if the declared type is correct and if the method exists. @ line 11, column 44. ollectors.groupingBy(named -> named.getN
The difference between this issue and GROOVY-10049 is that the lambda passed here is not directly assigned to a Stream method. Of course, the issue is probably not limited to Collectors, but this is how I am able to reproduce it.
I've tested this against https://github.com/apache/groovy/commit/e07f0112c5eff8d9c6828bd0ddb69e4b7f7cc1d6
Attachments
Issue Links
- is duplicated by
-
GROOVY-10613 Fail to infer correct types for fluent method calls
- Closed
- relates to
-
GROOVY-10544 Static compiler chooses superinterface return type
- Closed
-
GROOVY-11024 STC NPE when using Collectors.toMap() with a generic result
- Closed
-
GROOVY-10734 STC doesn't resolve zero-argument method references in nested generics
- Closed
-
GROOVY-10741 STC method pointer or reference to generated property method
- Closed
-
GROOVY-10749 STC: closure/lambda/reference parameter as type witness for SAM type generics
- Closed