[
https://issues.apache.org/jira/browse/GROOVY-8787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16613399#comment-16613399
]
Jochen Theodorou commented on GROOVY-8787:
------------------------------------------
correct would be selection based on the static infered type. "" is String, thus
bar(String) is the most exact match and should be selected for method calls.
There is obviously a difference between dynamic and static because of the
dynamic mode using the runtime type for method selection, but this case here
should not fail
> Inconsistency in method selection with @CompileStatic
> -----------------------------------------------------
>
> Key: GROOVY-8787
> URL: https://issues.apache.org/jira/browse/GROOVY-8787
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation, Static Type Checker
> Affects Versions: 2.4.15, 2.5.2
> Reporter: Daniil Ovchinnikov
> Priority: Major
>
> Running
> {code:title=playground.groovy}
> class A {
> void bar(String s) {
> println("A#bar(String)")
> }
> }
> class B extends A {
> void bar(Object o) {
> println("B#bar(Object)")
> }
> }
> //@groovy.transform.CompileStatic
> void usage() {
> new B().bar("")
> }
> usage()
> {code}
> prints {{A#bar(String)}} which is correct.
> And with uncommented {{@CompileStatic}}:
> {noformat}
> Cannot choose between [void B#bar(java.lang.Object), void
> A#bar(java.lang.String)]
> {noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)