[
https://issues.apache.org/jira/browse/GROOVY-11057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-11057.
------------------------------
> STC Generic type matching failure
> ---------------------------------
>
> Key: GROOVY-11057
> URL: https://issues.apache.org/jira/browse/GROOVY-11057
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 4.0.12
> Reporter: Jan Hackel
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.13
>
>
> With Groovy version 4.0.12 this code will no longer compile:
>
> {code:java}
> import groovy.transform.CompileStatic
> import org.junit.jupiter.api.Test
> import org.mockito.Mockito
> @CompileStatic
> interface Configuration {
> Map<String, Object> getSettings()
> }
> @CompileStatic
> class GenericMapStubbing {
> @Test
> void stubSettings() {
> def configuration = Mockito.mock(Configuration).tap {
> Mockito.when(it.getSettings()).thenReturn([:])
> }
> assert configuration.settings.isEmpty()
> }
> } {code}
> Failure message:
>
> 18: [Static type checking] - Cannot find matching method
> org.mockito.stubbing.OngoingStubbing#thenReturn(java.util.LinkedHashMap<#K,
> #V>). Please check if the declared type is correct and if the method exists.
> @ line 16, column 7.
> Mockito.when(it.getSettings()).thenReturn([:])
--
This message was sent by Atlassian Jira
(v8.20.10#820010)