[jira] [Commented] (GROOVY-9570) Class-Level Closure Definition With Generics Fails TypeChecked

2020-11-11 Thread Ian (Jira)


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

Ian commented on GROOVY-9570:
-

Wonderful! Thank you, Eric, for fixing my picky issues.

> Class-Level Closure Definition With Generics Fails TypeChecked
> --
>
> Key: GROOVY-9570
> URL: https://issues.apache.org/jira/browse/GROOVY-9570
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.5, 3.0.0, 3.0.3
>Reporter: Ian
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-alpha-1, 3.0.6
>
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
>  
>  
> {code:java}
> import groovy.transform.TypeChecked
> @TypeChecked
> abstract class A{
> Collection testQueue
> Closure c = {
> testQueue.each{T item->
> println item
> }
> }
> //def foo() {
> //testQueue.each{T item->
> //println item
> //}
> //}
> }
> new A(){}
> {code}
> Put this in filename.groovy and call "groovy filename.groovy" and I get
>  
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> /home/ianl/closureGeneric.groovy: 9: Expected parameter of type 
> java.lang.Object but got T
>  @ line 7, column 24.
>testQueue.each{T item->
>   ^
> 1 error{noformat}
> Yet, uncomment the method foo() and there's no error there. or put the 
> closure definition into the method and there's no error.



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


[jira] [Created] (GROOVY-10059) Super Class Closure Can't Find Field when Any Method Overridden

2021-04-26 Thread Ian (Jira)
Ian created GROOVY-10059:


 Summary: Super Class Closure Can't Find Field when Any Method 
Overridden
 Key: GROOVY-10059
 URL: https://issues.apache.org/jira/browse/GROOVY-10059
 Project: Groovy
  Issue Type: Bug
Affects Versions: 4.0.0-alpha-3, 3.0.8
Reporter: Ian


{noformat}
class A {
private final boolean VAL = false
Closure foo = {
println VAL // Exception thrown from here
}
}

class B {
A a = new A() {} // Removing these braces makes it work as expected. Also 
fails if an actual method is overridden here
def bar() {
a.foo()
}
}
new B().bar() // Running this throws exception
//new A().foo() // Running this instead works as expected{noformat}
Running this (script called OverrideFail.groovy) results in an exception:
{noformat}
Caught: groovy.lang.MissingPropertyException: No such property: VAL for class: B
Possible solutions: a
groovy.lang.MissingPropertyException: No such property: VAL for class: B
Possible solutions: a
at A$_closure1.doCall(OverrideFail.groovy:4)
at A$_closure1.doCall(OverrideFail.groovy)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at B.bar(OverrideFail.groovy:12)
at B$bar.call(Unknown Source)
at OverrideFail.run(OverrideFail.groovy:16)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
{noformat}



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


[jira] [Commented] (GROOVY-10059) Super Class Closure Can't Find Field when Any Method Overridden

2021-04-27 Thread Ian (Jira)


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

Ian commented on GROOVY-10059:
--

Perfect, thank you. I did search, but evidently missed that one.

> Super Class Closure Can't Find Field when Any Method Overridden
> ---
>
> Key: GROOVY-10059
> URL: https://issues.apache.org/jira/browse/GROOVY-10059
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.8, 4.0.0-alpha-3
>Reporter: Ian
>Priority: Major
>
> {noformat}
> class A {
> private final boolean VAL = false
> Closure foo = {
> println VAL // Exception thrown from here
> }
> }
> class B {
> A a = new A() {} // Removing these braces makes it work as expected. Also 
> fails if an actual method is overridden here
> def bar() {
> a.foo()
> }
> }
> new B().bar() // Running this throws exception
> //new A().foo() // Running this instead works as expected{noformat}
> Running this (script called OverrideFail.groovy) results in an exception:
> {noformat}
> Caught: groovy.lang.MissingPropertyException: No such property: VAL for 
> class: B
> Possible solutions: a
> groovy.lang.MissingPropertyException: No such property: VAL for class: B
> Possible solutions: a
>   at A$_closure1.doCall(OverrideFail.groovy:4)
>   at A$_closure1.doCall(OverrideFail.groovy)
>   at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>   at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at B.bar(OverrideFail.groovy:12)
>   at B$bar.call(Unknown Source)
>   at OverrideFail.run(OverrideFail.groovy:16)
>   at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>   at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> {noformat}



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


[jira] [Created] (GROOVY-10218) BUG! exception in phase 'instruction selection' when non-existent method called

2021-09-08 Thread Ian (Jira)
Ian created GROOVY-10218:


 Summary: BUG! exception in phase 'instruction selection' when 
non-existent method called
 Key: GROOVY-10218
 URL: https://issues.apache.org/jira/browse/GROOVY-10218
 Project: Groovy
  Issue Type: Bug
Affects Versions: 3.0.9, 4.0.0-beta-1, 3.0.8
 Environment: linux
Reporter: Ian


My file "ite.groovy":
{noformat}
import groovy.transform.TypeChecked
interface A {}
@TypeChecked
trait B implements A {
  def foo() {
bar()
  }
}
class C implements B {}
println new C().foo()
{noformat}
Fails to compile (as it should) but does not give a helpful error message:
{noformat}
$ groovy ite.groovy 
Caught: BUG! exception in phase 'instruction selection' in source unit '/ite.groovy' ClassNode#getTypeClass for A called before the type class is 
set
BUG! exception in phase 'instruction selection' in source unit '/ite.groovy' ClassNode#getTypeClass for A called before the type class is 
set
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43){noformat}
Remove the @TypeChecked and it gives a coherent and useful error. 



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


