[
https://issues.apache.org/jira/browse/GROOVY-10196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-10196.
------------------------------
> "Cannot find matching method" with specific class hierarchy and static
> compilation
> ----------------------------------------------------------------------------------
>
> Key: GROOVY-10196
> URL: https://issues.apache.org/jira/browse/GROOVY-10196
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 3.0.8
> Reporter: Marcin Zajaczkowski
> Assignee: Eric Milles
> Priority: Minor
> Fix For: 3.0.9
>
>
> Groovy static compilation reports:
>
> {code:java}
> > Task :compileTestGroovy
> startup failed:
> /home/.../ReproCannotFindMethod.groovy: 11: [Static type checking] - Cannot
> find matching method
> com.example.repro.LinkedMultiValueMap3#add(java.lang.String,
> java.lang.String). Please check if the declared type is correct and if the
> method exists.
> @ line 11, column 9.
> map.add("foo", "bar")
> ^
> 1 error
> {code}
> in some weird, but still valid hierarchy of classes:
>
> {code:java}
> @CompileStatic
> class ReproCannotFindMethod {
> static ups() {
> LinkedMultiValueMap3<String, String> map = new LinkedMultiValueMap3<>()
> //fails on add()
> // MultiValueMapAdapter3<String, String> map = new
> MultiValueMapAdapter3<>() //works fine with add()
> map.add("foo", "bar")
> }
> }
> interface Map3<K, V> {
> }
> interface MultiValueMap3<K, V> extends Map3<K, List<V>> {
> void add(K key, V value);
> }
> class MultiValueMapAdapter3<K, V> implements MultiValueMap3<K, V> {
> @Override
> void add(K key, V value) {
> }
> }
> class LinkedMultiValueMap3<K, V> extends MultiValueMapAdapter3<K, V> {
> }
> {code}
>
> It is definitely a corner case, so it might not be worth to fix it, but I
> report it as I've encountered it in a class hierarchy available related to
> LinkedMultiValueMap in Spring Framework (classes originally in Java).
> Reproduced with Groovy 3.0.8
--
This message was sent by Atlassian Jira
(v8.20.1#820001)