[ 
https://issues.apache.org/jira/browse/GROOVY-10196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marcin Zajaczkowski updated GROOVY-10196:
-----------------------------------------
    Description: 
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, bu I report 
it as I encountered it in the class hierarchy available related to 
LinkedMultiValueMap in Spring Framework (classes originally in Java).

Reproduced with Groovy 3.0.8

  was:
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, bu I report 
it as I encountered it in the class hierarchy available related to 
LinkedMultiValueMap in Spring Framework (classes originally in Java).

Reproduced with Groovy 3.0.8


> "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: Improvement
>          Components: Static compilation
>    Affects Versions: 3.0.8
>            Reporter: Marcin Zajaczkowski
>            Priority: Minor
>
> 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, bu I 
> report it as I encountered it in the 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.3.4#803005)

Reply via email to