[jira] [Created] (GROOVY-10241) Class Implementing Map Can't Read Fields From Within Closures

2021-09-17 Thread Ian (Jira)
Ian created GROOVY-10241:


 Summary: Class Implementing Map Can't Read Fields From Within 
Closures
 Key: GROOVY-10241
 URL: https://issues.apache.org/jira/browse/GROOVY-10241
 Project: Groovy
  Issue Type: Bug
Affects Versions: 3.0.9
Reporter: Ian


If a class implements 'Map' or subclasses an implementation of 'Map' then 
closures can't read fields in that class. This code is in a script called 
'map.groovy':

 
{noformat}
class A extends HashMap {
  @Override
  Object get(Object key) {
return 'OtherString'
  }
}
class B extends A {
  String aa = 'TheString'
  def foo() {
println aa
Closure c = {println aa}
c.call()
  }
}
new B().foo(){noformat}
{noformat}
$ groovy map.groovy 
TheString
OtherString{noformat}
I expect to get "TheString" twice.

 

I see the same behavior with other implementations of 'Map' or when I implement 
'Map' directly.

Curiously I was not able to get the same behavior when I created my own 
interface defining 'get()' and implementing that.

 



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


[jira] [Commented] (GROOVY-10241) Class Implementing Map Can't Read Fields From Within Closures

2021-09-27 Thread Ian (Jira)


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

Ian commented on GROOVY-10241:
--

Those 3 all work, of course. So this is just a weird intersection between 
groovy internals and Map implementation?

Not a bug then. Thanks for looking into it Eric.

> Class Implementing Map Can't Read Fields From Within Closures
> -
>
> Key: GROOVY-10241
> URL: https://issues.apache.org/jira/browse/GROOVY-10241
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.9
>Reporter: Ian
>Priority: Major
>
> If a class implements 'Map' or subclasses an implementation of 'Map' then 
> closures can't read fields in that class. This code is in a script called 
> 'map.groovy':
>  
> {noformat}
> class A extends HashMap {
>   @Override
>   Object get(Object key) {
> return 'OtherString'
>   }
> }
> class B extends A {
>   String aa = 'TheString'
>   def foo() {
> println aa
> Closure c = {println aa}
> c.call()
>   }
> }
> new B().foo(){noformat}
> {noformat}
> $ groovy map.groovy 
> TheString
> OtherString{noformat}
> I expect to get "TheString" twice.
>  
> I see the same behavior with other implementations of 'Map' or when I 
> implement 'Map' directly.
> Curiously I was not able to get the same behavior when I created my own 
> interface defining 'get()' and implementing that.
>  



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


[jira] [Resolved] (GROOVY-10241) Class Implementing Map Can't Read Fields From Within Closures

2021-09-27 Thread Ian (Jira)


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

Ian resolved GROOVY-10241.
--
Resolution: Not A Bug

> Class Implementing Map Can't Read Fields From Within Closures
> -
>
> Key: GROOVY-10241
> URL: https://issues.apache.org/jira/browse/GROOVY-10241
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.9
>Reporter: Ian
>Priority: Major
>
> If a class implements 'Map' or subclasses an implementation of 'Map' then 
> closures can't read fields in that class. This code is in a script called 
> 'map.groovy':
>  
> {noformat}
> class A extends HashMap {
>   @Override
>   Object get(Object key) {
> return 'OtherString'
>   }
> }
> class B extends A {
>   String aa = 'TheString'
>   def foo() {
> println aa
> Closure c = {println aa}
> c.call()
>   }
> }
> new B().foo(){noformat}
> {noformat}
> $ groovy map.groovy 
> TheString
> OtherString{noformat}
> I expect to get "TheString" twice.
>  
> I see the same behavior with other implementations of 'Map' or when I 
> implement 'Map' directly.
> Curiously I was not able to get the same behavior when I created my own 
> interface defining 'get()' and implementing that.
>  



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


[jira] [Created] (GROOVY-9412) enum added to List fails TypeChecked

