You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/05/01 20:41:00 UTC

[jira] [Comment Edited] (GROOVY-9529) Static type checking сannot choose between Map#getAt(Object) and Object#getAt(String) methods

    [ https://issues.apache.org/jira/browse/GROOVY-9529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17097650#comment-17097650 ] 

Eric Milles edited comment on GROOVY-9529 at 5/1/20, 8:40 PM:
--------------------------------------------------------------

I think this was caused by the changes for GROOVY-9420.  Update: nope, it's not.


was (Author: emilles):
I think this was caused by the changes for GROOVY-9420.

> 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
>
> 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.3.4#803005)