groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (GROOVY-8389) Static import of a property messes with instance method
Date Fri, 24 Nov 2017 22:58:00 GMT

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

Paul King edited comment on GROOVY-8389 at 11/24/17 10:57 PM:
--------------------------------------------------------------

Another example:
{code}
import static A.baz
import static A.bar

class A {
  static bar = { "Abar" }
  static baz = { "Abaz" }
}

def bar() {
  "bar"
}

@groovy.transform.CompileStatic
def usage() {
  bar() + baz()
}

assert usage() == 'barAbaz'
{code}
Works with {{@CS}} commented out (and indicates in dynamic Groovy that local explicit methods
with the same name as static imports are allowed and take precedence - worth checking other
cases to make sure this is by design) but otherwise fails with:
{noformat}
2 compilation errors:
[Static type checking] - Cannot find matching method A#bar(). Please check if the declared
type is right and if the method exists...
[Static type checking] - Cannot find matching method A#baz(). Please check if the declared
type is right and if the method exists...
{noformat}


was (Author: paulk):
Another example:
{code}
import static A.baz
import static A.bar

class A {
  static bar = { "Abar" }
  static baz = { "Abaz" }
}

def bar() {
  "bar"
}

@groovy.transform.CompileStatic
def usage() {
  bar() + baz()
}

assert usage() == 'barAbaz'
{code}
Works with {{@CS}} commented out (and indicating that local explicit methods take precedence
in dynamic Groovy - which I'm unsure is by design) but otherwise fails with:
{noformat}
2 compilation errors:
[Static type checking] - Cannot find matching method A#bar(). Please check if the declared
type is right and if the method exists...
[Static type checking] - Cannot find matching method A#baz(). Please check if the declared
type is right and if the method exists...
{noformat}

> Static import of a property messes with instance method
> -------------------------------------------------------
>
>                 Key: GROOVY-8389
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8389
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 2.5.0-beta-2, 2.4.13
>            Reporter: Daniil Ovchinnikov
>
> {code:title=bugs.groovy}
> import static A.bar
> class A {
>   static bar = "A"
> }
> def bar() {
>   "bar"
> }
> @groovy.transform.CompileStatic
> def usage() {
>   bar()
> }
> println usage() 
> {code}
> {noformat}
> 13: [Static type checking] - Cannot find matching method A#bar(). Please check if the
declared type is right and if the method exists.
>  @ line 13, column 3.
>      bar()
>      ^
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message