2020-02-19 Thread Ian (Jira)
Ian created GROOVY-9412:
---

 Summary: enum added to List fails TypeChecked
 Key: GROOVY-9412
 URL: https://issues.apache.org/jira/browse/GROOVY-9412
 Project: Groovy
  Issue Type: Bug
Affects Versions: 3.0.1, 3.0.0
 Environment: CentOS
Reporter: Ian


 
{code:java}
import groovy.transform.TypeChecked

@TypeChecked
class MyClass {

interface Foo {}

enum Bar implements Foo {
AA
}

void F() {
List g = []
g.add(Bar.AA)
}
}

new MyClass()
{code}
Put this in a file "script.groovy" and call "groovy script.groovy"

Expected: No output
 Actual: 
{noformat}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/Script.groovy: 14: [Static type checking] - Cannot call 
java.util.List #add(MyClass$Foo) with arguments [MyClass$Bar] 
 @ line 14, column 9.
   g.add(Bar.AA)
   ^
1 error{noformat}
Does not occur in 3.0.0-rc-3 or earlier.

Looks similar to GROOVY-8960 but does not occur in 2.5.5

Workaround: Add cast "g.add(Bar.AA as Foo)"



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


[jira] [Updated] (GROOVY-8715) Cannot Resolve Arrays of Inner Class

2020-02-19 Thread Ian (Jira)


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

Ian updated GROOVY-8715:

Description: 
Two files in the 'pkg' package:
{code:java|title=MyClass.groovy}
package pkg 
class HasClass { static class MyClass {} }
{code}
 
{code:java|title=HasClass.groovy}
package pkg
private static void foo(HasClass.MyClass... val) {}
//pkg.HasClass.MyClass[] val // Also Fails
//pkg.HasClass.MyClass val // Does not fail
{code}
Results in the following error:
  
{code:java}
/home/ianl/IdeaProjects/VariousGroovy/src/main/groovy/pkg/UsesClass.groovy: 3: 
unable to resolve class HasClass.MyClass[] 
 @ line 3, column 25.
   private static void foo(HasClass.MyClass... val) {}
   ^
{code}
This fails only for arrays, not single references. It does not occur if the 
files are in the default package.

It is also possible to work around it with a static import:
  
{code:java|title=HasClass.groovy}
package pkg
import static HasClass.MyClass // Now it doesn't fail
private static void foo(MyClass... val) {}
{code}

  was:
Two files in the 'pkg' package:
{code:java|title=HasClass.groovy}
package pkg 
class HasClass { static class MyClass {} }
{code}
 
{code:java|title=HasClass.groovy}
package pkg
private static void foo(HasClass.MyClass... val) {}
//pkg.HasClass.MyClass[] val // Also Fails
//pkg.HasClass.MyClass val // Does not fail
{code}
Results in the following error:
  
{code:java}
/home/ianl/IdeaProjects/VariousGroovy/src/main/groovy/pkg/UsesClass.groovy: 3: 
unable to resolve class HasClass.MyClass[] 
 @ line 3, column 25.
   private static void foo(HasClass.MyClass... val) {}
   ^
{code}
This fails only for arrays, not single references. It does not occur if the 
files are in the default package.

It is also possible to work around it with a static import:
  
{code:java|title=HasClass.groovy}
package pkg
import static HasClass.MyClass // Now it doesn't fail
private static void foo(MyClass... val) {}
{code}


> Cannot Resolve Arrays of Inner Class
> 
>
> Key: GROOVY-8715
> URL: https://issues.apache.org/jira/browse/GROOVY-8715
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-alpha-3, 2.5.0
>Reporter: Ian
>Priority: Major
>
> Two files in the 'pkg' package:
> {code:java|title=MyClass.groovy}
> package pkg 
> class HasClass { static class MyClass {} }
> {code}
>  
> {code:java|title=HasClass.groovy}
> package pkg
> private static void foo(HasClass.MyClass... val) {}
> //pkg.HasClass.MyClass[] val // Also Fails
> //pkg.HasClass.MyClass val // Does not fail
> {code}
> Results in the following error:
>   
> {code:java}
> /home/ianl/IdeaProjects/VariousGroovy/src/main/groovy/pkg/UsesClass.groovy: 
> 3: unable to resolve class HasClass.MyClass[] 
>  @ line 3, column 25.
>private static void foo(HasClass.MyClass... val) {}
>^
> {code}
> This fails only for arrays, not single references. It does not occur if the 
> files are in the default package.
> It is also possible to work around it with a static import:
>   
> {code:java|title=HasClass.groovy}
> package pkg
> import static HasClass.MyClass // Now it doesn't fail
> private static void foo(MyClass... val) {}
> {code}



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


[jira] [Updated] (GROOVY-8715) Cannot Resolve Arrays of Inner Class

