[
https://issues.apache.org/jira/browse/GROOVY-12779?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Sun reassigned GROOVY-12779:
-----------------------------------
Assignee: Daniel Sun
> STC: Type::extensionMethod with further parameters is not found when passed
> to a generic call
> ----------------------------------------------------------------------------------------------
>
> Key: GROOVY-12779
> URL: https://issues.apache.org/jira/browse/GROOVY-12779
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Paul King
> Assignee: Daniel Sun
> Priority: Major
>
> {code:groovy}
> import java.util.function.BiFunction
> @groovy.transform.CompileStatic
> class C {
> static <T, U, R> BiFunction<T, U, R> same(BiFunction<T, U, R> fn) { fn }
> static main(args) {
> BiFunction<List<String>, String, String> join = same(List::join)
> println join.apply(['a', 'b'], '-')
> }
> }
> {code}
> *Actual*, with 5.1.3 and 6.0.0, under {{@CompileStatic}}:
> {noformat}
> Failed to find class method 'join(java.lang.Object,java.lang.Object)' or
> instance method 'join(java.lang.Object)' for the type: java.util.List
> {noformat}
> and under {{@TypeChecked}}:
> {noformat}
> [Static type checking] - Cannot find matching method java.util.List#join.
> Please check if the declared type is correct and if the method exists.
> {noformat}
> Master rejects it too.
> *Expected:* it compiles and prints {{a-b}}, as dynamic code does and as the
> direct assignment does under both annotations:
> {code:groovy}
> BiFunction<List<String>, String, String> join = List::join
> {code}
> When the reference is first visited, the type parameters of {{same}} are not
> yet known, so the extension method {{join(Iterable, String)}} is looked up
> with {{Object}} parameter types and none is selected. Extension methods with
> only the receiver, such as {{List::first}}, are found.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)