[jira] [Created] (GROOVY-8362) Nested class is resolved via another nested class with package name

2017-10-20 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8362:
--

 Summary: Nested class is resolved via another nested class with 
package name
 Key: GROOVY-8362
 URL: https://issues.apache.org/jira/browse/GROOVY-8362
 Project: Groovy
  Issue Type: Bug
Reporter: Daniil Ovchinnikov
Priority: Critical


{code:title=bugs/bugs.groovy}
package bugs

class Current {

  static class bugs {
static class Target {}
  }

  static usage() {
new Target() // error expected
  }
}

println Current.usage() // bugs.Current$bugs$Target@20d28811
{code}



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


[jira] [Created] (GROOVY-8364) Nested class of parent Java class is not resolved

2017-10-23 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8364:
--

 Summary: Nested class of parent Java class is not resolved
 Key: GROOVY-8364
 URL: https://issues.apache.org/jira/browse/GROOVY-8364
 Project: Groovy
  Issue Type: Bug
Reporter: Daniil Ovchinnikov


{code:title=bugs/A.java}
package bugs;

public class A {
public interface Inner {}
}
{code}

{code:title=bugs/B.java}
package bugs;

public class B {
public interface Inner {}
}
{code}

{code:title=bugs/test/test.groovy}
package bugs.test

import bugs.A
//import static bugs.B.Inner

class Current extends A {
  static usage() {
return Inner // here
  }
}

println Current.usage()
{code}

{noformat}
Apparent variable 'Inner' was found in a static scope but doesn't refer to a 
local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable 
from a static context.
You misspelled a classname or statically imported field. Please check the 
spelling.
You attempted to use a method 'Inner' but left out brackets in a place not 
allowed by the grammar.
 @ line 8, column 12.
   return Inner
  ^
{noformat}

Note the class could be resolved only via import.

Now try to uncomment a static import.
While usually the nested class takes precedence over an import, in this case 
the failure to resolve a nested class results in a silent resolution to 
{{bugs.B.Inner}}, i.e. no error is reported.



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


[jira] [Updated] (GROOVY-8364) Nested class of parent Java class is not resolved

2017-10-23 Thread Daniil Ovchinnikov (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-8364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-8364:
---
Description: 
{code:title=bugs/A.java}
package bugs;

public class A {
public interface Inner {}
}
{code}

{code:title=bugs/B.java}
package bugs;

public class B {
public interface Inner {}
}
{code}

{code:title=bugs/test/test.groovy}
package bugs.test

import bugs.A
//import static bugs.B.Inner

class Current extends A {
  static usage() {
return Inner // here
  }
}

println Current.usage()
{code}

{noformat}
Apparent variable 'Inner' was found in a static scope but doesn't refer to a 
local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable 
from a static context.
You misspelled a classname or statically imported field. Please check the 
spelling.
You attempted to use a method 'Inner' but left out brackets in a place not 
allowed by the grammar.
 @ line 8, column 12.
   return Inner
  ^
{noformat}

Note the class could be resolved only via import.

Now try to uncomment a static import.
While usually the nested class takes precedence over an import, in this case 
the failure to resolve a nested class results in a silent resolution to 
{{bugs.B.Inner}}, i.e. no error is reported.

In both cases the reference is expected to be resolved to {{bugs.A.Inner}}

  was:
{code:title=bugs/A.java}
package bugs;

public class A {
public interface Inner {}
}
{code}

{code:title=bugs/B.java}
package bugs;

public class B {
public interface Inner {}
}
{code}

{code:title=bugs/test/test.groovy}
package bugs.test

import bugs.A
//import static bugs.B.Inner

class Current extends A {
  static usage() {
return Inner // here
  }
}

println Current.usage()
{code}

{noformat}
Apparent variable 'Inner' was found in a static scope but doesn't refer to a 
local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable 
from a static context.
You misspelled a classname or statically imported field. Please check the 
spelling.
You attempted to use a method 'Inner' but left out brackets in a place not 
allowed by the grammar.
 @ line 8, column 12.
   return Inner
  ^
{noformat}

Note the class could be resolved only via import.

Now try to uncomment a static import.
While usually the nested class takes precedence over an import, in this case 
the failure to resolve a nested class results in a silent resolution to 
{{bugs.B.Inner}}, i.e. no error is reported.


> Nested class of parent Java class is not resolved
> -
>
> Key: GROOVY-8364
> URL: https://issues.apache.org/jira/browse/GROOVY-8364
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniil Ovchinnikov
>
> {code:title=bugs/A.java}
> package bugs;
> public class A {
> public interface Inner {}
> }
> {code}
> {code:title=bugs/B.java}
> package bugs;
> public class B {
> public interface Inner {}
> }
> {code}
> {code:title=bugs/test/test.groovy}
> package bugs.test
> import bugs.A
> //import static bugs.B.Inner
> class Current extends A {
>   static usage() {
> return Inner // here
>   }
> }
> println Current.usage()
> {code}
> {noformat}
> Apparent variable 'Inner' was found in a static scope but doesn't refer to a 
> local variable, static field or class. Possible causes:
> You attempted to reference a variable in the binding or an instance variable 
> from a static context.
> You misspelled a classname or statically imported field. Please check the 
> spelling.
> You attempted to use a method 'Inner' but left out brackets in a place not 
> allowed by the grammar.
>  @ line 8, column 12.
>return Inner
>   ^
> {noformat}
> Note the class could be resolved only via import.
> Now try to uncomment a static import.
> While usually the nested class takes precedence over an import, in this case 
> the failure to resolve a nested class results in a silent resolution to 
> {{bugs.B.Inner}}, i.e. no error is reported.
> In both cases the reference is expected to be resolved to {{bugs.A.Inner}}



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


[jira] [Updated] (GROOVY-8449) Inconsistency in accessing uppercase properties in @CompileStatic

2018-01-15 Thread Daniil Ovchinnikov (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-8449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-8449:
---
Summary: Inconsistency in accessing uppercase properties in @CompileStatic  
(was: Inconsistency in accessing properties in @CompileStatic)

> Inconsistency in accessing uppercase properties in @CompileStatic
> -
>
> Key: GROOVY-8449
> URL: https://issues.apache.org/jira/browse/GROOVY-8449
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation
>Affects Versions: 2.4.13
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:title=bugs.groovy}
> class Fields {
>   def Field = "field"
>   def getField() { "getter" }
> }
> @CompileStatic
> def usageCompileStatic() {
>   new Fields().Field
> }
> def usageCompileDynamic() {
>   new Fields().Field
> }
> println usageCompileDynamic() // field
> println usageCompileStatic() // getter{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8449) Inconsistency in accessing properties in @CompileStatic

2018-01-15 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8449:
--

 Summary: Inconsistency in accessing properties in @CompileStatic
 Key: GROOVY-8449
 URL: https://issues.apache.org/jira/browse/GROOVY-8449
 Project: Groovy
  Issue Type: Bug
  Components: Static compilation
Affects Versions: 2.4.13
Reporter: Daniil Ovchinnikov


{code:title=bugs.groovy}
class Fields {
  def Field = "field"
  def getField() { "getter" }
}

@CompileStatic
def usageCompileStatic() {
  new Fields().Field
}

def usageCompileDynamic() {
  new Fields().Field
}

println usageCompileDynamic() // field
println usageCompileStatic() // getter{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8449) Inconsistency in accessing properties in @CompileStatic

2018-01-15 Thread Daniil Ovchinnikov (JIRA)

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

Daniil Ovchinnikov commented on GROOVY-8449:


Please confirm this is intended behaviour or clarify which of these cases 
should be fixed.

> Inconsistency in accessing properties in @CompileStatic
> ---
>
> Key: GROOVY-8449
> URL: https://issues.apache.org/jira/browse/GROOVY-8449
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation
>Affects Versions: 2.4.13
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:title=bugs.groovy}
> class Fields {
>   def Field = "field"
>   def getField() { "getter" }
> }
> @CompileStatic
> def usageCompileStatic() {
>   new Fields().Field
> }
> def usageCompileDynamic() {
>   new Fields().Field
> }
> println usageCompileDynamic() // field
> println usageCompileStatic() // getter{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8448) Local variable is accessible via explicit this

2018-01-15 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8448:
--

 Summary: Local variable is accessible via explicit this
 Key: GROOVY-8448
 URL: https://issues.apache.org/jira/browse/GROOVY-8448
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.4.13
Reporter: Daniil Ovchinnikov


{code:groovy}
def var = "local var"
new Runnable() {
  def getVar() { "getter" }
  void run() {
println var // as expected: local var
println this.var // expected: getter, actual: local var
  }
}.run()
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (GROOVY-8449) Inconsistency in accessing uppercase properties in @CompileStatic

2018-01-16 Thread Daniil Ovchinnikov (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-8449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-8449:
---
Description: 
{code:java|title=bugs.groovy}
class Fields {
  def Field = "field"
  def getField() { "getter" }
}

def usageCompileDynamic() {
  new Fields().Field
}

@CompileStatic 
def usageCompileStatic() { 
  new Fields().Field 
}

println usageCompileDynamic() // field
println usageCompileStatic() // getter{code}

  was:
{code:title=bugs.groovy}
class Fields {
  def Field = "field"
  def getField() { "getter" }
}

@CompileStatic
def usageCompileStatic() {
  new Fields().Field
}

def usageCompileDynamic() {
  new Fields().Field
}

println usageCompileDynamic() // field
println usageCompileStatic() // getter{code}


> Inconsistency in accessing uppercase properties in @CompileStatic
> -
>
> Key: GROOVY-8449
> URL: https://issues.apache.org/jira/browse/GROOVY-8449
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation
>Affects Versions: 2.4.13
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:java|title=bugs.groovy}
> class Fields {
>   def Field = "field"
>   def getField() { "getter" }
> }
> def usageCompileDynamic() {
>   new Fields().Field
> }
> @CompileStatic 
> def usageCompileStatic() { 
>   new Fields().Field 
> }
> println usageCompileDynamic() // field
> println usageCompileStatic() // getter{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (GROOVY-8447) It is allowed to define local variable of void type

2018-01-12 Thread Daniil Ovchinnikov (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-8447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-8447:
---
Description: 
{code:title=bugs.groovy}
void ff = 1
println ff
{code}

{noformat}
java.lang.ClassFormatError: Field "ff" in class bugs has illegal signature "V"
{noformat}


  was:
{code:title=bugs.groovy}
void ff = 1
println ff
{code}

{noformat}
java.lang.ClassFormatError: Field "ff" in class playground has illegal 
signature "V"
{noformat}



> It is allowed to define local variable of void type
> ---
>
> Key: GROOVY-8447
> URL: https://issues.apache.org/jira/browse/GROOVY-8447
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.13
>Reporter: Daniil Ovchinnikov
>
> {code:title=bugs.groovy}
> void ff = 1
> println ff
> {code}
> {noformat}
> java.lang.ClassFormatError: Field "ff" in class bugs has illegal signature "V"
> {noformat}



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


[jira] [Updated] (GROOVY-8447) It is allowed to define local variable of void type

2018-01-12 Thread Daniil Ovchinnikov (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-8447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-8447:
---
Description: 
{code:title=bugs.groovy}
void ff = 1
println ff
{code}

{noformat}
java.lang.ClassFormatError: Field "ff" in class playground has illegal 
signature "V"
{noformat}


  was:

{noformat}
java.lang.ClassFormatError: Field "ff" in class playground has illegal 
signature "V"
{noformat}



> It is allowed to define local variable of void type
> ---
>
> Key: GROOVY-8447
> URL: https://issues.apache.org/jira/browse/GROOVY-8447
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.13
>Reporter: Daniil Ovchinnikov
>
> {code:title=bugs.groovy}
> void ff = 1
> println ff
> {code}
> {noformat}
> java.lang.ClassFormatError: Field "ff" in class playground has illegal 
> signature "V"
> {noformat}



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


[jira] [Created] (GROOVY-8447) It is allowed to define local variable of void type

2018-01-12 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8447:
--

 Summary: It is allowed to define local variable of void type
 Key: GROOVY-8447
 URL: https://issues.apache.org/jira/browse/GROOVY-8447
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.4.13
Reporter: Daniil Ovchinnikov



{noformat}
java.lang.ClassFormatError: Field "ff" in class playground has illegal 
signature "V"
{noformat}




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


[jira] [Created] (GROOVY-8446) void[] return type causes compiler to fail

2018-01-12 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8446:
--

 Summary: void[] return type causes compiler to fail
 Key: GROOVY-8446
 URL: https://issues.apache.org/jira/browse/GROOVY-8446
 Project: Groovy
  Issue Type: Bug
  Components: Compiler
Affects Versions: 2.4.13
Reporter: Daniil Ovchinnikov


{noformat}
$ cat playground.groovy
void[] foo() {}
$ groovy playground.groovy
BUG! exception in phase 'conversion' in source unit '%path%/playground.groovy' 
null
Caused by: java.lang.IllegalArgumentException
{noformat}



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


[jira] [Commented] (GROOVY-8463) Inconsistency: setter imported with getter alias

2018-01-29 Thread Daniil Ovchinnikov (JIRA)

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

Daniil Ovchinnikov commented on GROOVY-8463:


Sorry, it appears I've already reported same issue

> Inconsistency: setter imported with getter alias
> 
>
> Key: GROOVY-8463
> URL: https://issues.apache.org/jira/browse/GROOVY-8463
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:java|title=com/foo/Bar.groovy}
> class Bar {
>   static def myProperty = 'hello'
> }
> {code}
> {code:java|title=bugs.groovy}
> import com.foo.Bar
> import static com.foo.Bar.setMyProperty as getAbc
> println Bar.@myProperty // as expected: 'hello'
> abc // -> getAbc() -> getAbc(null) -> setMyProperty(null)
> println Bar.@myProperty // expected: null, actual: 'hello', field value was 
> not updated
> getAbc() // -> getAbc(null) -> setMyProperty(null)
> println Bar.@myProperty // as expected: null, field was updated to null
> getAbc(42) // -> setMyProperty(42)
> println Bar.@myProperty // as expected: 42, field was updated to 42{code}
> {{abc}} should call setter as explicit {{getAbc()}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Resolved] (GROOVY-8463) Inconsistency: setter imported with getter alias

2018-01-29 Thread Daniil Ovchinnikov (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-8463?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov resolved GROOVY-8463.

Resolution: Duplicate

> Inconsistency: setter imported with getter alias
> 
>
> Key: GROOVY-8463
> URL: https://issues.apache.org/jira/browse/GROOVY-8463
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:java|title=com/foo/Bar.groovy}
> class Bar {
>   static def myProperty = 'hello'
> }
> {code}
> {code:java|title=bugs.groovy}
> import com.foo.Bar
> import static com.foo.Bar.setMyProperty as getAbc
> println Bar.@myProperty // as expected: 'hello'
> abc // -> getAbc() -> getAbc(null) -> setMyProperty(null)
> println Bar.@myProperty // expected: null, actual: 'hello', field value was 
> not updated
> getAbc() // -> getAbc(null) -> setMyProperty(null)
> println Bar.@myProperty // as expected: null, field was updated to null
> getAbc(42) // -> setMyProperty(42)
> println Bar.@myProperty // as expected: 42, field was updated to 42{code}
> {{abc}} should call setter as explicit {{getAbc()}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8463) Inconsistency: setter imported with getter alias

2018-01-29 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8463:
--

 Summary: Inconsistency: setter imported with getter alias
 Key: GROOVY-8463
 URL: https://issues.apache.org/jira/browse/GROOVY-8463
 Project: Groovy
  Issue Type: Bug
Reporter: Daniil Ovchinnikov


{code:java|title=com/foo/Bar.groovy}
class Bar {
  static def myProperty = 'hello'
}
{code}
{code:java|title=bugs.groovy}
import com.foo.Bar
import static com.foo.Bar.setMyProperty as getAbc

println Bar.@myProperty // as expected: 'hello'
abc // -> getAbc() -> getAbc(null) -> setMyProperty(null)
println Bar.@myProperty // expected: null, actual: 'hello', field value was not 
updated
getAbc() // -> getAbc(null) -> setMyProperty(null)
println Bar.@myProperty // as expected: null, field was updated to null
getAbc(42) // -> setMyProperty(42)
println Bar.@myProperty // as expected: 42, field was updated to 42{code}
{{abc}} should call setter as explicit {{getAbc()}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8417) Add @UseCategory annotation for classes/methods instead of use() everywhere

2017-12-22 Thread Daniil Ovchinnikov (JIRA)

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

Daniil Ovchinnikov commented on GROOVY-8417:


It can be just {{@Use(CoolCategory)}}

> Add @UseCategory annotation for classes/methods instead of use() everywhere
> ---
>
> Key: GROOVY-8417
> URL: https://issues.apache.org/jira/browse/GROOVY-8417
> Project: Groovy
>  Issue Type: New Feature
>  Components: ast builder, Compiler, syntax
>Affects Versions: 2.4.13
>Reporter: death lord
>Priority: Minor
>
> Adding an easier method to use categories without modifying configuration 
> files or repeating the same method everywhere (and adding an indent) would 
> help adjust new users and would allow for more practicality.



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


[jira] [Commented] (GROOVY-8403) Trait FieldHelper is not marked synthetic

2017-12-22 Thread Daniil Ovchinnikov (JIRA)

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

Daniil Ovchinnikov commented on GROOVY-8403:


Obvious question: is it intentional?

> Trait FieldHelper is not marked synthetic
> -
>
> Key: GROOVY-8403
> URL: https://issues.apache.org/jira/browse/GROOVY-8403
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Reporter: Daniil Ovchinnikov
>




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


[jira] [Created] (GROOVY-8658) MME on instance receiver via method closure

2018-06-21 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8658:
--

 Summary: MME on instance receiver via method closure
 Key: GROOVY-8658
 URL: https://issues.apache.org/jira/browse/GROOVY-8658
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.5.0
Reporter: Daniil Ovchinnikov


{code:groovy}
def c = String.
c() // IAE: object is not an instance of declaring class
c("hi") // MME: No signature of method: java.lang.String.toUpperCase() is 
applicable for argument types: (java.lang.String) values: [hi]
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8657) Resource variable is accessible from finally block