2020-02-19 Thread Ian (Jira)


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

Ian updated GROOVY-8715:

Affects Version/s: 3.0.0

> Cannot Resolve Arrays of Inner Class
> 
>
> Key: GROOVY-8715
> URL: https://issues.apache.org/jira/browse/GROOVY-8715
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-alpha-3, 2.5.0, 3.0.0, 3.0.1
>Reporter: Ian
>Priority: Major
>
> Two files in the 'pkg' package:
> {code:java|title=MyClass.groovy}
> package pkg 
> class HasClass { static class MyClass {} }
> {code}
>  
> {code:java|title=HasClass.groovy}
> package pkg
> private static void foo(HasClass.MyClass... val) {}
> //pkg.HasClass.MyClass[] val // Also Fails
> //pkg.HasClass.MyClass val // Does not fail
> {code}
> Results in the following error:
>   
> {code:java}
> /home/ianl/IdeaProjects/VariousGroovy/src/main/groovy/pkg/UsesClass.groovy: 
> 3: unable to resolve class HasClass.MyClass[] 
>  @ line 3, column 25.
>private static void foo(HasClass.MyClass... val) {}
>^
> {code}
> This fails only for arrays, not single references. It does not occur if the 
> files are in the default package.
> It is also possible to work around it with a static import:
>   
> {code:java|title=HasClass.groovy}
> package pkg
> import static HasClass.MyClass // Now it doesn't fail
> private static void foo(MyClass... val) {}
> {code}



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


[jira] [Updated] (GROOVY-8715) Cannot Resolve Arrays of Inner Class

2020-02-19 Thread Ian (Jira)


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

Ian updated GROOVY-8715:

Affects Version/s: 3.0.1

> Cannot Resolve Arrays of Inner Class
> 
>
> Key: GROOVY-8715
> URL: https://issues.apache.org/jira/browse/GROOVY-8715
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-alpha-3, 2.5.0, 3.0.1
>Reporter: Ian
>Priority: Major
>
> Two files in the 'pkg' package:
> {code:java|title=MyClass.groovy}
> package pkg 
> class HasClass { static class MyClass {} }
> {code}
>  
> {code:java|title=HasClass.groovy}
> package pkg
> private static void foo(HasClass.MyClass... val) {}
> //pkg.HasClass.MyClass[] val // Also Fails
> //pkg.HasClass.MyClass val // Does not fail
> {code}
> Results in the following error:
>   
> {code:java}
> /home/ianl/IdeaProjects/VariousGroovy/src/main/groovy/pkg/UsesClass.groovy: 
> 3: unable to resolve class HasClass.MyClass[] 
>  @ line 3, column 25.
>private static void foo(HasClass.MyClass... val) {}
>^
> {code}
> This fails only for arrays, not single references. It does not occur if the 
> files are in the default package.
> It is also possible to work around it with a static import:
>   
> {code:java|title=HasClass.groovy}
> package pkg
> import static HasClass.MyClass // Now it doesn't fail
> private static void foo(MyClass... val) {}
> {code}



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


[jira] [Reopened] (GROOVY-9412) enum added to List fails TypeChecked

2020-03-02 Thread Ian (Jira)


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

Ian reopened GROOVY-9412:
-

> enum added to List fails TypeChecked
> 
>
> Key: GROOVY-9412
> URL: https://issues.apache.org/jira/browse/GROOVY-9412
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0, 3.0.1
> Environment: CentOS
>Reporter: Ian
>Priority: Major
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
>  
> {code:java}
> import groovy.transform.TypeChecked
> @TypeChecked
> class MyClass {
> interface Foo {}
> enum Bar implements Foo {
> AA
> }
> 
> void F() {
> List g = []
> g.add(Bar.AA)
> }
> }
> new MyClass()
> {code}
> Put this in a file "script.groovy" and call "groovy script.groovy"
> Expected: No output
>  Actual: 
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> /Script.groovy: 14: [Static type checking] - Cannot call 
> java.util.List #add(MyClass$Foo) with arguments [MyClass$Bar] 
>  @ line 14, column 9.
>g.add(Bar.AA)
>^
> 1 error{noformat}
> Does not occur in 3.0.0-rc-3 or earlier.
> Looks similar to GROOVY-8960 but does not occur in 2.5.5
> Workaround: Add cast "g.add(Bar.AA as Foo)"



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


[jira] [Commented] (GROOVY-9412) enum added to List fails TypeChecked

2020-03-02 Thread Ian (Jira)


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

Ian commented on GROOVY-9412:
-

If I'm wrong about this, I apologize for taking your time. As far as I can 
tell, the equivalent Java code is valid, and compiles and runs without error in 
pure Java:
{noformat}
import java.util.ArrayList;
import java.util.List;

