[
https://issues.apache.org/jira/browse/GROOVY-9529?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-9529:
--------------------------------
Fix Version/s: 2.5.19
> Static type checking сannot choose between Map#getAt(Object) and
> Object#getAt(String) methods
> ---------------------------------------------------------------------------------------------
>
> Key: GROOVY-9529
> URL: https://issues.apache.org/jira/browse/GROOVY-9529
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 3.0.3
> Environment: Groovy Version: 3.0.3 JVM: 11.0.7 Vendor: Azul Systems,
> Inc. OS: Linux
> Reporter: Aleksey
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-alpha-1, 3.0.4, 2.5.19
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Script:
> {code:groovy}
> import groovy.transform.CompileStatic
> interface SimpleFeatureMap extends Map<Object, Object> {}
> interface FeatureMap extends SimpleFeatureMap{}
> class FeatureMapImpl extends HashMap<Object, Object> implements FeatureMap {}
> @CompileStatic
> class Test {
> FeatureMap newMap() {
> new FeatureMapImpl()
> }
> String test() {
> FeatureMap map = newMap()
> map['asd']
> }
> }
> new Test().test()
> {code}
> Result:
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> ideaGroovyConsole.groovy: 14: [Static type checking] - Reference to method is
> ambiguous. Cannot choose between [V java.util.Map <K,
> V>#getAt(java.lang.Object), java.lang.Object
> java.lang.Object#getAt(java.lang.String)]
> @ line 14, column 9.
> map['asd']
> ^
> 1 error
> at
> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
> at
> org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:963)
> at
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:650)
> at
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627)
> at
> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
> at
> groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
> at
> org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
> at
> org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
> at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
> at groovy.lang.GroovyShell.parseClass(GroovyShell.java:526)
> at groovy.lang.GroovyShell.run(GroovyShell.java:359)
> at groovy.lang.GroovyShell.run(GroovyShell.java:339)
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)