2018-06-21 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8657:
--

 Summary: Resource variable is accessible from finally block
 Key: GROOVY-8657
 URL: https://issues.apache.org/jira/browse/GROOVY-8657
 Project: Groovy
  Issue Type: Bug
Affects Versions: 3.0.0-alpha-2
Reporter: Daniil Ovchinnikov


From http://groovy-lang.org/releasenotes/groovy-3.0.html
{code:groovy}
try(
FromResource from = new FromResource("ARM was here!")
ToResource to = new ToResource()
) {
to << from
} finally {
assert from.closed // should throw MissingPropertyException
assert to.closed
assert to.toString() == 'ARM was here!'
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8660) Unexpected MethodSelectionException with implicit null argument

2018-06-22 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8660:
--

 Summary: Unexpected MethodSelectionException with implicit null 
argument
 Key: GROOVY-8660
 URL: https://issues.apache.org/jira/browse/GROOVY-8660
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.5.0, 2.4.15, 3.0.0-alpha-2
Reporter: Daniil Ovchinnikov


{code:groovy}
class OnlySingle {
def foo(a) { "single param: $a" }
}

println new OnlySingle().foo()
// as expected: 'single param: null'


class OnlyVararg {
def foo(a, ... b) { "vararg param: $a, $b" }
}

println new OnlyVararg().foo()
// as expected: 'MME: No signature of method: OnlyVararg.foo() is applicable 
for argument types: () values: []'

class Both {
def foo(a) { "single param: $a" }
def foo(a, ... b) { "vararg param: $a, $b" }
}

println new Both().foo()
// unexpected:
// MethodSelectionException: Could not find which method foo() to invoke from 
this list:
//  public java.lang.Object Both#foo(java.lang.Object)
//  public transient java.lang.Object Both#foo(java.lang.Object, 
[Ljava.lang.Object;)
{code}