public class InterfaceList { 

  interface Foo { }

  enum Bar implements Foo { AA }

  static void F() { 
List g = new ArrayList<>(); 
g.add(Bar.AA); 
  }
  
  public static void main(String args[]) { 
F(); 
  }

}{noformat}
Is there some difference in covariance in groovy that makes it invalid there?

 

Also, your suggestion does not resolve the issue. This also gives an error:
{noformat}
import groovy.transform.TypeChecked

@TypeChecked
class MyClass {
interface Foo {}
enum Bar implements Foo {
AA
}
void F() {
List g = []
g.add(Bar.AA)
}
}
new MyClass()
{noformat}
{noformat}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: 
/home/ianl/tmpEnum/script.groovy: 14: [Static type checking] - Cannot call 
java.util.List #add(MyClass$Foo) with arguments 
[MyClass$Bar] 
 @ line 14, column 9. 
   g.add(Bar.AA) 
   ^1 error 
{noformat}
Also, the equivalent code with classes instead of enums does not present this 
error:
{noformat}
import groovy.transform.TypeChecked

@TypeChecked
class MyClass {

interface Foo {}

class Bar implements Foo {}

void F() {
List g = []
g.add(new Bar())
}
}
new MyClass()
{noformat}
Compiles and runs fine.

So in summary:
 # This error does not occur in Java, only in Groovy
 # This error only occurs for Enums, not classes
 # This error occurs both with List and List

 

 

> enum added to List fails TypeChecked
> 
>
> Key: GROOVY-9412
> URL: https://issues.apache.org/jira/browse/GROOVY-9412
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0, 3.0.1
> Environment: CentOS
>Reporter: Ian
>Priority: Major
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
>  
> {code:java}
> import groovy.transform.TypeChecked
> @TypeChecked
> class MyClass {
> interface Foo {}
> enum Bar implements Foo {
> AA
> }
> 
> void F() {
> List g = []
> g.add(Bar.AA)
> }
> }
> new MyClass()
> {code}
> Put this in a file "script.groovy" and call "groovy script.groovy"
> Expected: No output
>  Actual: 
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> /Script.groovy: 14: [Static type checking] - Cannot call 
> java.util.List #add(MyClass$Foo) with arguments [MyClass$Bar] 
>  @ line 14, column 9.
>g.add(Bar.AA)
>^
> 1 error{noformat}
> Does not occur in 3.0.0-rc-3 or earlier.
> Looks similar to GROOVY-8960 but does not occur in 2.5.5
> Workaround: Add cast "g.add(Bar.AA as Foo)"



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


[jira] [Created] (GROOVY-9570) Class-Level Closure Definition With Generics Fails TypeChecked

2020-05-22 Thread Ian (Jira)
Ian created GROOVY-9570:
---

 Summary: Class-Level Closure Definition With Generics Fails 
TypeChecked
 Key: GROOVY-9570
 URL: https://issues.apache.org/jira/browse/GROOVY-9570
 Project: Groovy
  Issue Type: Bug
Affects Versions: 3.0.3, 3.0.0, 2.5.5
Reporter: Ian


import groovy.transform.TypeChecked

