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 2021/06/08 15:49:00 UTC
[jira] [Resolved] (GROOVY-5239) Statically imported method vs other
methods with the same name
[ https://issues.apache.org/jira/browse/GROOVY-5239?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-5239.
---------------------------------
Fix Version/s: 4.0.0-beta-1
Resolution: Fixed
> Statically imported method vs other methods with the same name
> --------------------------------------------------------------
>
> Key: GROOVY-5239
> URL: https://issues.apache.org/jira/browse/GROOVY-5239
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Reporter: Maxim Medvedev
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-beta-1
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Assume you have a class test.Foo:
> {code}
> package test
> class Foo {
> static foo() {'foo'}
> }
> {code}
> Let's consider some code snippets. IMHO Groovy incorrectly resolves reference 'foo' to statically imported method in all of these cases.
> {code}
> import static test.Foo.foo
> class Bar {
> def foo() {'bar'}
> class Inner {
> def abc() {
> assert foo() == 'bar' //statically imported method will be invoked here
> }
> }
> }
> {code}
> {code}
> import static test.Foo.foo
> class Bar {
> def foo() {'bar'}
> }
> new Bar().with {
> assert foo() == 'bar' //statically imported method will be executed
> }
> {code}
> {code}
> import static test.Foo.foo
> class Base {
> def foo(){'base'}
> }
> class Bar extends Base {
> def abc() {
> assert foo() == 'base' //statically imported method will be executed
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)