If the exception is expected then {{OnlyVararg}} case should work too.
If the exception is unexpected then {{Both#foo(Object)}} should be selected.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8657) Resource variable is accessible from finally block

2018-06-22 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-8657:


[~daniel_sun] at least it should not be misused in release notes page, if 
cannot be fixed soon

> Resource variable is accessible from finally block
> --
>
> Key: GROOVY-8657
> URL: https://issues.apache.org/jira/browse/GROOVY-8657
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-alpha-2
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> From http://groovy-lang.org/releasenotes/groovy-3.0.html
> {code:groovy}
> try(
> FromResource from = new FromResource("ARM was here!")
> ToResource to = new ToResource()
> ) {
> to << from
> } finally {
> assert from.closed // should throw MissingPropertyException
> assert to.closed
> assert to.toString() == 'ARM was here!'
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8757) Incorrect bytecode produced after compiling class implementing trait with generic method

2018-08-20 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8757:
--

 Summary: Incorrect bytecode produced after compiling class 
implementing trait with generic method
 Key: GROOVY-8757
 URL: https://issues.apache.org/jira/browse/GROOVY-8757
 Project: Groovy
  Issue Type: Bug
  Components: Compiler
Affects Versions: 3.0.0-alpha-3, 2.4.15
Reporter: Daniil Ovchinnikov


{code:java|title=T.groovy}
trait T {
def  T foo(Class c) {
println c
return null 
}
}
{code}
{code:java|title=C.groovy}
class C implements T {}
{code}
{code:java|title=usage.groovy}
new C().foo(Integer)
{code}
{noformat}
$ groovyc C.groovy T.groovy
$ groovy usage.groovy
class java.lang.Integer
$ groovyc C.groovy # recompile C using already compiled T
$ groovy usage.groovy
Caught: java.lang.VerifyError: Bad return type
Exception Details:
  Location:
C.foo(Ljava/lang/Class;)Ljava/lang/Number; @5: areturn
  Reason:
Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 
'java/lang/Number' (from method signature)
  Current Frame:
bci: @5
flags: { }
locals: { 'C', 'java/lang/Class' }
stack: { 'java/lang/Object' }
  Bytecode:
0x000: 2a2b b600 88b0

java.lang.VerifyError: Bad return type
Exception Details:
  Location:
C.foo(Ljava/lang/Class;)Ljava/lang/Number; @5: areturn
  Reason:
Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 
'java/lang/Number' (from method signature)
  Current Frame:
bci: @5
flags: { }
locals: { 'C', 'java/lang/Class' }
stack: { 'java/lang/Object' }
  Bytecode:
0x000: 2a2b b600 88b0

at usage.run(usage.groovy:1)
{noformat}

{noformat:title=original javap output}
public class C implements T,groovy.lang.GroovyObject {
  public static transient boolean __$stMC;
  public C();
  public  T foo(java.lang.Class);
  public  T Ttrait$super$foo(java.lang.Class);
  static {};
  protected groovy.lang.MetaClass $getStaticMetaClass();
  public groovy.lang.MetaClass getMetaClass();
  public void setMetaClass(groovy.lang.MetaClass);
  public java.lang.Object invokeMethod(java.lang.String, java.lang.Object);
  public java.lang.Object getProperty(java.lang.String);
  public void setProperty(java.lang.String, java.lang.Object);
}
{noformat}

{noformat:title=recompiled javap output}
public class C implements T,groovy.lang.GroovyObject {
  public static transient boolean __$stMC;
  public C();
  public  T foo(java.lang.Class);
  public  T Ttrait$super$foo(java.lang.Class);
  static {};
  protected groovy.lang.MetaClass $getStaticMetaClass();
  public groovy.lang.MetaClass getMetaClass();
  public void setMetaClass(groovy.lang.MetaClass);
  public java.lang.Object invokeMethod(java.lang.String, java.lang.Object);
  public java.lang.Object getProperty(java.lang.String);
  public void setProperty(java.lang.String, java.lang.Object);
  public java.lang.Number foo(java.lang.Class);
}
{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8602) Safe index doesn't work with map arguments

2018-09-07 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-8602:


Sounds fair to me.

> Safe index doesn't work with map arguments
> --
>
> Key: GROOVY-8602
> URL: https://issues.apache.org/jira/browse/GROOVY-8602
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-alpha-2
>Reporter: Daniil Ovchinnikov
>Priority: Minor
>
> {{a[b:2]}} works.
> {{a?[b:2]}} produces {{Unexpected input: ''; Expecting ':' @ ...}}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8689) New line between constructor call and {}

2018-07-06 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8689:
--

 Summary: New line between constructor call and {}
 Key: GROOVY-8689
 URL: https://issues.apache.org/jira/browse/GROOVY-8689
 Project: Groovy
  Issue Type: Bug
  Components: parser-antlr4
Affects Versions: 3.0.0-alpha-3
Reporter: Daniil Ovchinnikov


{code:groovy}
new A() 
{}
{code}
is parsed as {{this.(new A())({})}} i.e. method call with constructor call as 
method expression.
This results in invocation of whatever `#toString()` returns which doesn't make 
sense.

In older version it was parsed as {{new A().call({})}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8496) Can't call default getProperty() implementation from superclass

2018-03-07 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8496:
--

 Summary: Can't call default getProperty() implementation from 
superclass
 Key: GROOVY-8496
 URL: https://issues.apache.org/jira/browse/GROOVY-8496
 Project: Groovy
  Issue Type: Bug
Reporter: Daniil Ovchinnikov


{code:title=GroovyClass.groovy}
class GroovyClass {}
{code}

{code:title=JavaClass.java}
class JavaClass extends GroovyClass { 
@Override
public Object getProperty(String propertyName) {
return super.getProperty(propertyName); 
// error: cannot find symbol: method getProperty(String)
}
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8495) GroovyObject method implementations are marked with ACC_SYNTHETIC

2018-03-06 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8495:
--

 Summary: GroovyObject method implementations are marked with 
ACC_SYNTHETIC
 Key: GROOVY-8495
 URL: https://issues.apache.org/jira/browse/GROOVY-8495
 Project: Groovy
  Issue Type: Bug
  Components: bytecode, class generator, Compiler
Reporter: Daniil Ovchinnikov


{code}
class GroovyClass {}
{code}

{noformat:title=javap -v (stripped)}
...
public class com.example.groovylib.GroovyClass implements 
groovy.lang.GroovyObject
  flags: ACC_PUBLIC, ACC_SUPER
...
{
  public static transient boolean __$stMC;
descriptor: Z
flags: ACC_PUBLIC, ACC_STATIC, ACC_TRANSIENT, ACC_SYNTHETIC

  public com.example.groovylib.GroovyClass();
descriptor: ()V
flags: ACC_PUBLIC

  protected groovy.lang.MetaClass $getStaticMetaClass();
descriptor: ()Lgroovy/lang/MetaClass;
flags: ACC_PROTECTED, ACC_SYNTHETIC

  public groovy.lang.MetaClass getMetaClass();
descriptor: ()Lgroovy/lang/MetaClass;
flags: ACC_PUBLIC, ACC_SYNTHETIC

  public void setMetaClass(groovy.lang.MetaClass);
descriptor: (Lgroovy/lang/MetaClass;)V
flags: ACC_PUBLIC, ACC_SYNTHETIC

  public java.lang.Object invokeMethod(java.lang.String, java.lang.Object);
descriptor: (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;
flags: ACC_PUBLIC, ACC_SYNTHETIC

  public java.lang.Object getProperty(java.lang.String);
descriptor: (Ljava/lang/String;)Ljava/lang/Object;
flags: ACC_PUBLIC, ACC_SYNTHETIC

  public void setProperty(java.lang.String, java.lang.Object);
descriptor: (Ljava/lang/String;Ljava/lang/Object;)V
flags: ACC_PUBLIC, ACC_SYNTHETIC
}
SourceFile: "GroovyClass.groovy"
{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8497) Can't call getProperty() from Java

2018-03-07 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8497:
--

 Summary: Can't call getProperty() from Java
 Key: GROOVY-8497
 URL: https://issues.apache.org/jira/browse/GROOVY-8497
 Project: Groovy
  Issue Type: Bug
Reporter: Daniil Ovchinnikov


{code:title=GroovyClass.groovy}
class GroovyClass {}
{code}

{code:title=JavaClass.java}
class JavaClass {
void usage() {
new GroovyClass().getProperty("a"); 
// error: cannot find symbol: method getProperty(String)
}
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (GROOVY-8496) Can't call default getProperty() implementation from Java subclass

2018-03-07 Thread Daniil Ovchinnikov (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-8496?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-8496:
---
Summary: Can't call default getProperty() implementation from Java subclass 
 (was: Can't call default getProperty() implementation from superclass)

> Can't call default getProperty() implementation from Java subclass
> --
>
> Key: GROOVY-8496
> URL: https://issues.apache.org/jira/browse/GROOVY-8496
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:title=GroovyClass.groovy}
> class GroovyClass {}
> {code}
> {code:title=JavaClass.java}
> class JavaClass extends GroovyClass { 
> @Override
> public Object getProperty(String propertyName) {
> return super.getProperty(propertyName); 
> // error: cannot find symbol: method getProperty(String)
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8490) Extend @Newify to support a class name pattern parameter

2018-03-05 Thread Daniil Ovchinnikov (JIRA)

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

Daniil Ovchinnikov commented on GROOVY-8490:


{code}
import com.foo.Bar
import com.foo.Bar as Baz

@Newify(classNamePattern=/Baz/)
def usage() {
  Bar() 
  Baz() 
}
{code}

Which one of the invocations should throw MME? 
In other words, should the pattern be tested against the reference name or the 
class name?


> Extend @Newify to support a class name pattern parameter
> 
>
> Key: GROOVY-8490
> URL: https://issues.apache.org/jira/browse/GROOVY-8490
> Project: Groovy
>  Issue Type: Improvement
>  Components: Compiler
>Reporter: mgroovy
>Priority: Major
>
> * @Newify should be extended to support a classNamePattern parameter
> * All class names inside e.g. a @Newify annotated class that match the given 
> pattern shall support having its ctor called without the new keyword ("Python 
> style")
> * Example:
> {code}
> @Newify(classNamePattern=/[A-Z].*/)
> class Foo {
>   // Any class whose name starts with an uppercase letter
>   // can have its ctors called without new keyword inside Foo
>   
>   String s
>   Integer x
>   File f
>   
>   Foo(String s, File f, Integer x) { 
> this.s = s
> this.f = f
> this.x = x
>   }
>   
>   void createFoo(File base) {
> // Java style
> new Foo(new String('abc'), new File(base,'log'), new Integer(123))
> // new Groovy style
> Foo(String('abc'), File(base,'log'), Integer(123))
>   }
> } 
> {code}
> * The classNamePattern parameter:
> ## Is 100% backwards compatible (same as the existing value parameter)
> ## Would allow e.g. @Newify(classNamePattern=/[A-Z].*/) to be auto-applied to 
> all classes in a project (same as e.g. @AutoFinal (GROOVY-8300))
> *** In practice that would typically cover 99.9...% of all classes, since 
> most projects follow the Java convention of classes being the only callable 
> entities to start with an uppercase letter
> *** The existing value parameter cannot be used that way on a global level, 
> since it is not practical to explicitly list all project classes
> ## Compile time performance wise classNamePattern=/[A-Z].*/ avoids having to 
> check any (method/field/variable)() call whether it is a class ctor call if 
> it is lowercase (i.e. again typically in 99.9...% of cases), i.e. the 
> approach is fast



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8845) @DelegatesTo works only for the first vararg

2018-10-15 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-8845:


Please close if this is intended.

> @DelegatesTo works only for the first vararg
> 
>
> Key: GROOVY-8845
> URL: https://issues.apache.org/jira/browse/GROOVY-8845
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.3
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:groovy}
> def md(@DelegatesTo.Target Object target, @DelegatesTo(strategy = 
> Closure.DELEGATE_FIRST) Closure... arg) {
> for (Closure a : arg) {
> a.delegate = target
> a.resolveStrategy = Closure.DELEGATE_FIRST
> a()
> }
> }
> class D {
>   def foo() { 42 }
> }
> @groovy.transform.CompileStatic
> def test() {
> md(
>   new D(), 
>   { print(foo()) }, 
> //  { print(foo()) }, // [Static type checking] - Cannot find matching 
> method ConsoleScript15#foo()
> //  { print(foo()) }, // [Static type checking] - Cannot find matching 
> method ConsoleScript15#foo()
> )
> }
> test()
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8845) @DelegatesTo works only for the first vararg

2018-10-15 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8845:
--

 Summary: @DelegatesTo works only for the first vararg
 Key: GROOVY-8845
 URL: https://issues.apache.org/jira/browse/GROOVY-8845
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.3
Reporter: Daniil Ovchinnikov


{code:groovy}
def md(@DelegatesTo.Target Object target, @DelegatesTo(strategy = 
Closure.DELEGATE_FIRST) Closure... arg) {
for (Closure a : arg) {
a.delegate = target
a.resolveStrategy = Closure.DELEGATE_FIRST
a()
}
}

class D {
  def foo() { 42 }
}

@groovy.transform.CompileStatic
def test() {
md(
  new D(), 
  { print(foo()) }, 
//  { print(foo()) }, // [Static type checking] - Cannot find matching 
method ConsoleScript15#foo()
//  { print(foo()) }, // [Static type checking] - Cannot find matching 
method ConsoleScript15#foo()
)
}

test()
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8961) Cannot pass generic list into explicit setter

2019-01-18 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8961:
--

 Summary: Cannot pass generic list into explicit setter
 Key: GROOVY-8961
 URL: https://issues.apache.org/jira/browse/GROOVY-8961
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.5
Reporter: Daniil Ovchinnikov


{code}
class GC {
void setStrings(List ss) {}
}

@groovy.transform.CompileStatic
void usage(GC gc) {
gc.strings = Collections.emptyList()
}
{code}

{noformat}
[Static type checking] - Cannot assign value of type java.util.List  to variable of type java.util.List 
 at line: 7, column: 5
{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8965) instanceof with || inserts wrong cast

2019-01-22 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8965:
--

 Summary: instanceof with || inserts wrong cast
 Key: GROOVY-8965
 URL: https://issues.apache.org/jira/browse/GROOVY-8965
 Project: Groovy
  Issue Type: Bug
  Components: Static compilation
Affects Versions: 2.5.5
Reporter: Daniil Ovchinnikov


{code:java}
@groovy.transform.CompileStatic
def foo(a) {
if (a instanceof Integer || a instanceof Double) {
a.floatValue() // expected: cast to Number; actual: cast to Integer
}
}

println foo(1d).class // CCE: java.lang.Double cannot be cast to 
java.lang.Integer
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8909) List literal type inference does not take its context into account

2018-12-05 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8909:
--

 Summary: List literal type inference does not take its context 
into account
 Key: GROOVY-8909
 URL: https://issues.apache.org/jira/browse/GROOVY-8909
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.4
Reporter: Daniil Ovchinnikov


{code:title=bug.groovy}
def methodAcceptingListOfObjects(List lo) {}

@groovy.transform.CompileStatic
def usage() {
methodAcceptingListOfObjects([1, 2, 3]) 
}
{code}
Compilation fails with
{noformat}
[Static type checking] - Cannot call 
#methodAcceptingListOfObjects(java.util.List ) with arguments 
[java.util.List ]
{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8896) Cannot create instance of inner class with list literals

2018-11-20 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8896:
--

 Summary: Cannot create instance of inner class with list literals
 Key: GROOVY-8896
 URL: https://issues.apache.org/jira/browse/GROOVY-8896
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.5.4
Reporter: Daniil Ovchinnikov


{code:java}
import groovy.transform.*

class Outer {

  @ToString
  @TupleConstructor
  class Inner {
def ff
  }

  void createStuff() {
println new Inner(20) // Outer$Inner(20) as expected
println new Inner(ff: 20) // Outer$Inner(20) as expected

Inner i1 = [22] // Could not find matching constructor for: 
Outer$Inner(Integer)
println i1

def i1_ = [23] as Inner // Could not find matching constructor for: 
Outer$Inner(Integer)
println i1_

Inner i2 = [ff: 33] // Could not find which method () to invoke from 
this list:
 // public Outer$Inner#(Outer)
 // public Outer$Inner#(Outer, java.util.LinkedHashMap)
 // public Outer$Inner#(Outer, java.lang.Object)
println i2

def i2_ = [ff: 33] as Inner // Error casting map to Outer$Inner, Reason: 
null
println i2_
  }
}

new Outer().createStuff(){code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8787) Inconsistency in method selection with @CompileStatic

2018-09-13 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-8787:


[~blackdrag] Yep, I understand the difference, that's why I came here to make 
sure this case (when all types are known and they are the same in both dynamic 
and static modes) is a bug. Thank you.

Could you please also check out the related issue?

> 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)


[jira] [Updated] (GROOVY-8787) Inconsistency in method selection with @CompileStatic

2018-09-13 Thread Daniil Ovchinnikov (JIRA)


 [ 
https://issues.apache.org/jira/browse/GROOVY-8787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-8787:
---
Component/s: Static compilation

> 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)


[jira] [Commented] (GROOVY-8787) Inconsistency in method selection with @CompileStatic

2018-09-13 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-8787:


I'd like to know what would be the correct behaviour, so I would be able to 
update resolution in IntelliJ.

> 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 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)


[jira] [Commented] (GROOVY-8788) Inconsistency in extension method selection with @CompileStatic

2018-09-13 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-8788:


Possibly the same cause.

> Inconsistency in extension method selection with @CompileStatic
> ---
>
> Key: GROOVY-8788
> URL: https://issues.apache.org/jira/browse/GROOVY-8788
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Affects Versions: 2.4.15, 2.5.2
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> Given properly registered extension class:
> {code:java|title=MyExtensions.java}
> public class MyExtensions {
> public static void foo(Object self, String s) {
> System.out.println("Object#foo(String)");
> }
> public static void foo(String self, Object o) {
> System.out.println("String#foo(Object)");
> }
> }
> {code}
> Run
> {code:java|title=playground.groovy}
> void usageExt() {
> "".foo("") // prints "Object#foo(String)" which is correct
> }
> @groovy.transform.CompileStatic
> void usageExtStatic() {
> "".foo("") // prints "String#foo(Object)" which is questionable
> }
> usageExt()
> usageExtStatic()
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8974) STC ignores declaration type

2019-01-28 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8974:
--

 Summary: STC ignores declaration type
 Key: GROOVY-8974
 URL: https://issues.apache.org/jira/browse/GROOVY-8974
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.5
Reporter: Daniil Ovchinnikov


{code:java}
static  T id(T arg) { arg }

@groovy.transform.CompileStatic
def ddd() {
  List ls = id(new ArrayList<>())
  ls.get(0).toUpperCase() // Cannot find matching method 
java.lang.Object#toUpperCase()
}

println ddd()
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (GROOVY-9033) Bad code green: empty list literal with each method

2019-03-13 Thread Daniil Ovchinnikov (JIRA)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9033:
---
Affects Version/s: 2.5.6

> Bad code green: empty list literal with each method
> ---
>
> Key: GROOVY-9033
> URL: https://issues.apache.org/jira/browse/GROOVY-9033
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.6
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:java}
> @groovy.transform.CompileStatic
> List usage() {
>   def l = [].each {}
>   return l // expected error: Incompatible generic argument types. Cannot 
> assign java.util.List  to: java.util.List  
> }
> println usage(){code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-9033) Bad code green: empty list literal with each method

2019-03-13 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-9033:
--

 Summary: Bad code green: empty list literal with each method
 Key: GROOVY-9033
 URL: https://issues.apache.org/jira/browse/GROOVY-9033
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Reporter: Daniil Ovchinnikov


{code:java}
@groovy.transform.CompileStatic
List usage() {
  def l = [].each {}
  return l // expected error: Incompatible generic argument types. Cannot 
assign java.util.List  to: java.util.List  
}

println usage(){code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (GROOVY-9033) Bad code green: empty list literal with each method

2019-03-13 Thread Daniil Ovchinnikov (JIRA)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9033:
---
Description: 
{code:groovy}
@groovy.transform.CompileStatic
List usage() {
  def l = [].each {}
  return l // expected error: Incompatible generic argument types. Cannot 
assign java.util.List  to: java.util.List  
}{code}

  was:
{code:java}
@groovy.transform.CompileStatic
List usage() {
  def l = [].each {}
  return l // expected error: Incompatible generic argument types. Cannot 
assign java.util.List  to: java.util.List  
}

println usage(){code}


> Bad code green: empty list literal with each method
> ---
>
> Key: GROOVY-9033
> URL: https://issues.apache.org/jira/browse/GROOVY-9033
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.6
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:groovy}
> @groovy.transform.CompileStatic
> List usage() {
>   def l = [].each {}
>   return l // expected error: Incompatible generic argument types. Cannot 
> assign java.util.List  to: java.util.List  
> }{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8984) Can assign Collection with super wildcard to Array

2019-02-08 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8984:
--

 Summary: Can assign Collection with super wildcard to Array
 Key: GROOVY-8984
 URL: https://issues.apache.org/jira/browse/GROOVY-8984
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.6
Reporter: Daniil Ovchinnikov


{code:java}
Collection foo() {[new Object()]}

@groovy.transform.CompileStatic
def usage() {
  Runnable[] ar = foo() // here
  ar
}

println usage()
{code}
Expected: compilation should fail
 Actual: compilation completes and execution fails with {{Cannot cast object 
'java.lang.Object@65e98b1c' with class 'java.lang.Object' to class 
'java.lang.Runnable'}}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8983) Cannot assign Collection to Array

2019-02-08 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8983:
--

 Summary: Cannot assign Collection to Array
 Key: GROOVY-8983
 URL: https://issues.apache.org/jira/browse/GROOVY-8983
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.6
Reporter: Daniil Ovchinnikov


{code:java}
Collection foo() {}

@groovy.transform.CompileStatic
def usage() {
  Runnable[] ar = foo() // OK as expected
}