@TypeChecked
abstract class A{
Collection testQueue
Closure c = {
testQueue.each{T item->
println item
}
}
//def foo() {
//testQueue.each{T item->
//println item
//}
//}
}
new A(){}
Put this in filename.groovy and call "groovy filename.groovy" and I get
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
filename.groovy: 9: Expected parameter of type java.lang.Object but got T
 @ line 7, column 24.
   testQueue.each{T item->
  ^1 error
Yet, uncomment the method foo() and there's no error there. or put the closure 
definition into the method and there's no error.



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


[jira] [Updated] (GROOVY-9570) Class-Level Closure Definition With Generics Fails TypeChecked

2020-05-22 Thread Ian (Jira)


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

Ian updated GROOVY-9570:

Description: 
 

 
{code:java}
import groovy.transform.TypeChecked@TypeChecked
abstract class A{
Collection testQueue
Closure c = {
testQueue.each{T item->
println item
}
}
//def foo() {
//testQueue.each{T item->
//println item
//}
//}
}
new A(){}
{code}
Put this in filename.groovy and call "groovy filename.groovy" and I get

 
{noformat}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/ianl/closureGeneric.groovy: 9: Expected parameter of type 
java.lang.Object but got T
 @ line 7, column 24.
   testQueue.each{T item->
  ^1 error{noformat}
Yet, uncomment the method foo() and there's no error there. or put the closure 
definition into the method and there's no error.

  was:
import groovy.transform.TypeChecked

@TypeChecked
abstract class A{
Collection testQueue
Closure c = {
testQueue.each{T item->
println item
}
}
//def foo() {
//testQueue.each{T item->
//println item
//}
//}
}
new A(){}
Put this in filename.groovy and call "groovy filename.groovy" and I get
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
filename.groovy: 9: Expected parameter of type java.lang.Object but got T
 @ line 7, column 24.
   testQueue.each{T item->
  ^1 error
Yet, uncomment the method foo() and there's no error there. or put the closure 
definition into the method and there's no error.


> Class-Level Closure Definition With Generics Fails TypeChecked
> --
>
> Key: GROOVY-9570
> URL: https://issues.apache.org/jira/browse/GROOVY-9570
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.5, 3.0.0, 3.0.3
>Reporter: Ian
>Priority: Major
>
>  
>  
> {code:java}
> import groovy.transform.TypeChecked@TypeChecked
> abstract class A{
> Collection testQueue
> Closure c = {
> testQueue.each{T item->
> println item
> }
> }
> //def foo() {
> //testQueue.each{T item->
> //println item
> //}
> //}
> }
> new A(){}
> {code}
> Put this in filename.groovy and call "groovy filename.groovy" and I get
>  
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> /home/ianl/closureGeneric.groovy: 9: Expected parameter of type 
> java.lang.Object but got T
>  @ line 7, column 24.
>testQueue.each{T item->
>   ^1 error{noformat}
> Yet, uncomment the method foo() and there's no error there. or put the 
> closure definition into the method and there's no error.



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


[jira] [Updated] (GROOVY-9570) Class-Level Closure Definition With Generics Fails TypeChecked

2020-05-22 Thread Ian (Jira)


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

Ian updated GROOVY-9570:

Description: 
 

 
{code:java}
import groovy.transform.TypeChecked

@TypeChecked
abstract class A{
Collection testQueue
Closure c = {
testQueue.each{T item->
println item
}
}
//def foo() {
//testQueue.each{T item->
//println item
//}
//}
}
new A(){}
{code}
Put this in filename.groovy and call "groovy filename.groovy" and I get

 
{noformat}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/ianl/closureGeneric.groovy: 9: Expected parameter of type 
java.lang.Object but got T
 @ line 7, column 24.
   testQueue.each{T item->
  ^1 error{noformat}
Yet, uncomment the method foo() and there's no error there. or put the closure 
definition into the method and there's no error.

  was:
 

 
{code:java}
import groovy.transform.TypeChecked@TypeChecked
abstract class A{
Collection testQueue
Closure c = {
testQueue.each{T item->
println item
}
}
//def foo() {
//testQueue.each{T item->
//println item
//}
//}
}
new A(){}
{code}
Put this in filename.groovy and call "groovy filename.groovy" and I get

 
{noformat}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/ianl/closureGeneric.groovy: 9: Expected parameter of type 
java.lang.Object but got T
 @ line 7, column 24.
   testQueue.each{T item->
  ^1 error{noformat}
Yet, uncomment the method foo() and there's no error there. or put the closure 
definition into the method and there's no error.


> Class-Level Closure Definition With Generics Fails TypeChecked
> --
>
> Key: GROOVY-9570
> URL: https://issues.apache.org/jira/browse/GROOVY-9570
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.5, 3.0.0, 3.0.3
>Reporter: Ian
>Priority: Major
>
>  
>  
> {code:java}
> import groovy.transform.TypeChecked
> @TypeChecked
> abstract class A{
> Collection testQueue
> Closure c = {
> testQueue.each{T item->
> println item
> }
> }
> //def foo() {
> //testQueue.each{T item->
> //println item
> //}
> //}
> }
> new A(){}
> {code}
> Put this in filename.groovy and call "groovy filename.groovy" and I get
>  
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> /home/ianl/closureGeneric.groovy: 9: Expected parameter of type 
> java.lang.Object but got T
>  @ line 7, column 24.
>testQueue.each{T item->
>   ^1 error{noformat}
> Yet, uncomment the method foo() and there's no error there. or put the 
> closure definition into the method and there's no error.



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


[jira] [Updated] (GROOVY-9570) Class-Level Closure Definition With Generics Fails TypeChecked

2020-05-22 Thread Ian (Jira)


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

Ian updated GROOVY-9570:

Description: 
 

 
{code:java}
import groovy.transform.TypeChecked

@TypeChecked
abstract class A{
Collection testQueue
Closure c = {
testQueue.each{T item->
println item
}
}
//def foo() {
//testQueue.each{T item->
//println item
//}
//}
}
new A(){}
{code}
Put this in filename.groovy and call "groovy filename.groovy" and I get

 
{noformat}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/ianl/closureGeneric.groovy: 9: Expected parameter of type 
java.lang.Object but got T
 @ line 7, column 24.
   testQueue.each{T item->
  ^
1 error{noformat}
Yet, uncomment the method foo() and there's no error there. or put the closure 
definition into the method and there's no error.

  was:
 

 
{code:java}
import groovy.transform.TypeChecked

@TypeChecked
abstract class A{
Collection testQueue
Closure c = {
testQueue.each{T item->
println item
}
}
//def foo() {
//testQueue.each{T item->
//println item
//}
//}
}
new A(){}
{code}
Put this in filename.groovy and call "groovy filename.groovy" and I get

 
{noformat}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/home/ianl/closureGeneric.groovy: 9: Expected parameter of type 
java.lang.Object but got T
 @ line 7, column 24.
   testQueue.each{T item->
  ^1 error{noformat}
Yet, uncomment the method foo() and there's no error there. or put the closure 
definition into the method and there's no error.


> Class-Level Closure Definition With Generics Fails TypeChecked
> --
>
> Key: GROOVY-9570
> URL: https://issues.apache.org/jira/browse/GROOVY-9570
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.5, 3.0.0, 3.0.3
>Reporter: Ian
>Priority: Major
>
>  
>  
> {code:java}
> import groovy.transform.TypeChecked
> @TypeChecked
> abstract class A{
> Collection testQueue
> Closure c = {
> testQueue.each{T item->
> println item
> }
> }
> //def foo() {
> //testQueue.each{T item->
> //println item
> //}
> //}
> }
> new A(){}
> {code}
> Put this in filename.groovy and call "groovy filename.groovy" and I get
>  
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> /home/ianl/closureGeneric.groovy: 9: Expected parameter of type 
> java.lang.Object but got T
>  @ line 7, column 24.
>testQueue.each{T item->
>   ^
> 1 error{noformat}
> Yet, uncomment the method foo() and there's no error there. or put the 
> closure definition into the method and there's no error.



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


[jira] [Created] (GROOVY-8538) static type checking, generics, and collect

2018-04-09 Thread Ian (JIRA)
Ian created GROOVY-8538:
---

 Summary:  static type checking, generics, and collect 
 Key: GROOVY-8538
 URL: https://issues.apache.org/jira/browse/GROOVY-8538
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.2.2
 Environment: CentOS 7
Gradle 4.6
Reporter: Ian


Broken between 2.2.2 and 2.4.15 (the latest I have access to).

 
{code:java}
import groovy.transform.TypeChecked

@TypeChecked
class MyClass {
List>> ii = []
List> jj = ii.collect { Foo> it -> it.get() }
}

interface Foo {
V get()
}

abstract class Bar {}
{code}
Fails to compile with error:

 

 
{code:java}
MyClass.groovy: 6: [Static type checking] - Incompatible generic argument 
types. Cannot assign java.util.List  to: java.util.List 
@ line 6, column 27.
List> jj = ii.collect { Foo> it -> it.get() }
  ^
{code}
Note that if the type of Foo is changed to  it compiles successfully:
{code:java}
...
interface Foo {
T get()
}

abstract class Bar {}
{code}
Also successfully compiles if the type of Bar is changed to anything else:
{code:java}
...
interface Foo {
V get()
}

abstract class Bar {}{code}
So it seems there is something special in the use of  specifically that 
makes this fail.

This also seems to hold true for classes defined in different files.

 



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


[jira] [Resolved] (GROOVY-8538) static type checking, generics, and collect

2018-06-04 Thread Ian (JIRA)


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

Ian resolved GROOVY-8538.
-
   Resolution: Fixed
Fix Version/s: 2.5.0

>  static type checking, generics, and collect 
> 
>
> Key: GROOVY-8538
> URL: https://issues.apache.org/jira/browse/GROOVY-8538
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.2.2
> Environment: CentOS 7
> Gradle 4.6
>Reporter: Ian
>Priority: Major
> Fix For: 2.5.0
>
>
> Broken between 2.2.2 and 2.4.15 (the latest I have access to).
>  
> {code:java}
> import groovy.transform.TypeChecked
> @TypeChecked
> class MyClass {
> List>> ii = []
> List> jj = ii.collect { Foo> it -> it.get() }
> }
> interface Foo {
> V get()
> }
> abstract class Bar {}
> {code}
> Fails to compile with error:
>  
>  
> {code:java}
> MyClass.groovy: 6: [Static type checking] - Incompatible generic argument 
> types. Cannot assign java.util.List  to: java.util.List 
> @ line 6, column 27.
> List> jj = ii.collect { Foo> it -> it.get() }
>   ^
> {code}
> Note that if the type of Foo is changed to  it compiles successfully:
> {code:java}
> ...
> interface Foo {
> T get()
> }
> abstract class Bar {}
> {code}
> Also successfully compiles if the type of Bar is changed to anything else:
> {code:java}
> ...
> interface Foo {
> V get()
> }
> abstract class Bar {}{code}
> So it seems there is something special in the use of  specifically that 
> makes this fail.
> This also seems to hold true for classes defined in different files.
>  



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


[jira] [Closed] (GROOVY-8538) static type checking, generics, and collect

2018-06-04 Thread Ian (JIRA)


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

Ian closed GROOVY-8538.
---

>  static type checking, generics, and collect 
> 
>
> Key: GROOVY-8538
> URL: https://issues.apache.org/jira/browse/GROOVY-8538
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.2.2
> Environment: CentOS 7
> Gradle 4.6
>Reporter: Ian
>Priority: Major
> Fix For: 2.5.0
>
>
> Broken between 2.2.2 and 2.4.15 (the latest I have access to).
>  
> {code:java}
> import groovy.transform.TypeChecked
> @TypeChecked
> class MyClass {
> List>> ii = []
> List> jj = ii.collect { Foo> it -> it.get() }
> }
> interface Foo {
> V get()
> }
> abstract class Bar {}
> {code}
> Fails to compile with error:
>  
>  
> {code:java}
> MyClass.groovy: 6: [Static type checking] - Incompatible generic argument 
> types. Cannot assign java.util.List  to: java.util.List 
> @ line 6, column 27.
> List> jj = ii.collect { Foo> it -> it.get() }
>   ^
> {code}
> Note that if the type of Foo is changed to  it compiles successfully:
> {code:java}
> ...
> interface Foo {
> T get()
> }
> abstract class Bar {}
> {code}
> Also successfully compiles if the type of Bar is changed to anything else:
> {code:java}
> ...
> interface Foo {
> V get()
> }
> abstract class Bar {}{code}
> So it seems there is something special in the use of  specifically that 
> makes this fail.
> This also seems to hold true for classes defined in different files.
>  



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


[jira] [Commented] (GROOVY-8538) static type checking, generics, and collect

2018-06-04 Thread Ian (JIRA)


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

Ian commented on GROOVY-8538:
-

Confirmed fix in 2.5.0

Thank you very much!

>  static type checking, generics, and collect 
> 
>
> Key: GROOVY-8538
> URL: https://issues.apache.org/jira/browse/GROOVY-8538
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.2.2
> Environment: CentOS 7
> Gradle 4.6
>Reporter: Ian
>Priority: Major
> Fix For: 2.5.0
>
>
> Broken between 2.2.2 and 2.4.15 (the latest I have access to).
>  
> {code:java}
> import groovy.transform.TypeChecked
> @TypeChecked
> class MyClass {
> List>> ii = []
> List> jj = ii.collect { Foo> it -> it.get() }
> }
> interface Foo {
> V get()
> }
> abstract class Bar {}
> {code}
> Fails to compile with error:
>  
>  
> {code:java}
> MyClass.groovy: 6: [Static type checking] - Incompatible generic argument 
> types. Cannot assign java.util.List  to: java.util.List 
> @ line 6, column 27.
> List> jj = ii.collect { Foo> it -> it.get() }
>   ^
> {code}
> Note that if the type of Foo is changed to  it compiles successfully:
> {code:java}
> ...
> interface Foo {
> T get()
> }
> abstract class Bar {}
> {code}
> Also successfully compiles if the type of Bar is changed to anything else:
> {code:java}
> ...
> interface Foo {
> V get()
> }
> abstract class Bar {}{code}
> So it seems there is something special in the use of  specifically that 
> makes this fail.
> This also seems to hold true for classes defined in different files.
>  



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


[jira] [Created] (GROOVY-8715) Cannot Resolve Arrays of Inner Class

2018-07-25 Thread Ian (JIRA)
Ian created GROOVY-8715:
---

 Summary: Cannot Resolve Arrays of Inner Class
 Key: GROOVY-8715
 URL: https://issues.apache.org/jira/browse/GROOVY-8715
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.5.0, 3.0.0-alpha-3
Reporter: Ian


Two files in the 'pkg' package:
{code:java|title=HasClass.groovy}
package pkg 
class HasClass { static class MyClass {} }
{code}
 
{code:java|title=HasClass.groovy}
package pkg
private static void foo(HasClass.MyClass... val) {}
//pkg.HasClass.MyClass[] val // Also Fails
//pkg.HasClass.MyClass val // Does not fail
{code}
Results in the following error:
  
{code:java}
/home/ianl/IdeaProjects/VariousGroovy/src/main/groovy/pkg/UsesClass.groovy: 3: 
unable to resolve class HasClass.MyClass[] 
 @ line 3, column 25.
   private static void foo(HasClass.MyClass... val) {}
   ^
{code}
This fails only for arrays, not single references. It does not occur if the 
files are in the default package.

It is also possible to work around it with a static import:
  
{code:java|title=HasClass.groovy}
package pkg
import static HasClass.MyClass // Now it doesn't fail
private static void foo(MyClass... val) {}
{code}



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