[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-21 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9779:
-

https://github.com/apache/groovy/pull/1407

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.7, 4.0.0-alpha-2
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-21 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9779:
-

[~paulk] Could you please clone the issue for the static compile support?  Then 
I will take a look at that.

[~daniilo] I will look into the call property chaining mentioned above.  That 
was an unexpected consequence.

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.7, 4.0.0-alpha-2
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-21 Thread Paul King (Jira)


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

Paul King commented on GROOVY-9779:
---

Thanks [~daniilo]. I tried an example which worked on 4 but not 3, but I can 
replicate your example on both.

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.7, 4.0.0-alpha-2
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-21 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9779:


[~paulk] the example can be found in the body of this ticket. Adjusted with the 
@CS, it looks like:
{code:title=playground.groovy}
class C {
def call() {
42
}
}

class Container {
static final staticC   = new C()
def  instanceC = new C()
}
@groovy.transform.CompileStatic
def usage() {
  assert Container.staticC() == 42 // [Static type checking] - Cannot find 
matching method Container#staticC()
  def container = new Container()
  assert container.staticC() == 42 // [Static type checking] - Cannot find 
matching method Container#staticC()
  assert container.instanceC() == 42 // [Static type checking] - Cannot find 
matching method Container#instanceC()
}
usage()
{code}

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.7, 4.0.0-alpha-2
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-20 Thread Paul King (Jira)


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

Paul King commented on GROOVY-9779:
---

[~daniilo] Do you have an example failing on master or GROOVY_3_0_X?

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.7, 4.0.0-alpha-2
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-20 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9779:


In @CompileStatic the code doesn't compile. Do you plan to fix it as well?

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.7, 4.0.0-alpha-2
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-14 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9779:


I also believe this change should be discussed in the mailing list first. It's 
also a major change which should not occur in the minor version.

https://groovy-lang.org/operators.html#_call_operator shows an example with 
{{call}} omitted _on a local variable_. Local variable calls, as well as calls 
on something which is not a reference e.g. call on a parenthesised expression, 
are compiled as if {{call}} was written explicitly.

{noformat}
foo() -> foo.call() // if `foo` is a variable, this allows to omit `call`
foo() -> foo() // if `foo` is not a variable
(foo) -> foo.call()
foo[bar]() -> foo[bar].call() 
{noformat}

See org.codehaus.groovy.classgen.VariableScopeVisitor#visitMethodCallExpression 


> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.7, 4.0.0-alpha-2
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-14 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9779:


After this change the following tests pass:

{code:groovy}
assertScript '''   
class C {
def call() { return 42 }
}
class C1 {
def call = new C()
}
class C2 {
def call = new C1()
}
class C3 {
def call = new C2()
}
class D {
final y = new C3()
}
assert new D().y() == 42
'''
{code}

{code:groovy}
assertScript '''   
class C {
def call(a) { return 42 }
}
class C1 {
def call = new C()
}
class C2 {
def plus = new C1()
}
assert new C2() + 1 == 42
'''
{code}

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.7, 4.0.0-alpha-2
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-12 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9779:
-

https://github.com/apache/groovy/pull/1403

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-12 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9779:
-

In general "()" is considered the "call" operator and can be used to invoke the 
call method of its receiver.  
https://docs.groovy-lang.org/latest/html/documentation/#Operator-Overloading

I don't see any roadblocks to making the instance case work like the class 
case.  But I have to run through some tests to be sure.

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-12 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9779:


In @CS it fails to compile in all 3 cases.

I'd actually expect the static case ({{Container.staticC()}}) to fail as well. 
There is a reason why properties are callable, AFAIU in the early times it was 
common to define a property with Closure type instead of a method. If the 
instance case ({{container.instanceC()}}) will work, then what should happen 
here?
{code:groovy}
class Callable {
def call() {
42
}
} 

class C {
def call = new Callable()
}

class Container {
def c = new C()
}

def container = new Container()
container.c() // ?
// try container.c()
// then try container.c.call() as if it was written explicitly
// which in turn should try container.c.call.call() 
// which in turn should try container.c.call.call.call()
// ...
{code}

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-12 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9779:
-

I'm going to try out the "invokeStaticMissingMethod" logic for the instance 
case.  Also, what is the behavior for static compilation?

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-12 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9779:


Eric, so what the fix will be? Will invocations in both contexts fail or work?

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-12 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9779:
-

{{MetaClassImpl#invokeStaticMethod}} does this at the end:
{code:java}
if (prop != null) {
MetaClass propMC = registry.getMetaClass(prop.getClass());
return propMC.invokeMethod(prop, CLOSURE_CALL_METHOD, arguments);
}

return invokeStaticMissingMethod(sender, methodName, arguments);
}
{code}

This is where a non-closure property is tried as a callable.  {{invokeMethod}} 
ends with 
[{{invokePropertyOrMissing}}|https://github.com/apache/groovy/blob/master/src/main/java/groovy/lang/MetaClassImpl.java#L1315]
 which does not try the property as callable unless it is a closure or a script 
binding variable.

> Inconsistency with callable properties in static context
> 
>
> Key: GROOVY-9779
> URL: https://issues.apache.org/jira/browse/GROOVY-9779
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.6
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:title=playground.groovy}
> class C {
> def call() {
> 42
> }
> }
> class Container {
> static final staticC   = new C()
> def  instanceC = new C()
> }
> assert Container.staticC() == 42 // works fine
> def container = new Container()
> assert container.staticC() == 42 // MissingMethodException
> assert container.instanceC() == 42 // MissingMethodException
> {code}
> I'd expect the invocations to fail or to work in both static and instance 
> contexts.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)