@groovy.transform.CompileStatic
def usage(Collection cr) {
  Runnable[] ar = cr // [Static type checking] - Cannot assign value of type 
java.util.Collection  to variable of type 
java.lang.Runnable[]
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (GROOVY-9076) Debugger Step Into doesn't work in Groovy-compiled classes

2019-04-12 Thread Daniil Ovchinnikov (JIRA)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9076?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9076:
---
Description: 
Please see https://github.com/dovchinnikov/debug-groovy-bug
{code:title=GC.groovy}
package foo.bar

class GC {

GC() {
int i = 42
}

int getStuff() {
return 70
}
}
{code}

{code:title=GMain.groovy}
package foo.bar

class GMain {

static void main(String[] args) {
new GC().stuff // set breakpoint here
}
} 
{code}

  was:
Please see https://github.com/dovchinnikov/debug-groovy-bug



> Debugger Step Into doesn't work in Groovy-compiled classes
> --
>
> Key: GROOVY-9076
> URL: https://issues.apache.org/jira/browse/GROOVY-9076
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.6
>Reporter: Daniil Ovchinnikov
>Priority: Blocker
>
> Please see https://github.com/dovchinnikov/debug-groovy-bug
> {code:title=GC.groovy}
> package foo.bar
> class GC {
> GC() {
> int i = 42
> }
> int getStuff() {
> return 70
> }
> }
> {code}
> {code:title=GMain.groovy}
> package foo.bar
> class GMain {
> static void main(String[] args) {
> new GC().stuff // set breakpoint here
> }
> } 
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-9076) Debugger Step Into doesn't work in Groovy-compiled classes

2019-04-11 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-9076:
--

 Summary: Debugger Step Into doesn't work in Groovy-compiled classes
 Key: GROOVY-9076
 URL: https://issues.apache.org/jira/browse/GROOVY-9076
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.5.6
Reporter: Daniil Ovchinnikov


Please see https://github.com/dovchinnikov/debug-groovy-bug




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-9076) Debugger Step Into doesn't work in Groovy-compiled classes

2019-04-19 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-9076:


[~emilles] what's the "int" optimization and how to disable it?

 

> Debugger Step Into doesn't work in Groovy-compiled classes
> --
>
> Key: GROOVY-9076
> URL: https://issues.apache.org/jira/browse/GROOVY-9076
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.6
> Environment: $ java -version
> java version "1.8.0_211"
> Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
> Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
>Reporter: Daniil Ovchinnikov
>Priority: Blocker
>
> Please see https://github.com/dovchinnikov/debug-groovy-bug
> {code:title=GC.groovy}
> package foo.bar
> class GC {
> GC() {
> int i = 42
> }
> int getStuff() {
> return 70
> }
> }
> {code}
> {code:title=GMain.groovy}
> package foo.bar
> class GMain {
> static void main(String[] args) {
> new GC().stuff // set breakpoint here
> }
> } 
> {code}
> This issue is reproducible with plain raw jdb:
> {noformat}
> $ ./gradlew clean classes
> $ jdb -classpath build/classes/groovy/main:
> {noformat}
> Inside jdb prompt:
> {noformat}
> > sourcepath src/main/groovy
> > exclude 
> > java.*,sun.*,com.sun.*,groovy.*,org.codehaus.groovy.*,org.apache.groovy.*
> > stop in foo.bar.GMain.main
> > run foo.bar.GMain
> {noformat}
> Then {{step}} until the end and observe the behaviour.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (GROOVY-9076) Debugger Step Into doesn't work in Groovy-compiled classes

2019-04-19 Thread Daniil Ovchinnikov (JIRA)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9076?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9076:
---
Environment: 
$ java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

> Debugger Step Into doesn't work in Groovy-compiled classes
> --
>
> Key: GROOVY-9076
> URL: https://issues.apache.org/jira/browse/GROOVY-9076
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.6
> Environment: $ java -version
> java version "1.8.0_211"
> Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
> Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
>Reporter: Daniil Ovchinnikov
>Priority: Blocker
>
> Please see https://github.com/dovchinnikov/debug-groovy-bug
> {code:title=GC.groovy}
> package foo.bar
> class GC {
> GC() {
> int i = 42
> }
> int getStuff() {
> return 70
> }
> }
> {code}
> {code:title=GMain.groovy}
> package foo.bar
> class GMain {
> static void main(String[] args) {
> new GC().stuff // set breakpoint here
> }
> } 
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (GROOVY-9076) Debugger Step Into doesn't work in Groovy-compiled classes

2019-04-19 Thread Daniil Ovchinnikov (JIRA)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9076?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9076:
---
Description: 
Please see https://github.com/dovchinnikov/debug-groovy-bug
{code:title=GC.groovy}
package foo.bar

class GC {

GC() {
int i = 42
}

int getStuff() {
return 70
}
}
{code}

{code:title=GMain.groovy}
package foo.bar

class GMain {

static void main(String[] args) {
new GC().stuff // set breakpoint here
}
} 
{code}

This issue is reproducible with plain raw jdb:
{noformat}
$ ./gradlew clean classes
$ jdb -classpath build/classes/groovy/main:
{noformat}
Inside jdb prompt:
{noformat}
> sourcepath src/main/groovy
> exclude 
> java.*,sun.*,com.sun.*,groovy.*,org.codehaus.groovy.*,org.apache.groovy.*
> stop in foo.bar.GMain.main
> run foo.bar.GMain
{noformat}
Then {{step}} until the end and observe the behaviour.

  was:
Please see https://github.com/dovchinnikov/debug-groovy-bug
{code:title=GC.groovy}
package foo.bar

class GC {

GC() {
int i = 42
}

int getStuff() {
return 70
}
}
{code}

{code:title=GMain.groovy}
package foo.bar

class GMain {

static void main(String[] args) {
new GC().stuff // set breakpoint here
}
} 
{code}


> Debugger Step Into doesn't work in Groovy-compiled classes
> --
>
> Key: GROOVY-9076
> URL: https://issues.apache.org/jira/browse/GROOVY-9076
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.6
> Environment: $ java -version
> java version "1.8.0_211"
> Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
> Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
>Reporter: Daniil Ovchinnikov
>Priority: Blocker
>
> Please see https://github.com/dovchinnikov/debug-groovy-bug
> {code:title=GC.groovy}
> package foo.bar
> class GC {
> GC() {
> int i = 42
> }
> int getStuff() {
> return 70
> }
> }
> {code}
> {code:title=GMain.groovy}
> package foo.bar
> class GMain {
> static void main(String[] args) {
> new GC().stuff // set breakpoint here
> }
> } 
> {code}
> This issue is reproducible with plain raw jdb:
> {noformat}
> $ ./gradlew clean classes
> $ jdb -classpath build/classes/groovy/main:
> {noformat}
> Inside jdb prompt:
> {noformat}
> > sourcepath src/main/groovy
> > exclude 
> > java.*,sun.*,com.sun.*,groovy.*,org.codehaus.groovy.*,org.apache.groovy.*
> > stop in foo.bar.GMain.main
> > run foo.bar.GMain
> {noformat}
> Then {{step}} until the end and observe the behaviour.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-9076) Debugger Step Into doesn't work in Groovy-compiled classes

2019-04-19 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-9076:


[~emilles] the issue is reproducible with class files produced by {{gradle 
clean classes}}

> Debugger Step Into doesn't work in Groovy-compiled classes
> --
>
> Key: GROOVY-9076
> URL: https://issues.apache.org/jira/browse/GROOVY-9076
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.6
> Environment: $ java -version
> java version "1.8.0_211"
> Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
> Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
>Reporter: Daniil Ovchinnikov
>Priority: Blocker
>
> Please see https://github.com/dovchinnikov/debug-groovy-bug
> {code:title=GC.groovy}
> package foo.bar
> class GC {
> GC() {
> int i = 42
> }
> int getStuff() {
> return 70
> }
> }
> {code}
> {code:title=GMain.groovy}
> package foo.bar
> class GMain {
> static void main(String[] args) {
> new GC().stuff // set breakpoint here
> }
> } 
> {code}
> This issue is reproducible with plain raw jdb:
> {noformat}
> $ ./gradlew clean classes
> $ jdb -classpath build/classes/groovy/main:
> {noformat}
> Inside jdb prompt:
> {noformat}
> > sourcepath src/main/groovy
> > exclude 
> > java.*,sun.*,com.sun.*,groovy.*,org.codehaus.groovy.*,org.apache.groovy.*
> > stop in foo.bar.GMain.main
> > run foo.bar.GMain
> {noformat}
> Then {{step}} until the end and observe the behaviour.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (GROOVY-9209) Compiler throws an exception in ClassNode#getTypeClass after checking ClassNode#isResolved

2019-07-29 Thread Daniil Ovchinnikov (JIRA)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9209?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9209:
---
Description: 
{noformat}
Error:Groovyc: While compiling mn-gorm-example.main: BUG! exception in phase 
'canonicalization' in source unit 
'/Users/pditommaso/Projects/mn-gorm-example/src/main/groovy/example/gorm/Bootstrap.groovy'
 JVM class can't be loaded for example.gorm.service.PersonService
