Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Compiling this code:
assert 'Hi'.transform(String::length) * 3 == 6 // transform is JDK12
with type checking gives:
[Static type checking] - Cannot find matching method java.lang.Object#multiply(int). Please check if the declared type is correct and if the method exists.
We can close as duplicate if this overlaps with an existing issue. It might not be anything to do with method references but an existing limitation in the type checker around supporting generics involving bounded parameters. For reference, the definition of transform is:
public <R> R transform​(Function<? super String,​? extends R> f)