Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0.8
-
None
Description
Groovy static compilation reports:
> 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
in some weird, but still valid hierarchy of classes:
@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> { }
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