at 
org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveJvmClass(AsmReferenceResolver.java:86)
at 
org.codehaus.groovy.ast.decompiled.DecompiledClassNode.getTypeClass(DecompiledClassNode.java:175)
at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1381)
at 
io.micronaut.ast.groovy.InjectTransform$InjectVisitor.resolveParameterType(InjectTransform.groovy:1117)
...
{noformat}
{code:java|title=InjectVisitor#resolveParameterType}
ClassNode parameterType = parameter.type
if (parameterType.isResolved()) {
  parameterType.typeClass // here 
} else {
  parameterType.name
}
{code}
Code: [https://github.com/pditommaso/mn-gorm-example]
 Steps to reproduce:
 1. make sure the build is not delegated to Gradle in Preferences | Build, 
Execution, Deployment | Build Tools | Gradle
 2. rebuild project
 3. make changes in Person.groovy and Bootstrap.groovy (to mark them as subject 
for recompilation)
 4. build project

What happens with {{-Dgroovyc.asm.resolving.only=false}}:
 1. Bootstrap.groovy and Person.groovy are added to 
{{CompilationUnit#queuedSources}}
 2. {{ResolveVisitor}} visits Bootstrap.groovy and tries to load PersonService
 3. {{asmResolving}} flag is set to {{false}} by IntelliJ, this results in 
skipping {{findDecompiled}} call inside 
{{ClassNodeResolver#tryAsLoaderClassOrScript}}
 4. the PersonService class fails to load because of missing Person class
 5. {{tryAsScript}} kicks in and adds PersonService to 
{{CompilationUnit#queuedSources}}
 6. when it comes to Micronaut {{ClassNode#isResolved}} returns {{false}} for 
PersonService

What happens without {{-Dgroovyc.asm.resolving.only=false}}:
 1. same
 2. same
 3. {{asmResolving}} is not set by IntellliJ
 4. {{findDecompiled}} returns {{DecompiledClassNode}} for PersonService
 5. when it comes to Micronaut {{ClassNode#isResolved}} returns {{true}} for 
PersonService, and this results in an exception because the class cannot be 
loaded actually.

I've tried to fix it in the compiler but I'm not sure what's the proper fix 
would be. 
 Please let me know if I can do something within IntelliJ. 
 The issue in JB YouTrack for the reference: 
[https://youtrack.jetbrains.com/issue/IDEA-218698]

  was:
{noformat}
Error:Groovyc: While compiling mn-gorm-example.main: BUG! exception in phase 
'canonicalization' in source unit 
'/Users/pditommaso/Projects/mn-gorm-example/src/main/groovy/example/gorm/Bootstrap.groovy'
 JVM class can't be loaded for example.gorm.service.PersonService
at 
org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveJvmClass(AsmReferenceResolver.java:86)
at 
org.codehaus.groovy.ast.decompiled.DecompiledClassNode.getTypeClass(DecompiledClassNode.java:175)
at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1381)
at 
io.micronaut.ast.groovy.InjectTransform$InjectVisitor.resolveParameterType(InjectTransform.groovy:1117)
...
{noformat}
{code:java|title=InjectVisitor#resolveParameterType}
ClassNode parameterType = parameter.type
if (parameterType.isResolved()) {
  parameterType.typeClass // here 
} else {
  parameterType.name
}
{code}
Code: [https://github.com/pditommaso/mn-gorm-example]
 Steps to reproduce:
 1. make sure the build is not delegated to Gradle in Preferences | Build, 
Execution, Deployment | Build Tools | Gradle
 2. rebuild project
 3. make changes in Person.groovy and Bootstrap.groovy (to mark them as subject 
for recompilation)
 4. build project

What happens with {{-Dgroovyc.asm.resolving.only=false}}:
1. Bootstrap.groovy and Person.groovy are added to 
{{CompilationUnit#queuedSources}}
2. {{ResolveVisitor}} visits Bootstrap.groovy and tries to load PersonService
3. {{asmResolving}} flag is set to {{false}} by IntelliJ, this results in 
skipping {{findDecompiled}} call inside 
{{ClassNodeResolver#tryAsLoaderClassOrScript}}
4. the PersonService class fails to load because of missing Person class
5. {{tryAsScript}} kicks in and adds PersonService to 
{{CompilationUnit#queuedSources}}
6. when it comes to Micronaut {{ClassNode#isResolved}} returns {{false}} for 
PersonService

What happens with {{asmResolving}}:
1. same
2. same
3. {{asmResolving}} is not set by IntellliJ
4. {{findDecompiled}} returns {{DecompiledClassNode}} for PersonService
5. when it comes to Micronaut {{ClassNode#isResolved}} returns {{true}} for 
PersonService, and this results in an exception because the class cannot be 
loaded actually.

I've tried to fix 

[jira] [Commented] (GROOVY-9209) Compiler throws an exception in ClassNode#getTypeClass after checking ClassNode#isResolved

2019-07-31 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-9209:


[~blackdrag] thank you for looking into this. 

bq. Maybe it would be more correct for DecompiledClassNode to not to return 
true for isResolved
That was my first thought, I'm not sure about semantics of isResolved. I seems 
that generally it's used to determine whether ClassNode is _resolved_, i.e. 
whether it's possible to obtain its methods or to obtain ClassNode for its 
super, etc, so I'd say DecompiledClassNode must return true if it was found and 
instantiated. 

bq. getTypeClass should be removed from ClassNode
I'd say this is the way, but it'll break AST transformations, so I'm not the 
right person to do it, so I'm leaving this up to you.

cc [~graemerocher1]

> Compiler throws an exception in ClassNode#getTypeClass after checking 
> ClassNode#isResolved
> --
>
> Key: GROOVY-9209
> URL: https://issues.apache.org/jira/browse/GROOVY-9209
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 2.5.6
> Environment: intellij idea
>Reporter: Daniil Ovchinnikov
>Priority: Critical
>
> {noformat}
> Error:Groovyc: While compiling mn-gorm-example.main: BUG! exception in phase 
> 'canonicalization' in source unit 
> '/Users/pditommaso/Projects/mn-gorm-example/src/main/groovy/example/gorm/Bootstrap.groovy'
>  JVM class can't be loaded for example.gorm.service.PersonService
>   at 
> org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveJvmClass(AsmReferenceResolver.java:86)
>   at 
> org.codehaus.groovy.ast.decompiled.DecompiledClassNode.getTypeClass(DecompiledClassNode.java:175)
>   at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1381)
>   at 
> io.micronaut.ast.groovy.InjectTransform$InjectVisitor.resolveParameterType(InjectTransform.groovy:1117)
> ...
> {noformat}
> {code:java|title=InjectVisitor#resolveParameterType}
> ClassNode parameterType = parameter.type
> if (parameterType.isResolved()) {
>   parameterType.typeClass // here 
> } else {
>   parameterType.name
> }
> {code}
> Code: [https://github.com/pditommaso/mn-gorm-example]
>  Steps to reproduce:
>  1. make sure the build is not delegated to Gradle in Preferences | Build, 
> Execution, Deployment | Build Tools | Gradle
>  2. rebuild project
>  3. make changes in Person.groovy and Bootstrap.groovy (to mark them as 
> subject for recompilation)
>  4. build project
> What happens with {{-Dgroovyc.asm.resolving.only=false}}:
>  1. Bootstrap.groovy and Person.groovy are added to 
> {{CompilationUnit#queuedSources}}
>  2. {{ResolveVisitor}} visits Bootstrap.groovy and tries to load PersonService
>  3. {{asmResolving}} flag is set to {{false}} by IntelliJ, this results in 
> skipping {{findDecompiled}} call inside 
> {{ClassNodeResolver#tryAsLoaderClassOrScript}}
>  4. the PersonService class fails to load because of missing Person class
>  5. {{tryAsScript}} kicks in and adds PersonService to 
> {{CompilationUnit#queuedSources}}
>  6. when it comes to Micronaut {{ClassNode#isResolved}} returns {{false}} for 
> PersonService
> What happens without {{-Dgroovyc.asm.resolving.only=false}}:
>  1. same
>  2. same
>  3. {{asmResolving}} is not set by IntellliJ
>  4. {{findDecompiled}} returns {{DecompiledClassNode}} for PersonService
>  5. when it comes to Micronaut {{ClassNode#isResolved}} returns {{true}} for 
> PersonService, and this results in an exception because the class cannot be 
> loaded actually.
> I've tried to fix it in the compiler but I'm not sure what's the proper fix 
> would be. 
>  Please let me know if I can do something within IntelliJ. 
>  The issue in JB YouTrack for the reference: 
> [https://youtrack.jetbrains.com/issue/IDEA-218698]



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)


[jira] [Created] (GROOVY-9204) Compiler loses type info of superclass field

2019-07-24 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-9204:
--

 Summary: Compiler loses type info of superclass field
 Key: GROOVY-9204
 URL: https://issues.apache.org/jira/browse/GROOVY-9204
 Project: Groovy
  Issue Type: Bug
  Components: Static compilation, Static Type Checker
Affects Versions: 2.5.7
Reporter: Daniil Ovchinnikov


{code:java|title=foo/bar/classes.java}
package foo.bar;

class F {
void hi() {}
}

abstract class Base {
protected T theField;
}

abstract class Middle extends Base {}

abstract class Concrete extends Middle {}
{code}
{code:java|title=foo/bar/GroovyUsage.groovy}
package foo.bar

@groovy.transform.CompileStatic
class GroovyUsage extends Concrete {

def usage() {
theField.hi() // Error:(7, 9) Groovyc: [Static type checking] - Cannot 
find matching method java.lang.Object#hi(). Please check if the declared type 
is correct and if the method exists.
}
}
{code}
Note this was working with 2.4.17.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)


[jira] [Updated] (GROOVY-9328) Cannot call private method of containing class in @CS

2019-12-04 Thread Daniil Ovchinnikov (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9328?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9328:
---
Description: 
{code:java}
class C {

private C() {}
private privateMethod() {}

def anonymousUsage() {
new Runnable() {
@groovy.transform.CompileStatic
@Override
void run() {
privateMethod()
new C()
}
}
}
}{code}
Expected: code is compiled without errors.
 Actual: 2  errors:
{{Cannot call private method C#privateMethod from class C$1}}
{{Cannot call private constructor for C from class C$1}}

Note that Java compiles the same code just fine.

  was:
{code:java}
class C {

private privateMethod() {}

def anonymousUsage() {
new Runnable() {
@groovy.transform.CompileStatic
@Override
void run() {
privateMethod()
}
}
}
} {code}
Expected: code is compiled without errors.
 Actual: {{Cannot call private method C#privateMethod from class C$1}}

Note that Java compiles the same code just fine.


> Cannot call private method of containing class in @CS
> -
>
> Key: GROOVY-9328
> URL: https://issues.apache.org/jira/browse/GROOVY-9328
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.8
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:java}
> class C {
> private C() {}
> private privateMethod() {}
> def anonymousUsage() {
> new Runnable() {
> @groovy.transform.CompileStatic
> @Override
> void run() {
> privateMethod()
> new C()
> }
> }
> }
> }{code}
> Expected: code is compiled without errors.
>  Actual: 2  errors:
> {{Cannot call private method C#privateMethod from class C$1}}
> {{Cannot call private constructor for C from class C$1}}
> Note that Java compiles the same code just fine.



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


[jira] [Updated] (GROOVY-9328) Cannot call private member of containing class in @CS

2019-12-04 Thread Daniil Ovchinnikov (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9328?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9328:
---
Summary: Cannot call private member of containing class in @CS  (was: 
Cannot call private method of containing class in @CS)

> Cannot call private member of containing class in @CS
> -
>
> Key: GROOVY-9328
> URL: https://issues.apache.org/jira/browse/GROOVY-9328
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.8
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:java}
> class C {
> private C() {}
> private privateMethod() {}
> def anonymousUsage() {
> new Runnable() {
> @groovy.transform.CompileStatic
> @Override
> void run() {
> privateMethod()
> new C()
> }
> }
> }
> }{code}
> Expected: code is compiled without errors.
>  Actual: 2  errors:
> {{Cannot call private method C#privateMethod from class C$1}}
> {{Cannot call private constructor for C from class C$1}}
> Note that Java compiles the same code just fine.



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


[jira] [Created] (GROOVY-9328) Cannot call private method of containing class in @CS

2019-12-04 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9328:
--

 Summary: Cannot call private method of containing class in @CS
 Key: GROOVY-9328
 URL: https://issues.apache.org/jira/browse/GROOVY-9328
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.8
Reporter: Daniil Ovchinnikov


{code:java}
class C {

private privateMethod() {}

def anonymousUsage() {
new Runnable() {
@groovy.transform.CompileStatic
@Override
void run() {
privateMethod()
}
}
}
} {code}
Expected: code is compiled without errors.
Actual: {{Cannot call private method C#privateMethod from class C$1}}



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


[jira] [Created] (GROOVY-9327) @CompileStatic is not propagated to anonymous class

2019-12-04 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9327:
--

 Summary: @CompileStatic is not propagated to anonymous class
 Key: GROOVY-9327
 URL: https://issues.apache.org/jira/browse/GROOVY-9327
 Project: Groovy
  Issue Type: Bug
  Components: Static compilation, Static Type Checker
Affects Versions: 2.5.8
Reporter: Daniil Ovchinnikov


{code:java}
@groovy.transform.CompileStatic
def method() {
new Runnable() {
@Override
void run() {
foo // invalid reference
}
}
} {code}
Expected: Error:(6, 13) Groovyc: [Static type checking] - The variable [foo] is 
undeclared.
Actual: no error is reported.

Note that annotating {{run}} method works properly, i.e. the error is reported.



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


[jira] [Updated] (GROOVY-9328) Cannot call private method of containing class in @CS

2019-12-04 Thread Daniil Ovchinnikov (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9328?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9328:
---
Description: 
{code:java}
class C {

private privateMethod() {}

def anonymousUsage() {
new Runnable() {
@groovy.transform.CompileStatic
@Override
void run() {
privateMethod()
}
}
}
} {code}
Expected: code is compiled without errors.
 Actual: {{Cannot call private method C#privateMethod from class C$1}}

Note that Java compiles the same code just fine.

  was:
{code:java}
class C {

private privateMethod() {}

def anonymousUsage() {
new Runnable() {
@groovy.transform.CompileStatic
@Override
void run() {
privateMethod()
}
}
}
} {code}
Expected: code is compiled without errors.
Actual: {{Cannot call private method C#privateMethod from class C$1}}


> Cannot call private method of containing class in @CS
> -
>
> Key: GROOVY-9328
> URL: https://issues.apache.org/jira/browse/GROOVY-9328
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.8
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:java}
> class C {
> private privateMethod() {}
> def anonymousUsage() {
> new Runnable() {
> @groovy.transform.CompileStatic
> @Override
> void run() {
> privateMethod()
> }
> }
> }
> } {code}
> Expected: code is compiled without errors.
>  Actual: {{Cannot call private method C#privateMethod from class C$1}}
> Note that Java compiles the same code just fine.



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


[jira] [Created] (GROOVY-9344) CCE in closure shared variable assignment

2019-12-19 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9344:
--

 Summary: CCE in closure shared variable assignment
 Key: GROOVY-9344
 URL: https://issues.apache.org/jira/browse/GROOVY-9344
 Project: Groovy
  Issue Type: Bug
  Components: Static compilation, Static Type Checker
Affects Versions: 2.5.8
Reporter: Daniil Ovchinnikov


{code}
class A {}
class B {}

@groovy.transform.CompileStatic
def cs() {
def var
var = new A()
def c = {
var = new B() // Cannot cast object 'B@4e234c52' with class 'B' to 
class 'A'
}
c()
var.toString()
}

assert cs() != null
{code}



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


[jira] [Created] (GROOVY-9346) Closure shared variable type is polluted with previous assignment type

2019-12-19 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9346:
--

 Summary: Closure shared variable type is polluted with previous 
assignment type
 Key: GROOVY-9346
 URL: https://issues.apache.org/jira/browse/GROOVY-9346
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.8
Reporter: Daniil Ovchinnikov


{code:java}
class A { def foo() {42} }

@groovy.transform.CompileStatic
def cs() {
def var  
var = "hi" // commenting this line fixes the issue 
var = new A() 
def c = {
var = new A()
}
c()
var.foo() // [Static type checking] - A closure shared variable [var] has 
been assigned with various types and the method [foo()] does not exist in the 
lowest upper bound of those types: [java.lang.Object]. In general, this is a 
bad practice (variable reuse) because the compiler cannot determine safely what 
is the type of the variable at the moment of the call in a multithreaded 
context.
}
assert cs() == 42

{code}



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


[jira] [Created] (GROOVY-9345) Closure shared variable type is polluted with unreached assignment type

2019-12-19 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9345:
--

 Summary: Closure shared variable type is polluted with unreached 
assignment type
 Key: GROOVY-9345
 URL: https://issues.apache.org/jira/browse/GROOVY-9345
 Project: Groovy
  Issue Type: Bug
  Components: Static compilation, Static Type Checker
Reporter: Daniil Ovchinnikov


{code}
@groovy.transform.CompileStatic
def cs() {
def var

var = "hi"
println var.toUpperCase() // [Static type checking] - A closure shared 
variable [var] has been assigned with various types and the method 
[toUpperCase()] does not exist in the lowest upper bound of those types: 
[java.lang.Object]. In general, this is a bad practice (variable reuse) because 
the compiler cannot determine safely what is the type of the variable at the 
moment of the call in a multithreaded context.

def c = {
var = new Object()
}
c()
var.toString()
}

assert cs() != null
{code}



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


[jira] [Created] (GROOVY-9343) Variable type is not updated in operator assignment

2019-12-19 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9343:
--

 Summary: Variable type is not updated in operator assignment
 Key: GROOVY-9343
 URL: https://issues.apache.org/jira/browse/GROOVY-9343
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Reporter: Daniil Ovchinnikov


{code}
class A { B plus(x) { new B() } }
class B { def foo() {42} }

@groovy.transform.CompileStatic
def cs() {
def var
var = new A()
var = var + 1
var.foo()
}

assert cs() == 42

@groovy.transform.CompileStatic
def cs2() {
def var
var = new A()
var += 1 
var.foo() // Cannot find matching method A#foo()
}

assert cs2() == 43
{code}



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


[jira] [Updated] (GROOVY-9343) Variable type is not updated in operator assignment

2019-12-19 Thread Daniil Ovchinnikov (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9343?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9343:
---
Description: 
{code:java}
class A { B plus(x) { new B() } }
class B { def foo() {42} }

@groovy.transform.CompileStatic
def cs() {
def var
var = new A()
var = var + 1
var.foo()
}

assert cs() == 42

@groovy.transform.CompileStatic
def cs2() {
def var
var = new A()
var += 1 
var.foo() // Cannot find matching method A#foo()
}

assert cs2() == 42
{code}

  was:
{code}
class A { B plus(x) { new B() } }
class B { def foo() {42} }

@groovy.transform.CompileStatic
def cs() {
def var
var = new A()
var = var + 1
var.foo()
}

assert cs() == 42

@groovy.transform.CompileStatic
def cs2() {
def var
var = new A()
var += 1 
var.foo() // Cannot find matching method A#foo()
}

assert cs2() == 43
{code}


> Variable type is not updated in operator assignment
> ---
>
> Key: GROOVY-9343
> URL: https://issues.apache.org/jira/browse/GROOVY-9343
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.8
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:java}
> class A { B plus(x) { new B() } }
> class B { def foo() {42} }
> @groovy.transform.CompileStatic
> def cs() {
> def var
> var = new A()
> var = var + 1
> var.foo()
> }
> assert cs() == 42
> @groovy.transform.CompileStatic
> def cs2() {
> def var
> var = new A()
> var += 1 
> var.foo() // Cannot find matching method A#foo()
> }
> assert cs2() == 42
> {code}



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


[jira] [Updated] (GROOVY-9343) Variable type is not updated in operator assignment

2019-12-19 Thread Daniil Ovchinnikov (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9343?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9343:
---
Affects Version/s: 2.5.8

> Variable type is not updated in operator assignment
> ---
>
> Key: GROOVY-9343
> URL: https://issues.apache.org/jira/browse/GROOVY-9343
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.8
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code}
> class A { B plus(x) { new B() } }
> class B { def foo() {42} }
> @groovy.transform.CompileStatic
> def cs() {
> def var
> var = new A()
> var = var + 1
> var.foo()
> }
> assert cs() == 42
> @groovy.transform.CompileStatic
> def cs2() {
> def var
> var = new A()
> var += 1 
> var.foo() // Cannot find matching method A#foo()
> }
> assert cs2() == 43
> {code}



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


[jira] [Updated] (GROOVY-9375) Cannot call method with Map parameter

2020-01-27 Thread Daniil Ovchinnikov (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9375:
---
Description: 
{code}
def foo(Map> m) { m }

@groovy.transform.CompileStatic
def csUsage() {
Map inner = new LinkedHashMap<>()
inner.put("b", 42)
Map> outer = new LinkedHashMap<>()
outer.put("a", inner)
foo(outer)
foo(a: inner)// error
foo(a: [b: 42])  // error
foo([a: [b: 42]])// error
}

csUsage()
{code}

Expected: no errors.

The same error is reported on the lines with {{error}} comment: 
{noformat}
[Static type checking] - Cannot call script#foo(java.util.Map 
) with arguments [java.util.LinkedHashMap 
] 
{noformat}

  was:
{code}
def foo(Map> m) { m }

@groovy.transform.CompileStatic
def csUsage() {
Map inner = new LinkedHashMap<>()
inner.put("b", 42)
Map> outer = new LinkedHashMap<>()
outer.put("a", inner)
foo(outer)
foo(a: inner)// error
foo(a: [b: 42])  // error
foo([a: [b: 42]])// error
}

csUsage()
{code}

The same error is reported on the lines with {{error}} comment: 
{noformat}
[Static type checking] - Cannot call script#foo(java.util.Map 
) with arguments [java.util.LinkedHashMap 
] 
{noformat}


> Cannot call method with Map parameter
> -
>
> Key: GROOVY-9375
> URL: https://issues.apache.org/jira/browse/GROOVY-9375
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.9
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code}
> def foo(Map> m) { m }
> @groovy.transform.CompileStatic
> def csUsage() {
> Map inner = new LinkedHashMap<>()
> inner.put("b", 42)
> Map> outer = new LinkedHashMap<>()
> outer.put("a", inner)
> foo(outer)
> foo(a: inner)// error
> foo(a: [b: 42])  // error
> foo([a: [b: 42]])// error
> }
> csUsage()
> {code}
> Expected: no errors.
> The same error is reported on the lines with {{error}} comment: 
> {noformat}
> [Static type checking] - Cannot call script#foo(java.util.Map 
> ) with arguments [java.util.LinkedHashMap 
> ] 
> {noformat}



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


[jira] [Created] (GROOVY-9375) Cannot call method with Map parameter

2020-01-27 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9375:
--

 Summary: Cannot call method with Map parameter
 Key: GROOVY-9375
 URL: https://issues.apache.org/jira/browse/GROOVY-9375
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.9
Reporter: Daniil Ovchinnikov


{code}
def foo(Map> m) { m }

@groovy.transform.CompileStatic
def csUsage() {
Map inner = new LinkedHashMap<>()
inner.put("b", 42)
Map> outer = new LinkedHashMap<>()
outer.put("a", inner)
foo(outer)
foo(a: inner)// error
foo(a: [b: 42])  // error
foo([a: [b: 42]])// error
}

csUsage()
{code}

The same error is reported on the lines with {{error}} comment: 
{noformat}
[Static type checking] - Cannot call script#foo(java.util.Map 
) with arguments [java.util.LinkedHashMap 
] 
{noformat}



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


[jira] [Commented] (GROOVY-9204) Compiler loses type info of superclass field

2020-03-11 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9204:


[~katoquro] no. Next time please create another issue, since it will be much 
more easier to mark it as a duplicate if it turns out to be such.

> Compiler loses type info of superclass field
> 
>
> Key: GROOVY-9204
> URL: https://issues.apache.org/jira/browse/GROOVY-9204
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Affects Versions: 2.5.7
>Reporter: Daniil Ovchinnikov
>Assignee: Daniel Sun
>Priority: Blocker
> Fix For: 3.0.0, 2.5.10
>
>  Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> {code:java|title=foo/bar/classes.java}
> package foo.bar;
> class F {
> void hi() {}
> }
> abstract class Base {
> protected T theField;
> }
> abstract class Middle extends Base {}
> abstract class Concrete extends Middle {}
> {code}
> {code:java|title=foo/bar/GroovyUsage.groovy}
> package foo.bar
> @groovy.transform.CompileStatic
> class GroovyUsage extends Concrete {
> def usage() {
> theField.hi() // Error:(7, 9) Groovyc: [Static type checking] - 
> Cannot find matching method java.lang.Object#hi(). Please check if the 
> declared type is correct and if the method exists.
> }
> }
> {code}
> Note this was working with 2.4.17.



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


[jira] [Updated] (GROOVY-9506) Joint compilation is broken

2020-04-13 Thread Daniil Ovchinnikov (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9506?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9506:
---
Description: 
{code:title=playground.groovy}
@groovy.transform.AutoImplement
class C implements Runnable {}

class Main {
static void main(String[] args) {
def c = new C()
c.run()
}
}
{code}

{code:title=I.java}
public interface I {
  void foo();
}
{code}

{noformat}
$ groovyc I.java playground.groovy -j
$ java -cp .:$GROOVY_HOME/lib/groovy-2.5.10.jar Main
Exception in thread "main" java.lang.NullPointerException
at 
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:37)
at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
at Main.main(playground.groovy:9)
{noformat}

What happens:
1. {{org.codehaus.groovy.tools.javac.JavaStubGenerator#printClassContents}} 
applies its {{Verifier}}. 
2. {{org.codehaus.groovy.classgen.Verifier#addGroovyObjectInterfaceAndMethods}} 
adds {{GroovyObject}} interface and {{GroovyObject}}'s methods via 
{{org.codehaus.groovy.classgen.Verifier#addMethod}}.
3. {{Verifier#addMethod}} is overridden in {{#printClassContents}}' 
{{Verifier}} to skip adding methods to the class node.
4. at the moment when {{@AutoImplement}} kicks in there exists the 
{{GroovyObject}} interface and no methods in the class node, so the 
transformation adds default method implementations.

Related: https://youtrack.jetbrains.com/issue/IDEA-237148

  was:
{code:title=playground.groovy}
@groovy.transform.AutoImplement
class C implements Runnable {}

class Main {
static void main(String[] args) {
def c = new C()
c.run()
}
}
{code}

{code:title=I.java}
public interface I {
  void foo();
}
{code}

{noformat}
$ groovyc I.java playground.groovy -j
$ java -cp .:$GROOVY_HOME/lib/groovy-2.5.10.jar Main
Exception in thread "main" java.lang.NullPointerException
at 
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:37)
at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
at Main.main(playground.groovy:9)
{noformat}

What happens:
1. {{org.codehaus.groovy.tools.javac.JavaStubGenerator#printClassContents}} 
applies its {{Verifier}}. 
2. {{org.codehaus.groovy.classgen.Verifier#addGroovyObjectInterfaceAndMethods}} 
adds {{GroovyObject}} interface and {{GroovyObject}}'s methods}} via 
{{org.codehaus.groovy.classgen.Verifier#addMethod}}.
3. {{Verifier#addMethod}} is overridden in {{#printClassContents}}' 
{{Verifier}} to skip adding methods to the class node.
4. at the moment when {{@AutoImplement}} kicks in there exists the 
{{GroovyObject}} interface and no methods in the class node, so the 
transformation adds default method implementations.

Related: https://youtrack.jetbrains.com/issue/IDEA-237148


> Joint compilation is broken
> ---
>
> Key: GROOVY-9506
> URL: https://issues.apache.org/jira/browse/GROOVY-9506
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.10
>Reporter: Daniil Ovchinnikov
>Priority: Critical
>
> {code:title=playground.groovy}
> @groovy.transform.AutoImplement
> class C implements Runnable {}
> class Main {
> static void main(String[] args) {
> def c = new C()
> c.run()
> }
> }
> {code}
> {code:title=I.java}
> public interface I {
>   void foo();
> }
> {code}
> {noformat}
> $ groovyc I.java playground.groovy -j
> $ java -cp .:$GROOVY_HOME/lib/groovy-2.5.10.jar Main
> Exception in thread "main" java.lang.NullPointerException
>   at 
> org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:37)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
>   at Main.main(playground.groovy:9)
> {noformat}
> What happens:
> 1. {{org.codehaus.groovy.tools.javac.JavaStubGenerator#printClassContents}} 
> applies its {{Verifier}}. 
> 2. 
> {{org.codehaus.groovy.classgen.Verifier#addGroovyObjectInterfaceAndMethods}} 
> adds {{GroovyObject}} interface and {{GroovyObject}}'s methods via 
> {{org.codehaus.groovy.classgen.Verifier#addMethod}}.
> 3. {{Verifier#addMethod}} is 

[jira] [Created] (GROOVY-9506) Joint compilation is broken

2020-04-13 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9506:
--

 Summary: Joint compilation is broken
 Key: GROOVY-9506
 URL: https://issues.apache.org/jira/browse/GROOVY-9506
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.5.10
Reporter: Daniil Ovchinnikov


{code:title=playground.groovy}
@groovy.transform.AutoImplement
class C implements Runnable {}

class Main {
static void main(String[] args) {
def c = new C()
c.run()
}
}
{code}

{code:title=I.java}
public interface I {
  void foo();
}
{code}

{noformat}
$ groovyc I.java playground.groovy -j
$ java -cp .:$GROOVY_HOME/lib/groovy-2.5.10.jar Main
Exception in thread "main" java.lang.NullPointerException
at 
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:37)
at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
at Main.main(playground.groovy:9)
{noformat}

What happens:
1. {{org.codehaus.groovy.tools.javac.JavaStubGenerator#printClassContents}} 
applies its {{Verifier}}. 
2. {{org.codehaus.groovy.classgen.Verifier#addGroovyObjectInterfaceAndMethods}} 
adds {{GroovyObject}} interface and {{GroovyObject}}'s methods}} via 
{{org.codehaus.groovy.classgen.Verifier#addMethod}}.
3. {{Verifier#addMethod}} is overridden in {{#printClassContents}}' 
{{Verifier}} to skip adding methods to the class node.
4. at the moment when {{@AutoImplement}} kicks in there exists the 
{{GroovyObject}} interface and no methods in the class node, so the 
transformation adds default method implementations.

Related: https://youtrack.jetbrains.com/issue/IDEA-237148



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


[jira] [Created] (GROOVY-9471) NCDFE: nested class in middle class via static import resolution

2020-03-16 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9471:
--

 Summary: NCDFE: nested class in middle class via static import 
resolution
 Key: GROOVY-9471
 URL: https://issues.apache.org/jira/browse/GROOVY-9471
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.5.10
Reporter: Daniil Ovchinnikov


{code}
import static Child.Nested

class Parent {
Nested xxx
}

class Middle extends Parent {
static class Nested {}
}

class Child extends Middle {}

println(new Parent()) // java.lang.NoClassDefFoundError: Nested
{code}

The same exception when using star import.



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


[jira] [Created] (GROOVY-9555) Generic return type with raw upper bound is not inferred from argument properly

2020-05-15 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9555:
--

 Summary: Generic return type with raw upper bound is not inferred 
from argument properly
 Key: GROOVY-9555
 URL: https://issues.apache.org/jira/browse/GROOVY-9555
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.11
Reporter: Daniil Ovchinnikov


{code:title=classes.java}
interface I {}

class C implements I {}

interface Container {
 T getInstance(Class c);
}
{code}

{code:title=playground.groovy}
@groovy.transform.CompileStatic
def usage(Container pc) {
C instance = pc.getInstance(C)
println(instance)
}
{code}

{noformat}
$ groovy -version
Groovy Version: 2.5.11 JVM: 1.8.0_231 Vendor: Oracle Corporation OS: Mac OS X
$ javac classes.java
$ groovyc playground.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
playground.groovy: 3: [Static type checking] - Cannot assign value of type I  to variable of type C
 @ line 3, column 18.
   C instance = pc.getInstance(C)
^

1 error
{noformat}


PS real life use case:
- {{I}} is {{org.gradle.api.Plugin}}
- {{C}} is {{org.gradle.plugins.ear.EarPlugin}}
- {{Container#getInstance}} is 
{{org.gradle.api.plugins.PluginContainer#findPlugin}}



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


[jira] [Created] (GROOVY-9562) Base class property causes CCE

2020-05-18 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9562:
--

 Summary: Base class property causes CCE
 Key: GROOVY-9562
 URL: https://issues.apache.org/jira/browse/GROOVY-9562
 Project: Groovy
  Issue Type: Bug
  Components: Static compilation
Affects Versions: 2.5.11
Reporter: Daniil Ovchinnikov


{code:title=playground.groovy}
abstract class BaseClass {
def prop = 42
}

abstract class BaseClass2 {
def prop = 69
}

@groovy.transform.CompileStatic
class Impl extends BaseClass {
def usage() {
new BaseClass2() {
def foo() {
prop
}
}
}
}

assert new Impl().usage().foo() == 69
{code}

Output:
{noformat}
Caught: java.lang.ClassCastException: Impl$1 cannot be cast to BaseClass
java.lang.ClassCastException: Impl$1 cannot be cast to BaseClass
at Impl$1.foo(playground.groovy)
at Impl$1$foo.call(Unknown Source)
at playground.run(playground.groovy:20)
{noformat}



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


[jira] [Created] (GROOVY-9472) Static import causes unresolved reference to become resolved

2020-03-16 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9472:
--

 Summary: Static import causes unresolved reference to become 
resolved
 Key: GROOVY-9472
 URL: https://issues.apache.org/jira/browse/GROOVY-9472
 Project: Groovy
  Issue Type: Bug
  Components: Compiler, Static Type Checker
Affects Versions: 2.5.10
Reporter: Daniil Ovchinnikov


{code:groovy|title=com/foo/Person.groovy}
package com.foo

@groovy.transform.builder.Builder
class Person {
String name
}
{code}
1.
{code:groovy|title=Main.groovy}
import com.foo.Person

class Main {
static void main(String[] args) {
Person.PersonBuilder pb = Person.builder() 
println(pb.build())
}
}
{code}
Trying to use it without a static import yields {{unable to resolve class 
Person.PersonBuilder}}, which is another issue.

2. Let's add a static import
{code:groovy|title=Main.groovy}
import com.foo.Person
import static com.foo.Person.PersonBuilder

class Main {
static void main(String[] args) {
PersonBuilder pb = Person.builder()
println(pb.build())
}
}
{code}
The code compiles, but fails with {{java.lang.NoClassDefFoundError: 
PersonBuilder}} when run.

3. Let's add {{@CompileStatic}}
{code:groovy|title=Main.groovy}
import com.foo.Person
import static com.foo.Person.PersonBuilder

class Main {
static void main(String[] args) {
PersonBuilder pb = Person.builder()
println(pb.build())
}
}
{code}
Compilation fails with: 
 {{Cannot assign value of type com.foo.Person$PersonBuilder to variable of type 
PersonBuilder}} and {{Cannot find matching method PersonBuilder#build()}}



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


[jira] [Updated] (GROOVY-9472) Static import causes unresolved reference to become resolved

2020-03-16 Thread Daniil Ovchinnikov (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-9472?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9472:
---
Description: 
{code:groovy|title=com/foo/Person.groovy}
package com.foo

@groovy.transform.builder.Builder
class Person {
String name
}
{code}
1.
{code:groovy|title=Main.groovy}
import com.foo.Person

class Main {
static void main(String[] args) {
Person.PersonBuilder pb = Person.builder() 
println(pb.build())
}
}
{code}
Trying to use it without a static import yields {{unable to resolve class 
Person.PersonBuilder}}, which is another issue.

2. Let's add a static import
{code:groovy|title=Main.groovy}
import com.foo.Person
import static com.foo.Person.PersonBuilder

class Main {
static void main(String[] args) {
PersonBuilder pb = Person.builder()
println(pb.build())
}
}
{code}
The code compiles, but fails with {{java.lang.NoClassDefFoundError: 
PersonBuilder}} when run.

3. Let's add {{@CompileStatic}}
{code:groovy|title=Main.groovy}
import com.foo.Person
import static com.foo.Person.PersonBuilder
import groovy.transform.CompileStatic

@CompileStatic
class Main {
static void main(String[] args) {
PersonBuilder pb = Person.builder()
println(pb.build())
}
}
{code}
Compilation fails with: 
 {{Cannot assign value of type com.foo.Person$PersonBuilder to variable of type 
PersonBuilder}} and {{Cannot find matching method PersonBuilder#build()}}

  was:
{code:groovy|title=com/foo/Person.groovy}
package com.foo

@groovy.transform.builder.Builder
class Person {
String name
}
{code}
1.
{code:groovy|title=Main.groovy}
import com.foo.Person

class Main {
static void main(String[] args) {
Person.PersonBuilder pb = Person.builder() 
println(pb.build())
}
}
{code}
Trying to use it without a static import yields {{unable to resolve class 
Person.PersonBuilder}}, which is another issue.

2. Let's add a static import
{code:groovy|title=Main.groovy}
import com.foo.Person
import static com.foo.Person.PersonBuilder

class Main {
static void main(String[] args) {
PersonBuilder pb = Person.builder()
println(pb.build())
}
}
{code}
The code compiles, but fails with {{java.lang.NoClassDefFoundError: 
PersonBuilder}} when run.

3. Let's add {{@CompileStatic}}
{code:groovy|title=Main.groovy}
import com.foo.Person
import static com.foo.Person.PersonBuilder

class Main {
static void main(String[] args) {
PersonBuilder pb = Person.builder()
println(pb.build())
}
}
{code}
Compilation fails with: 
 {{Cannot assign value of type com.foo.Person$PersonBuilder to variable of type 
PersonBuilder}} and {{Cannot find matching method PersonBuilder#build()}}


> Static import causes unresolved reference to become resolved
> 
>
> Key: GROOVY-9472
> URL: https://issues.apache.org/jira/browse/GROOVY-9472
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler, Static Type Checker
>Affects Versions: 2.5.10
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:groovy|title=com/foo/Person.groovy}
> package com.foo
> @groovy.transform.builder.Builder
> class Person {
> String name
> }
> {code}
> 1.
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> class Main {
> static void main(String[] args) {
> Person.PersonBuilder pb = Person.builder() 
> println(pb.build())
> }
> }
> {code}
> Trying to use it without a static import yields {{unable to resolve class 
> Person.PersonBuilder}}, which is another issue.
> 2. Let's add a static import
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> import static com.foo.Person.PersonBuilder
> class Main {
> static void main(String[] args) {
> PersonBuilder pb = Person.builder()
> println(pb.build())
> }
> }
> {code}
> The code compiles, but fails with {{java.lang.NoClassDefFoundError: 
> PersonBuilder}} when run.
> 3. Let's add {{@CompileStatic}}
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> import static com.foo.Person.PersonBuilder
> import groovy.transform.CompileStatic
> @CompileStatic
> class Main {
> static void main(String[] args) {
> PersonBuilder pb = Person.builder()
> println(pb.build())
> }
> }
> {code}
> Compilation fails with: 
>  {{Cannot assign value of type com.foo.Person$PersonBuilder to variable of 
> type PersonBuilder}} and {{Cannot find matching method PersonBuilder#build()}}



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


[jira] [Created] (GROOVY-9734) Generic is not inferred from context

2020-09-09 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9734:
--

 Summary: Generic is not inferred from context
 Key: GROOVY-9734
 URL: https://issues.apache.org/jira/browse/GROOVY-9734
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.13, 3.0.5
Reporter: Daniil Ovchinnikov


{code:title=bugs.groovy}
static void stuff(List operations) {}

@groovy.transform.CompileStatic
void usage() {
stuff(Collections.emptyList()) // 
}

usage()
{code}

Results in compilation error:
{noformat}
[Static type checking] - Cannot call bugs#stuff(java.util.List 
) with arguments [java.util.List ] 
 @ line 5, column 5.
   stuff(Collections.emptyList())
   ^
{noformat}



--
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] [Comment Edited] (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 edited comment on GROOVY-9779 at 10/12/20, 2:44 PM:
---

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 Closure 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}


was (Author: daniilo):
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 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] [Created] (GROOVY-9779) Inconsistency with callable properties in static context

2020-10-12 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9779:
--

 Summary: 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


{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-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-8358) Nested class resolution behaves differently depending on class order

2020-06-07 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-8358:


[~richardHu] Tell me what is unclear, please. 

> Nested class resolution behaves differently depending on class order
> 
>
> Key: GROOVY-8358
> URL: https://issues.apache.org/jira/browse/GROOVY-8358
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniil Ovchinnikov
>Priority: Critical
>
> {code}
> package bugs
> class Outer implements OuterI {
>   static class Current extends CurrentParent  {
> static usage() {
>   new Target()
> }
>   }
> }
> class CurrentParent implements CurrentParentI {}
> interface CurrentParentI {
>   static class Target {}
> }
> interface OuterI {
>   static class Target {}
> }
> println Outer.Current.usage() // bugs.OuterI$Target@3eb7fc54
> {code}
> If {{CurrentParent}} definition is moved before {{Outer}}, then {{new 
> Target}} will be resolved to {{bugs.CurrentParentI$Target}}:
> {code}
> package bugs
> class CurrentParent implements CurrentParentI {}
> class Outer implements OuterI {
>   class Current extends CurrentParent  {
> static usage() {
>   new Target()
> }
>   }
> }
> interface CurrentParentI {
>   static class Target {}
> }
> interface OuterI {
>   static class Target {}
> }
> println Outer.Current.usage() // bugs.CurrentParentI$Target@3eb7fc54
> {code}
> Moving classes must not affect results of compilation.



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


[jira] [Created] (GROOVY-9866) Inner class of superinterface cannot be found

2020-12-18 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9866:
--

 Summary: Inner class of superinterface cannot be found
 Key: GROOVY-9866
 URL: https://issues.apache.org/jira/browse/GROOVY-9866
 Project: Groovy
  Issue Type: Bug
Affects Versions: 3.0.7
Reporter: Daniil Ovchinnikov


https://github.com/dovchinnikov/groovy-bug-inner-of-superinterface 

{noformat}
$ groovy playground.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:~/groovy-bug-inner-of-superinterface/com/foo/C.groovy: 11: unable to 
resolve class Level
 @ line 11, column 24.
   boolean isLoggable(Level level) {
  ^

file:~/groovy-bug-inner-of-superinterface/com/foo/C.groovy: 16: unable to 
resolve class Level
 @ line 16, column 14.
   void log(Level level, ResourceBundle bundle, String msg, Throwable 
thrown) {}
^

file:~/groovy-bug-inner-of-superinterface/com/foo/C.groovy: 19: unable to 
resolve class Level
 @ line 19, column 14.
   void log(Level level, ResourceBundle bundle, String format, Object... 
params) {}
^

3 errors
{noformat}




--
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-8248) MethodSelectionException when calling a overloaded method without arguments

2020-10-28 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-8248:


[~bigehokie] take a look please

> MethodSelectionException when calling a overloaded method without arguments
> ---
>
> Key: GROOVY-8248
> URL: https://issues.apache.org/jira/browse/GROOVY-8248
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.10
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code}
> def methodWithOverload(a, b) {
> println "$a $b"
> }
> def methodWithOverload(a) {
> methodWithOverload(a, new Object())
> }
> methodWithOverload("hello", "world")
> methodWithOverload("hello")
> methodWithOverload() // MSE here
> {code}
> {noformat}
> Caught: org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could 
> not find which method methodWithOverload() to invoke from this list:
>   public java.lang.Object myscript#methodWithOverload(java.lang.Object)
>   public java.lang.Object myscript#methodWithOverload(java.lang.Object, 
> java.lang.Object)
> {noformat}



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


[jira] [Commented] (GROOVY-8660) Unexpected MethodSelectionException with implicit null argument

2021-06-16 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-8660:


This should be documented somewhere. Last time I've checked, there was 
something like: "if a method can be called with a single null argument, then 
the argument can be omitted", there was no mention that the method must not 
have overloads or varargs. 

If {{new OnlyVararg().foo()}} fails
=> {{Both#foo(Object, [LObject;)}} must be inapplicable
=>  method selection in {{new Both().foo()}} should try only 
{{Both#foo(Object)}} against {{null}} argument 
=> {{Both#foo(Object)}} should be selected.

Now let's reverse the above.

If {{Both#foo(Object)}} is not selected
=> method selection in {{new Both().foo()}} actually sees both methods as 
applicable before trying them with null argument
=> {{Both#foo(Object, [LObject;)}} was applicable
=> {{new OnlyVararg().foo()}} must not fail.

I'm having trouble understanding `org.codehaus.groovy.*` code. Can you describe 
me the algorithm in human words, please?

> Unexpected MethodSelectionException with implicit null argument
> ---
>
> Key: GROOVY-8660
> URL: https://issues.apache.org/jira/browse/GROOVY-8660
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-alpha-2, 2.4.15, 2.5.0
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:groovy}
> class OnlySingle {
> def foo(a) { "single param: $a" }
> }
> println new OnlySingle().foo()
> // as expected: 'single param: null'
> class OnlyVararg {
> def foo(a, ... b) { "vararg param: $a, $b" }
> }
> println new OnlyVararg().foo()
> // as expected: 'MME: No signature of method: OnlyVararg.foo() is applicable 
> for argument types: () values: []'
> class Both {
> def foo(a) { "single param: $a" }
> def foo(a, ... b) { "vararg param: $a, $b" }
> }
> println new Both().foo()
> // unexpected:
> // MethodSelectionException: Could not find which method foo() to invoke from 
> this list:
> //  public java.lang.Object Both#foo(java.lang.Object)
> //  public transient java.lang.Object Both#foo(java.lang.Object, 
> [Ljava.lang.Object;)
> {code}
> If the exception is expected then {{OnlyVararg}} case should work too.
> If the exception is unexpected then {{Both#foo(Object)}} should be selected.



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


[jira] [Comment Edited] (GROOVY-8660) Unexpected MethodSelectionException with implicit null argument

2021-06-16 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov edited comment on GROOVY-8660 at 6/16/21, 12:07 PM:
---

This should be documented somewhere. Last time I've checked, there was 
something like: "if a method can be called with a single null argument, then 
the argument can be omitted", there was no mention that the method must not 
have overloads or varargs. 

If {{new OnlyVararg().foo()}} fails
=> {{Both#foo(Object, [LObject; )}} must be inapplicable
=>  method selection in {{new Both().foo()}} should try only 
{{Both#foo(Object)}} against {{null}} argument 
=> {{Both#foo(Object)}} should be selected.

Now let's reverse the above.

If {{Both#foo(Object)}} is not selected
=> method selection in {{new Both().foo()}} actually sees both methods as 
applicable before trying them with null argument
=> {{Both#foo(Object, [LObject; )}} was applicable
=> {{new OnlyVararg().foo()}} must not fail.

I'm having trouble understanding `org.codehaus.groovy.*` code. Can you describe 
me the algorithm in human words, please?


was (Author: daniilo):
This should be documented somewhere. Last time I've checked, there was 
something like: "if a method can be called with a single null argument, then 
the argument can be omitted", there was no mention that the method must not 
have overloads or varargs. 

If {{new OnlyVararg().foo()}} fails
=> {{Both#foo(Object, [LObject;)}} must be inapplicable
=>  method selection in {{new Both().foo()}} should try only 
{{Both#foo(Object)}} against {{null}} argument 
=> {{Both#foo(Object)}} should be selected.

Now let's reverse the above.

If {{Both#foo(Object)}} is not selected
=> method selection in {{new Both().foo()}} actually sees both methods as 
applicable before trying them with null argument
=> {{Both#foo(Object, [LObject;)}} was applicable
=> {{new OnlyVararg().foo()}} must not fail.

I'm having trouble understanding `org.codehaus.groovy.*` code. Can you describe 
me the algorithm in human words, please?

> Unexpected MethodSelectionException with implicit null argument
> ---
>
> Key: GROOVY-8660
> URL: https://issues.apache.org/jira/browse/GROOVY-8660
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-alpha-2, 2.4.15, 2.5.0
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:groovy}
> class OnlySingle {
> def foo(a) { "single param: $a" }
> }
> println new OnlySingle().foo()
> // as expected: 'single param: null'
> class OnlyVararg {
> def foo(a, ... b) { "vararg param: $a, $b" }
> }
> println new OnlyVararg().foo()
> // as expected: 'MME: No signature of method: OnlyVararg.foo() is applicable 
> for argument types: () values: []'
> class Both {
> def foo(a) { "single param: $a" }
> def foo(a, ... b) { "vararg param: $a, $b" }
> }
> println new Both().foo()
> // unexpected:
> // MethodSelectionException: Could not find which method foo() to invoke from 
> this list:
> //  public java.lang.Object Both#foo(java.lang.Object)
> //  public transient java.lang.Object Both#foo(java.lang.Object, 
> [Ljava.lang.Object;)
> {code}
> If the exception is expected then {{OnlyVararg}} case should work too.
> If the exception is unexpected then {{Both#foo(Object)}} should be selected.



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


[jira] [Created] (GROOVY-10122) Wrong cast in stubs generated

2021-06-02 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-10122:
---

 Summary: Wrong cast in stubs generated
 Key: GROOVY-10122
 URL: https://issues.apache.org/jira/browse/GROOVY-10122
 Project: Groovy
  Issue Type: Bug
  Components: Stub generator / Joint compiler
Affects Versions: 3.0.8
Reporter: Daniil Ovchinnikov
 Attachments: mre.zip

{noformat}
$ #unzip
$ cd mre/src
$ groovy -version
Groovy Version: 3.0.8 JVM: 15.0.1 Vendor: Oracle Corporation OS: Mac OS X
$ groovyc -j JavaBase.java GroovyInheritor.groovy JavaUsage.java
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Compile error during compilation with javac.
/var/folders/t7/26sb5vb111n3ljbmwv4s340mgn/T/groovy-generated--java-source12536140884342736527/GroovyInheritor.java:14:
 error: incompatible types: Object cannot be converted to Integer
super((java.lang.Object)null);
  ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get 
full output
1 error


1 error
{noformat}

The issue is not reproducible in 3.0.7.
Same issue can be reproduced opening the directory in IntelliJ and invoking 
Rebuild Project. 
Related https://youtrack.jetbrains.com/issue/IDEA-270650



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


[jira] [Updated] (GROOVY-10122) Wrong cast in stubs generated

2021-06-02 Thread Daniil Ovchinnikov (Jira)


 [ 
https://issues.apache.org/jira/browse/GROOVY-10122?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-10122:

Attachment: mre.zip

> Wrong cast in stubs generated
> -
>
> Key: GROOVY-10122
> URL: https://issues.apache.org/jira/browse/GROOVY-10122
> Project: Groovy
>  Issue Type: Bug
>  Components: Stub generator / Joint compiler
>Affects Versions: 3.0.8
>Reporter: Daniil Ovchinnikov
>Priority: Major
> Attachments: mre.zip
>
>
> {noformat}
> $ #unzip
> $ cd mre/src
> $ groovy -version
> Groovy Version: 3.0.8 JVM: 15.0.1 Vendor: Oracle Corporation OS: Mac OS X
> $ groovyc -j JavaBase.java GroovyInheritor.groovy JavaUsage.java
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Compile error during compilation with javac.
> /var/folders/t7/26sb5vb111n3ljbmwv4s340mgn/T/groovy-generated--java-source12536140884342736527/GroovyInheritor.java:14:
>  error: incompatible types: Object cannot be converted to Integer
> super((java.lang.Object)null);
>   ^
> Note: Some messages have been simplified; recompile with -Xdiags:verbose to 
> get full output
> 1 error
> 1 error
> {noformat}
> The issue is not reproducible in 3.0.7.
> Same issue can be reproduced opening the directory in IntelliJ and invoking 
> Rebuild Project. 
> Related https://youtrack.jetbrains.com/issue/IDEA-270650



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


[jira] [Commented] (GROOVY-10122) Wrong cast in stubs generated

2021-06-03 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-10122:
-

There was no such issue in 3.0.7. Did you manage to find the cause? Can you 
port the fix to the 3.0.x branch? 

> Wrong cast in stubs generated
> -
>
> Key: GROOVY-10122
> URL: https://issues.apache.org/jira/browse/GROOVY-10122
> Project: Groovy
>  Issue Type: Bug
>  Components: Stub generator / Joint compiler
>Affects Versions: 3.0.8
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-1
>
> Attachments: mre.zip
>
>
> {noformat}
> $ #unzip
> $ cd mre/src
> $ groovy -version
> Groovy Version: 3.0.8 JVM: 15.0.1 Vendor: Oracle Corporation OS: Mac OS X
> $ groovyc -j JavaBase.java GroovyInheritor.groovy JavaUsage.java
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Compile error during compilation with javac.
> /var/folders/t7/26sb5vb111n3ljbmwv4s340mgn/T/groovy-generated--java-source12536140884342736527/GroovyInheritor.java:14:
>  error: incompatible types: Object cannot be converted to Integer
> super((java.lang.Object)null);
>   ^
> Note: Some messages have been simplified; recompile with -Xdiags:verbose to 
> get full output
> 1 error
> 1 error
> {noformat}
> The issue is not reproducible in 3.0.7.
> Same issue can be reproduced opening the directory in IntelliJ and invoking 
> Rebuild Project. 
> Related https://youtrack.jetbrains.com/issue/IDEA-270650



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


[jira] [Commented] (GROOVY-9033) Bad code green: empty list literal with each method

2021-03-31 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9033:


{code:groovy}
@groovy.transform.CompileStatic
List usage() {
  def l = [].each {}
  l.add(new Object())
  return l
}
{code}

> Bad code green: empty list literal with each method
> ---
>
> Key: GROOVY-9033
> URL: https://issues.apache.org/jira/browse/GROOVY-9033
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.6
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:groovy}
> @groovy.transform.CompileStatic
> List usage() {
>   def l = [].each {}
>   return l // expected error: Incompatible generic argument types. Cannot 
> assign java.util.List  to: java.util.List  
> }{code}



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


[jira] [Created] (GROOVY-10406) Dollar slashy string is too greedy

2021-12-07 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-10406:
---

 Summary: Dollar slashy string is too greedy
 Key: GROOVY-10406
 URL: https://issues.apache.org/jira/browse/GROOVY-10406
 Project: Groovy
  Issue Type: Bug
  Components: lexer
Affects Versions: 3.0.9
Reporter: Daniil Ovchinnikov


This code compiles fine in 2.5.14, but fails to compile in 3.0.9.

{code:groovy}
println([$/$$/$ : /$$/])
{code}




--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (GROOVY-9472) Static import causes unresolved reference to become resolved

2022-03-17 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9472:


[~emilles] 

> If you include the class or classes that file1 generates on the classpath 
> when compiling file2 there can be a significant difference

Yes, this difference is the problem. 

[~blackdrag] 

> If some units completed and added new classes or sources to the AST, then 
> repeat.

Repeat re-trying to resolve references which were not resolved previously, i.e. 
if a reference got resolved, then it stays resolved.

I'd expect the resolution to work like this:
 # Resolve resolvable member types/annotations
 # Run transformations 
 # Resolve unresolved references in members
 # Resolve the references in bodies (both AST and generated, both types and 
variables/methods/fields)

The output of the second step is fixed after its completion, no more members 
are guaranteed to appear. The output of the third step is enough to do any 
static analysis in {{@CompileStatic}} mode, and it is enough to generate the 
stubs for the joint compilation. This approach aligns well with what IDEs do, 
and what other compilers do.

I'd also split transformation run into two separate steps: instead of 2, run 
transformations to determine the set of members and types, then generate method 
bodies between 3 and 4.

> Static import causes unresolved reference to become resolved
> 
>
> Key: GROOVY-9472
> URL: https://issues.apache.org/jira/browse/GROOVY-9472
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler, Static Type Checker
>Affects Versions: 2.5.10
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0
>
>
> {code:groovy|title=com/foo/Person.groovy}
> package com.foo
> @groovy.transform.builder.Builder
> class Person {
> String name
> }
> {code}
> 1.
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> class Main {
> static void main(String[] args) {
> Person.PersonBuilder pb = Person.builder() 
> println(pb.build())
> }
> }
> {code}
> Trying to use it without a static import yields {{unable to resolve class 
> Person.PersonBuilder}}, which is another issue.
> 2. Let's add a static import
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> import static com.foo.Person.PersonBuilder
> class Main {
> static void main(String[] args) {
> PersonBuilder pb = Person.builder()
> println(pb.build())
> }
> }
> {code}
> The code compiles, but fails with {{java.lang.NoClassDefFoundError: 
> PersonBuilder}} when run.
> 3. Let's add {{@CompileStatic}}
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> import static com.foo.Person.PersonBuilder
> import groovy.transform.CompileStatic
> @CompileStatic
> class Main {
> static void main(String[] args) {
> PersonBuilder pb = Person.builder()
> println(pb.build())
> }
> }
> {code}
> Compilation fails with: 
>  {{Cannot assign value of type com.foo.Person$PersonBuilder to variable of 
> type PersonBuilder}} and {{Cannot find matching method PersonBuilder#build()}}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (GROOVY-9472) Static import causes unresolved reference to become resolved

2022-03-16 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9472:


More general problem: there should be *zero* difference in compilation of file1 
and file2 together in one run and file1 followed by file2 in two subsequent 
runs (= two different compilation units). I've encountered this problem 
multiple times. The problem hits incremental recompilation, when e.g. file1 is 
unchanged, and we only want to recompile file2. I'm not sure how it works in 
Gradle, but it's one major pita in IJ, e.g. in this particular case the first 
compilation run would compile Person.groovy and fail with an error in 
Main.groovy, then the next run would compile Main.groovy successfully, so users 
come and ask why IJ cannot do it in one go. 

> Static import causes unresolved reference to become resolved
> 
>
> Key: GROOVY-9472
> URL: https://issues.apache.org/jira/browse/GROOVY-9472
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler, Static Type Checker
>Affects Versions: 2.5.10
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0
>
>
> {code:groovy|title=com/foo/Person.groovy}
> package com.foo
> @groovy.transform.builder.Builder
> class Person {
> String name
> }
> {code}
> 1.
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> class Main {
> static void main(String[] args) {
> Person.PersonBuilder pb = Person.builder() 
> println(pb.build())
> }
> }
> {code}
> Trying to use it without a static import yields {{unable to resolve class 
> Person.PersonBuilder}}, which is another issue.
> 2. Let's add a static import
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> import static com.foo.Person.PersonBuilder
> class Main {
> static void main(String[] args) {
> PersonBuilder pb = Person.builder()
> println(pb.build())
> }
> }
> {code}
> The code compiles, but fails with {{java.lang.NoClassDefFoundError: 
> PersonBuilder}} when run.
> 3. Let's add {{@CompileStatic}}
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> import static com.foo.Person.PersonBuilder
> import groovy.transform.CompileStatic
> @CompileStatic
> class Main {
> static void main(String[] args) {
> PersonBuilder pb = Person.builder()
> println(pb.build())
> }
> }
> {code}
> Compilation fails with: 
>  {{Cannot assign value of type com.foo.Person$PersonBuilder to variable of 
> type PersonBuilder}} and {{Cannot find matching method PersonBuilder#build()}}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (GROOVY-9472) Static import causes unresolved reference to become resolved

2022-03-17 Thread Daniil Ovchinnikov (Jira)


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

Daniil Ovchinnikov commented on GROOVY-9472:


> it is supposed to somehow guess that some of those class files are really 
> source units that should be added to the compilation unit and compiled as well

Exactly the opposite. The compiler should not care about whether a dependency 
comes from another source unit or a library or an arbitrary class on the 
classpath. 

 

> Why not just send in both source units in the first place if that is what you 
>expect?

Because the compilation will not be incremental if all files are recompiled 
each time.

 

> running resolve and transforms multiple times

Not multiple times, but in multiple steps. If a reference gets resolved at some 
step, it stays resolved to this exact entity in all subsequent steps. The 
transforms should only be run once (or in multiple steps). 

 

> Transforms can be assigned to any phase. 

Just as before, a transform is run once during requested phase, and that's it, 
no phase re-running. I've thought we are discussing how to deal with transforms 
running in SEMANTIC_ANALYSIS. 

> Static import causes unresolved reference to become resolved
> 
>
> Key: GROOVY-9472
> URL: https://issues.apache.org/jira/browse/GROOVY-9472
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler, Static Type Checker
>Affects Versions: 2.5.10
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0
>
>
> {code:groovy|title=com/foo/Person.groovy}
> package com.foo
> @groovy.transform.builder.Builder
> class Person {
> String name
> }
> {code}
> 1.
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> class Main {
> static void main(String[] args) {
> Person.PersonBuilder pb = Person.builder() 
> println(pb.build())
> }
> }
> {code}
> Trying to use it without a static import yields {{unable to resolve class 
> Person.PersonBuilder}}, which is another issue.
> 2. Let's add a static import
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> import static com.foo.Person.PersonBuilder
> class Main {
> static void main(String[] args) {
> PersonBuilder pb = Person.builder()
> println(pb.build())
> }
> }
> {code}
> The code compiles, but fails with {{java.lang.NoClassDefFoundError: 
> PersonBuilder}} when run.
> 3. Let's add {{@CompileStatic}}
> {code:groovy|title=Main.groovy}
> import com.foo.Person
> import static com.foo.Person.PersonBuilder
> import groovy.transform.CompileStatic
> @CompileStatic
> class Main {
> static void main(String[] args) {
> PersonBuilder pb = Person.builder()
> println(pb.build())
> }
> }
> {code}
> Compilation fails with: 
>  {{Cannot assign value of type com.foo.Person$PersonBuilder to variable of 
> type PersonBuilder}} and {{Cannot find matching method PersonBuilder#build()}}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


<    1   2