[jira] [Resolved] (GROOVY-10061) "del" ASCII character also should be escaped

2021-04-26 Thread Daniel Sun (Jira)


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

Daniel Sun resolved GROOVY-10061.
-
  Assignee: Daniel Sun
Resolution: Fixed

The proposed PR has been merged. Thanks!

> "del" ASCII character also should be escaped
> 
>
> Key: GROOVY-10061
> URL: https://issues.apache.org/jira/browse/GROOVY-10061
> Project: Groovy
>  Issue Type: Improvement
>Affects Versions: 3.0.8, 4.0.0-alpha-3
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Minor
> Fix For: 4.0.0-beta-1
>
>
> Otherwise, after printing out the result, it does not represent input!
> [https://github.com/apache/groovy/pull/1572]
>  



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


[GitHub] [groovy] danielsun1106 commented on pull request #1572: "del" ASCII character also should be escaped

2021-04-26 Thread GitBox


danielsun1106 commented on pull request #1572:
URL: https://github.com/apache/groovy/pull/1572#issuecomment-827223350


   Merged. Thanks.
   
https://github.com/apache/groovy/commit/4476af5e67bedcdb2c3b80528afcb991610fbcbc


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] asfgit closed pull request #1572: "del" ASCII character also should be escaped

2021-04-26 Thread GitBox


asfgit closed pull request #1572:
URL: https://github.com/apache/groovy/pull/1572


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Created] (GROOVY-10061) "del" ASCII character also should be escaped

2021-04-26 Thread Daniel Sun (Jira)
Daniel Sun created GROOVY-10061:
---

 Summary: "del" ASCII character also should be escaped
 Key: GROOVY-10061
 URL: https://issues.apache.org/jira/browse/GROOVY-10061
 Project: Groovy
  Issue Type: Improvement
Affects Versions: 4.0.0-alpha-3, 3.0.8
Reporter: Daniel Sun
 Fix For: 4.0.0-beta-1


Otherwise, after printing out the result, it does not represent input!

[https://github.com/apache/groovy/pull/1572]

 



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


[jira] [Created] (GROOVY-10060) Support static interface methods

2021-04-26 Thread Christopher Smith (Jira)
Christopher Smith created GROOVY-10060:
--

 Summary: Support static interface methods
 Key: GROOVY-10060
 URL: https://issues.apache.org/jira/browse/GROOVY-10060
 Project: Groovy
  Issue Type: Improvement
  Components: Compiler
Affects Versions: 3.0.8
Reporter: Christopher Smith


Apologies if this is a dupe, but I went back as far as 6000, and GROOVY-8299 is 
the only relevant ticket I saw.

Since Java 8, interfaces can carry static methods like classes. Groovy still 
(as of 3.0.8) does not support adding static methods to interfaces.

{code}
The method 'java.lang.String dynamoTableNameForType(java.lang.String)' from 
interface 'com.example.HasDynamo' must not be static. Only fields may be static 
in an interface.
{code}



--
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] [Comment Edited] (GROOVY-10040) @AnnotationCollector - Only classes and closures can be used for attribute 'value' in ...

2021-04-26 Thread Marcin Zajaczkowski (Jira)


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

Marcin Zajaczkowski edited comment on GROOVY-10040 at 4/26/21, 4:14 PM:


I was able to reproduce that problem without Closure. Using any enum is also 
problematic
{code:java}
class CustomCompiler {
  final GroovyClassLoader loader = new GroovyClassLoader(getClass().classLoader)

  static void main(String[] args) {
new CustomCompiler().compile()
  }

  void compile() {
Class clazz = loader.parseClass("""
//@${CustomCompiler.class.packageName}.EnumAnnotation(${CustomCompiler.class.packageName}.MyEnum.BAR)
 //works fine
@${CustomCompiler.class.packageName}.MetaEnum
class Foo {
 void foo() {
 }
}
""")
assert clazz
  }
}

enum MyEnum {
FOO, BAR
}

@interface EnumAnnotation {
MyEnum value()
}

@EnumAnnotation(MyEnum.BAR)
@AnnotationCollector
@interface MetaEnum {
}
{code}

With an error:
{code:java}
Exception in thread "main" 
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script_38dfc334e76a8e3f31d2efef7266fb23.groovy: -1: Expected enum value for 
attribute value in @info.solidsoft.blog.spock2.migration.EnumAnnotation
 @ line -1, column -1.
1 error
...{code}


was (Author: szpak):
I was able to reproduce that problem without Closure. Using any enum is also 
problematic
{code:java}
class CustomCompiler {
  final GroovyClassLoader loader = new GroovyClassLoader(getClass().classLoader)

  static void main(String[] args) {
new CustomCompiler().compile()
  }

  void compile() {
Class clazz = loader.parseClass("""
//@${CustomCompiler.class.packageName}.EnumAnnotation(${CustomCompiler.class.packageName}.MyEnum.BAR)
 //works fine
@${CustomCompiler.class.packageName}.MetaEnum
class Foo {
 void foo() {
 }
}
""")
assert clazz
  }
}

enum MyEnum {
FOO, BAR
}

@interface EnumAnnotation {
MyEnum value()
}

@EnumAnnotation(MyEnum.BAR)
@AnnotationCollector
@interface MetaEnum {
}
{code}

> @AnnotationCollector - Only classes and closures can be used for attribute 
> 'value' in ...
> -
>
> Key: GROOVY-10040
> URL: https://issues.apache.org/jira/browse/GROOVY-10040
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 3.0.7
> Environment: Groovy 3.0.7
>Reporter: Marcin Zajaczkowski
>Priority: Minor
>
> I've bumped into that problem writing regression tests for using 
> @AnnotationCollector in Spock to achieve meta-annotation support. A custom 
> annotation accepting Clusure is problematic with @AnnotationCollector. It 
> compiles file with groovyc, but not with ClassLoader (which is used by 
> Spock's EmbeddedSpecCompiler).
> The problem can be simply reproduced with `GroovyClassLoader`:
> {code:java}
> package foobar
> import groovy.transform.AnnotationCollector
> class CustomCompiler {
>   final GroovyClassLoader loader = new 
> GroovyClassLoader(getClass().classLoader)
>   static void main(String[] args) {
> new CustomCompiler().compile()
>   }
>   void compile() {
> Class clazz = loader.parseClass("""
> //@${CustomCompiler.class.packageName}.RetryCustom //works fine
> @${CustomCompiler.class.packageName}.MetaCustom 
> //MultipleCompilationErrorsException exception
> class Foo {
>  void foo() {
>  }
> }
> """)
> assert clazz
>   }
> }
> @RetryCustom(1)
> @RequiresCustom({ 1 == 1 })
> @AnnotationCollector
> @interface MetaCustom {
> }
> @interface RequiresCustom {
>   Class value()
> }
> @interface RetryCustom {
>   int value()
> }
> {code}
> which results in:
> {code:java}
> Exception in thread "main" 
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Script_45e27a459ca58d9b86efd544e2929b39.groovy: -1: Only classes and closures 
> can be used for attribute 'value' in @foobar.RequiresCustom
>  @ line -1, column -1.
> 1 error
> at 
> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:295)
>  at 
> org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:984)
>  at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671)
>  at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635)
>  at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
>  at 
> groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
>  at 
> org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
>  at 
> org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
>  at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
>  at 

[jira] [Commented] (GROOVY-10040) @AnnotationCollector - Only classes and closures can be used for attribute 'value' in ...

2021-04-26 Thread Marcin Zajaczkowski (Jira)


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

Marcin Zajaczkowski commented on GROOVY-10040:
--

I was able to reproduce that problem without Closure. Using any enum is also 
problematic
{code:java}
class CustomCompiler {
  final GroovyClassLoader loader = new GroovyClassLoader(getClass().classLoader)

  static void main(String[] args) {
new CustomCompiler().compile()
  }

  void compile() {
Class clazz = loader.parseClass("""
//@${CustomCompiler.class.packageName}.EnumAnnotation(${CustomCompiler.class.packageName}.MyEnum.BAR)
 //works fine
@${CustomCompiler.class.packageName}.MetaEnum
class Foo {
 void foo() {
 }
}
""")
assert clazz
  }
}

enum MyEnum {
FOO, BAR
}

@interface EnumAnnotation {
MyEnum value()
}

@EnumAnnotation(MyEnum.BAR)
@AnnotationCollector
@interface MetaEnum {
}
{code}

> @AnnotationCollector - Only classes and closures can be used for attribute 
> 'value' in ...
> -
>
> Key: GROOVY-10040
> URL: https://issues.apache.org/jira/browse/GROOVY-10040
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 3.0.7
> Environment: Groovy 3.0.7
>Reporter: Marcin Zajaczkowski
>Priority: Minor
>
> I've bumped into that problem writing regression tests for using 
> @AnnotationCollector in Spock to achieve meta-annotation support. A custom 
> annotation accepting Clusure is problematic with @AnnotationCollector. It 
> compiles file with groovyc, but not with ClassLoader (which is used by 
> Spock's EmbeddedSpecCompiler).
> The problem can be simply reproduced with `GroovyClassLoader`:
> {code:java}
> package foobar
> import groovy.transform.AnnotationCollector
> class CustomCompiler {
>   final GroovyClassLoader loader = new 
> GroovyClassLoader(getClass().classLoader)
>   static void main(String[] args) {
> new CustomCompiler().compile()
>   }
>   void compile() {
> Class clazz = loader.parseClass("""
> //@${CustomCompiler.class.packageName}.RetryCustom //works fine
> @${CustomCompiler.class.packageName}.MetaCustom 
> //MultipleCompilationErrorsException exception
> class Foo {
>  void foo() {
>  }
> }
> """)
> assert clazz
>   }
> }
> @RetryCustom(1)
> @RequiresCustom({ 1 == 1 })
> @AnnotationCollector
> @interface MetaCustom {
> }
> @interface RequiresCustom {
>   Class value()
> }
> @interface RetryCustom {
>   int value()
> }
> {code}
> which results in:
> {code:java}
> Exception in thread "main" 
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Script_45e27a459ca58d9b86efd544e2929b39.groovy: -1: Only classes and closures 
> can be used for attribute 'value' in @foobar.RequiresCustom
>  @ line -1, column -1.
> 1 error
> at 
> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:295)
>  at 
> org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:984)
>  at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671)
>  at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635)
>  at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
>  at 
> groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
>  at 
> org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
>  at 
> org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
>  at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
>  at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314)
>  at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:257)
>  at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
>  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 java.base/java.lang.reflect.Method.invoke(Method.java:566)
>  at 
> org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
>  at 
> org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrap.invoke(PojoMetaMethodSite.java:203)
>  at 
> org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
>  at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
>  at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>  at 
> 

[jira] [Commented] (GROOVY-10054) STC: Cannot infer lambda parameter types for a Stream Collector in a generic method

2021-04-26 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-10054:
--

The static type checker visits the non-closure method arguments before 
selecting the method, because it needs type information to choose the best fit. 
 So, to work around this, you can assign the collector to a local variable 
first, like this:
{code:groovy}
Map> group(Set set) {
Collector>> grouping =
Collectors.groupingBy(named -> named.getName())
set.stream().collect(grouping);
}
{code}

Not ideal, but should pass STC until this issue can be resolved.

> STC: Cannot infer lambda parameter types for a Stream Collector in a generic 
> method
> ---
>
> Key: GROOVY-10054
> URL: https://issues.apache.org/jira/browse/GROOVY-10054
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
> Environment: OpenJDK8
>Reporter: Lyuben Atanasov
>Assignee: Eric Milles
>Priority: Major
>
> This is a follow-up to GROOVY-10049. After the issue there had been fixed I 
> was able to progress further with a chain of Stream method calls. However, 
> the fix doesn't seem to cover the following case:
> {code}
> import java.util.stream.Collectors;
> class Test {
>   static interface Named {
>   String getName();
>   }
>Map> group(Set namedObjects) {
>   return namedObjects.stream()
>   .collect(Collectors.groupingBy(named -> 
> named.getName()));
>   }
>   
> }
> {code}
> With static type checking enabled, an error is produced:
> {noformat}
> Script_ce61a645759c941d687680111f9bedbd.groovy: 11: [Static type checking] - 
> Cannot find matching method java.lang.Object#getName(). Please check if the 
> declared type is correct and if the method exists.
>  @ line 11, column 44.
>ollectors.groupingBy(named -> named.getN
> {noformat}
> The difference between this issue and GROOVY-10049 is that the lambda passed 
> here is not directly assigned to a Stream method. Of course, the issue is 
> probably not limited to Collectors, but this is how I am able to reproduce it.
> I've tested this against 
> https://github.com/apache/groovy/commit/e07f0112c5eff8d9c6828bd0ddb69e4b7f7cc1d6



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


[jira] [Resolved] (GROOVY-10033) Compiler crash when encountering function reference on nested class

2021-04-26 Thread Eric Milles (Jira)


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

Eric Milles resolved GROOVY-10033.
--
Fix Version/s: 4.0.0-beta-1
   Resolution: Fixed

> Compiler crash when encountering function reference on nested class
> ---
>
> Key: GROOVY-10033
> URL: https://issues.apache.org/jira/browse/GROOVY-10033
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-1
>
>
> The following program
>  
> {code:java}
> class Foo {
>   protected Foo(Closure x) {}
> }
> class Bar {
> Bar(Foo x) {}
> }
> public class X extends Foo {
> public X() {
> super(Y::new);
> }
> private class Y extends Bar {
> Y(Foo x) {
> super(x);
> }
> }
> }
> {code}
>  
> crashes the compiler with a NullPointerException
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> General error during instruction selection: NullPointerException while 
> processing test.groovy. test.groovygroovy.lang.GroovyRuntimeException: 
> NullPointerException while processing test.groovy. test.groovy
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:348)
> at 
> org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:783)
> at 
> org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:928)
> at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:657)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:634)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:609)
> at 
> org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311)
> at 
> org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240)
> at 
> org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165)
> at 
> org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205)
> at 
> org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189)
> Caused by: java.lang.NullPointerException
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.createParametersWithExactType(StaticTypesMethodReferenceExpressionWriter.java:255)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:97)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:844)
> at 
> org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.visitArgument(StaticInvocationWriter.java:517)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.loadArguments(StaticInvocationWriter.java:464)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.writeSpecialConstructorCall(StaticInvocationWriter.java:212)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorCallExpression(AsmClassGenerator.java:917)
> at 
> org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:45)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:602)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:744)
> at 
> org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:92)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:78)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:675)
> at 
> org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:516)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:461)
> at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:101)
> at 
> 

[jira] [Resolved] (GROOVY-10056) Inferred parameter type of lambda expression for multi-dimensions array is not correct

2021-04-26 Thread Eric Milles (Jira)


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

Eric Milles resolved GROOVY-10056.
--
Fix Version/s: 4.0.0-beta-1
   Resolution: Fixed

> Inferred parameter type of lambda expression for multi-dimensions array is 
> not correct
> --
>
> Key: GROOVY-10056
> URL: https://issues.apache.org/jira/browse/GROOVY-10056
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Affects Versions: 4.0.0-alpha-3
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
> Fix For: 4.0.0-beta-1
>
>  Time Spent: 5h 20m
>  Remaining Estimate: 0h
>
> The type of {{strs}} is inferred as {{String}}, but its type should be 
> {{String[]}}
> {code:java}
> @groovy.transform.CompileStatic
> def test() {
> String[][] strsArray = new String[][] {
> new String[] {'a', 'b', 'c'},
> new String[] {'d', 'e', 'f'}
> }
> Arrays.stream(strsArray)
> .limit(1)
> .forEach(strs -> {
> assert ['a', 'b', 'c'] == Arrays.asList(strs)
> })
> }
> test()
> {code}
> *Error message*
> {code:java}
> java.lang.ClassCastException: class [Ljava.lang.String; cannot be cast to 
> class java.lang.String ([Ljava.lang.String; and java.lang.String are in 
> module java.base of loader 'bootstrap')
>   at 
> java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>   at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)
>   at 
> java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
>   at 
> java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
>   at 
> java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
>   at 
> java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
>   at 
> java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>   at 
> java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>   at 
> java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>   at 
> java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>   at 
> java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>   at ConsoleScript3.test(ConsoleScript3:7)
>   at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318)
>   at ConsoleScript3.run(ConsoleScript3:13)
>   at 
> groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:257)
>   at groovy.lang.GroovyShell.run(GroovyShell.java:363)
>   at groovy.lang.GroovyShell.run(GroovyShell.java:342)
>   at groovy.lang.GroovyShell.run(GroovyShell.java:168)
>   at groovy.console.ui.Console$GroovySourceType.run(Console.groovy:1177)
>   at groovy.console.ui.Console.doRun(Console.groovy:1408)
>   at jdk.internal.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
>   at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>   at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:112)
>   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
>   at 
> org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:331)
>   at 
> org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:63)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)
>   at 
> groovy.console.ui.Console$_runScriptImpl_closure23.doCall(Console.groovy:1372)
>   at 
> groovy.console.ui.Console$_runScriptImpl_closure23.doCall(Console.groovy)
>   at jdk.internal.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
>   at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>   at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:112)
>   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
>   at 
> org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:268)
>   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
>   at groovy.lang.Closure.call(Closure.java:419)
>   at groovy.lang.Closure.call(Closure.java:413)
>   at 

[jira] [Resolved] (GROOVY-10052) STC sometimes requires explicit closure to SAM cast inside of another closure

2021-04-26 Thread Eric Milles (Jira)


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

Eric Milles resolved GROOVY-10052.
--
Fix Version/s: 4.0.0-beta-1
   Resolution: Fixed

> STC sometimes requires explicit closure to SAM cast inside of another closure
> -
>
> Key: GROOVY-10052
> URL: https://issues.apache.org/jira/browse/GROOVY-10052
> Project: Groovy
>  Issue Type: Improvement
>  Components: Static compilation, Static Type Checker
>Affects Versions: 3.0.8
>Reporter: Damir Murat
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-1
>
>
> After upgrading to the 3.0.8 version, I observed several improvements in STC, 
> but it looks like some cases are still uncovered. Say I have the following 
> script (tested with Groovy console):
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.function.Predicate
> import java.util.function.Supplier
> import java.util.stream.Collectors
> @CompileStatic
> class Test {
>   void testMe() {
> String maybeSomeString = Optional.of("Some Name")
> .orElseThrow({ new NoSuchElementException("Nothing found") }) // line 
> 1 - no explicit cast
> println maybeSomeString
> 
> List stringList = ["1ab", "2cd"]
> .stream()
> .flatMap({ it.toList().stream() })
> .filter({ Character.isLetterOrDigit(it.chars[0]) }) // line 2 - no 
> explicit cast
> .collect(Collectors.toList())
> 
> println stringList
> [1, 2, 3]
> .stream()
> .map({
>   String maybeSomeOtherString = Optional
>   .of("Some Other Name")
>   .orElseThrow({ new NoSuchElementException("Nothing found") } as 
> Supplier) // line 3 - explicit cast needed
>   return "$it: $maybeSomeOtherString".toString()
> })
> .peek({
>   List list = it.toList()
>   .stream()
>   .filter({ Character.isLetterOrDigit(it.chars[0]) }) // line 4 - 
> no explicit cast and no explicit parameter type
>   .collect(Collectors.toList())
>   println list
> })
> .forEach({println it })
>   }
> }
> new Test().testMe()
> {code}
> In line 3, an explicit cast to Supplier is needed. It wasn't required for 
> 3.0.7. When removed, the checker throws
> {code}
> [Static type checking] - Cannot call  
> java.util.Optional #orElseThrow(java.util.function.Supplier 
> ) with arguments [groovy.lang.Closure 
> ] 
>  at line: 26, column: 41
> {code}
> As can be seen from the sample, coercion works if the closure is not nested 
> inside of another closure.
> For comparison, with the 3.0.7 version, line 1 and 2 behaves the same as for 
> 3.0.8.
> In 3.0.7, line 3 did not require an explicit cast. In line 4, 3.0.7 requires 
> explicit cast and explicit parameter declaration, while 3.0.8 does not 
> require either.
> Tnx



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


[jira] [Assigned] (GROOVY-10055) STC does not support self bounded types

2021-04-26 Thread Eric Milles (Jira)


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

Eric Milles reassigned GROOVY-10055:


Assignee: Eric Milles

> STC does not support self bounded types
> ---
>
> Key: GROOVY-10055
> URL: https://issues.apache.org/jira/browse/GROOVY-10055
> Project: Groovy
>  Issue Type: Improvement
>  Components: Static compilation, Static Type Checker
>Affects Versions: 3.0.8
>Reporter: Damir Murat
>Assignee: Eric Milles
>Priority: Major
>
> Some popular libraries use self bounded types for creating builder 
> hierarchies. For example, 
> PostgreSQLContainer (from Tescontainers library) is declared as 
> {code}
> public class PostgreSQLContainer> 
> extends JdbcDatabaseContainer
> {code}
> where JdbcDatabaseContainer is declared as
> {code}
> public abstract class JdbcDatabaseContainer JdbcDatabaseContainer> extends GenericContainer implements 
> LinkableContainer
> {code}
> and so on.
> In the following example (tested with Groovy Console), I'm trying to create 
> and modify such an object with its corresponding fluent API:
> {code}
> import org.testcontainers.containers.PostgreSQLContainer
> import groovy.transform.CompileStatic
> @Grab("org.testcontainers:testcontainers:1.15.3")
> @Grab("org.testcontainers:postgresql:1.15.3")
> @CompileStatic
> class TestcontainersTester {
>   static void testSome() {
> PostgreSQLContainer postgresqlServer = new PostgreSQLContainer()
> .withExposedPorts(5432)
> .withEnv(["TZ": "Europe/Paris"])
> .withDatabaseName("my_database")
> .withUsername("user")
> .withPassword("pass")
> // Working alternative 1
> //PostgreSQLContainer postgresqlServer = new 
> PostgreSQLContainer>>>()
> //.withExposedPorts(5432)
> //.withEnv(["TZ": "Europe/Paris"])
> //.withDatabaseName("my_database")
> //.withUsername("user")
> //.withPassword("pass")
> // Working alternative 2
> //PostgreSQLContainer postgresqlServer = new PostgreSQLContainer<>()
> //postgresqlServer.withExposedPorts(5432)
> //postgresqlServer.withEnv(["TZ": "Europe/Paris"])
> //postgresqlServer.withDatabaseName("my_database")
> //postgresqlServer.withUsername("user")
> //postgresqlServer.withPassword("pass")
> println postgresqlServer
>   }
> }
> TestcontainersTester.testSome();
> {code}
> Unfortunately, STC complains with several errors:
> {code}
> 4 compilation errors:
> [Static type checking] - Cannot call SELF#withEnv(java.util.Map 
> ) with arguments [java.util.LinkedHashMap 
> ] 
>  at line: 11, column: 17
> [Static type checking] - Cannot find matching method 
> java.lang.Object#withDatabaseName(java.lang.String). Please check if the 
> declared type is correct and if the method exists.
>  at line: 12, column: 26
> [Static type checking] - Cannot find matching method 
> java.lang.Object#withUsername(java.lang.String). Please check if the declared 
> type is correct and if the method exists.
>  at line: 13, column: 22
> [Static type checking] - Cannot find matching method 
> java.lang.Object#withPassword(java.lang.String). Please check if the declared 
> type is correct and if the method exists.
>  at line: 9, column: 44
> {code}
> There are two working alternatives in the example. "Alternative 1" is not 
> really practical, but maybe it can help with solving the issue. "Alternative 
> 2" is an actual practical workaround that can be further improved by using 
> the "with" method.
> Tnx



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


[jira] [Assigned] (GROOVY-10056) Inferred parameter type of lambda expression for multi-dimensions array is not correct

2021-04-26 Thread Eric Milles (Jira)


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

Eric Milles reassigned GROOVY-10056:


Assignee: Daniel Sun  (was: Eric Milles)

> Inferred parameter type of lambda expression for multi-dimensions array is 
> not correct
> --
>
> Key: GROOVY-10056
> URL: https://issues.apache.org/jira/browse/GROOVY-10056
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Affects Versions: 4.0.0-alpha-3
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
>  Time Spent: 5h 20m
>  Remaining Estimate: 0h
>
> The type of {{strs}} is inferred as {{String}}, but its type should be 
> {{String[]}}
> {code:java}
> @groovy.transform.CompileStatic
> def test() {
> String[][] strsArray = new String[][] {
> new String[] {'a', 'b', 'c'},
> new String[] {'d', 'e', 'f'}
> }
> Arrays.stream(strsArray)
> .limit(1)
> .forEach(strs -> {
> assert ['a', 'b', 'c'] == Arrays.asList(strs)
> })
> }
> test()
> {code}
> *Error message*
> {code:java}
> java.lang.ClassCastException: class [Ljava.lang.String; cannot be cast to 
> class java.lang.String ([Ljava.lang.String; and java.lang.String are in 
> module java.base of loader 'bootstrap')
>   at 
> java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
>   at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)
>   at 
> java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
>   at 
> java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
>   at 
> java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
>   at 
> java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
>   at 
> java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
>   at 
> java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
>   at 
> java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
>   at 
> java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>   at 
> java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
>   at ConsoleScript3.test(ConsoleScript3:7)
>   at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318)
>   at ConsoleScript3.run(ConsoleScript3:13)
>   at 
> groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:257)
>   at groovy.lang.GroovyShell.run(GroovyShell.java:363)
>   at groovy.lang.GroovyShell.run(GroovyShell.java:342)
>   at groovy.lang.GroovyShell.run(GroovyShell.java:168)
>   at groovy.console.ui.Console$GroovySourceType.run(Console.groovy:1177)
>   at groovy.console.ui.Console.doRun(Console.groovy:1408)
>   at jdk.internal.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
>   at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>   at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:112)
>   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
>   at 
> org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:331)
>   at 
> org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:63)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)
>   at 
> groovy.console.ui.Console$_runScriptImpl_closure23.doCall(Console.groovy:1372)
>   at 
> groovy.console.ui.Console$_runScriptImpl_closure23.doCall(Console.groovy)
>   at jdk.internal.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
>   at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>   at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:112)
>   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
>   at 
> org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:268)
>   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
>   at groovy.lang.Closure.call(Closure.java:419)
>   at groovy.lang.Closure.call(Closure.java:413)
>   at groovy.lang.Closure.run(Closure.java:501)
>   at 

[GitHub] [groovy] eric-milles merged pull request #1571: GROOVY-10056: Inferred parameter type of lambda expression for multi-…

2021-04-26 Thread GitBox


eric-milles merged pull request #1571:
URL: https://github.com/apache/groovy/pull/1571


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eustas opened a new pull request #1572: "del" ASCII character also should be escaped

2021-04-26 Thread GitBox


eustas opened a new pull request #1572:
URL: https://github.com/apache/groovy/pull/1572


   Otherwise, after printing out the result, it does not represent input!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eric-milles commented on a change in pull request #1571: GROOVY-10056: Inferred parameter type of lambda expression for multi-…

2021-04-26 Thread GitBox


eric-milles commented on a change in pull request #1571:
URL: https://github.com/apache/groovy/pull/1571#discussion_r619891683



##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
##
@@ -5305,10 +5305,7 @@ protected ClassNode inferReturnTypeGenerics(final 
ClassNode receiver, final Meth
 
applyGenericsContextToParameterClass(resolvedPlaceholders, paramType));
 }
 }
-if (isVargs && lastArg && argumentType.isArray()) {
-argumentType = argumentType.getComponentType();
-}
-if (isVargs && lastArg && paramType.isArray()) {
+if (isVargs && lastArg && paramType.isArray() && 
!argumentType.isArray()) {
 paramType = paramType.getComponentType();
 }

Review comment:
   What about tying the checks together?  I have tried this for the test 
case, but have run out of time today to run the full test suite.
   ```java
   if (isVargs && lastArg && argumentType.isArray() && 
paramType.isArray()) {
   argumentType = argumentType.getComponentType();
   paramType = paramType.getComponentType();
   }
   ```

##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
##
@@ -5305,10 +5305,7 @@ protected ClassNode inferReturnTypeGenerics(final 
ClassNode receiver, final Meth
 
applyGenericsContextToParameterClass(resolvedPlaceholders, paramType));
 }
 }
-if (isVargs && lastArg && argumentType.isArray()) {
-argumentType = argumentType.getComponentType();
-}
-if (isVargs && lastArg && paramType.isArray()) {
+if (isVargs && lastArg && paramType.isArray() && 
!argumentType.isArray()) {
 paramType = paramType.getComponentType();
 }

Review comment:
   What about tying the checks together?  ~I have tried this for the test 
case, but have run out of time today to run the full test suite.~  This passes 
all tests.
   ```java
   if (isVargs && lastArg && argumentType.isArray() && 
paramType.isArray()) {
   argumentType = argumentType.getComponentType();
   paramType = paramType.getComponentType();
   }
   ```

##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
##
@@ -5305,10 +5305,7 @@ protected ClassNode inferReturnTypeGenerics(final 
ClassNode receiver, final Meth
 
applyGenericsContextToParameterClass(resolvedPlaceholders, paramType));
 }
 }
-if (isVargs && lastArg && argumentType.isArray()) {
-argumentType = argumentType.getComponentType();
-}
-if (isVargs && lastArg && paramType.isArray()) {
+if (isVargs && lastArg && paramType.isArray() && 
!argumentType.isArray()) {
 paramType = paramType.getComponentType();
 }

Review comment:
   So probably not correct to reduce the arrays together.  But I don't 
think it is correct to reduce the parameter type only in the argument is not 
still an array.  There are more complete variadic checks in other blocks; I 
think the ones in `inferReturnTypeGenerics` are quite simplistic.  Like if the 
param type is `Object[]`, it accepts any array type.
   
   I did not get the error for "new ListExpression(Arrays.asList(..." and I'm 
not sure why that is.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] danielsun1106 commented on a change in pull request #1570: GROOVY-10056: Inferred parameter type of lambda expression for multi-…

2021-04-26 Thread GitBox


danielsun1106 commented on a change in pull request #1570:
URL: https://github.com/apache/groovy/pull/1570#discussion_r619682681



##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
##
@@ -480,8 +480,14 @@ public static boolean isAssignableTo(ClassNode type, 
ClassNode toBeAssignedTo) {
 return false;
 }
 
-static boolean isVargs(final Parameter[] parameters) {
+static boolean isVargs(final Parameter[] parameters, ClassNode[] 
argumentTypes) {
 if (parameters == null || parameters.length == 0) return false;
+
+// GROOVY-10056: Inferred parameter type of lambda expression for 
multi-dimensions array is not correct
+if (null != argumentTypes && argumentTypes.length == parameters.length 
&& argumentTypes[argumentTypes.length - 1].isArray()) {
+return false;
+}
+

Review comment:
   I tried to revert all changes and just to refine the check as you 
suggested:
   
   **Original**
   
https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java#L5286
   
   **Refined**
   ```
   boolean isVargs = -1 != lastArgMatchesVarg(parameters, 
expressions.stream().map(e -> 
getDeclaredOrInferredType(e)).toArray(ClassNode[]::new));
   ```
   
   but the build will be broken, then we can not debug... 
   `lastArgMatchesVarg` is much more complicated than `isVargs`, it is hard to 
replace `isVargs`.

##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
##
@@ -480,8 +480,14 @@ public static boolean isAssignableTo(ClassNode type, 
ClassNode toBeAssignedTo) {
 return false;
 }
 
-static boolean isVargs(final Parameter[] parameters) {
+static boolean isVargs(final Parameter[] parameters, ClassNode[] 
argumentTypes) {
 if (parameters == null || parameters.length == 0) return false;
+
+// GROOVY-10056: Inferred parameter type of lambda expression for 
multi-dimensions array is not correct
+if (null != argumentTypes && argumentTypes.length == parameters.length 
&& argumentTypes[argumentTypes.length - 1].isArray()) {
+return false;
+}
+

Review comment:
   I tried to revert all changes and just to refine the check as you 
suggested:
   
   **Original**
   
https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java#L5286
   
   **Refined**
   ```java
   boolean isVargs = -1 != lastArgMatchesVarg(parameters, 
expressions.stream().map(e -> 
getDeclaredOrInferredType(e)).toArray(ClassNode[]::new));
   ```
   
   but the build will be broken, then we can not debug... 
   `lastArgMatchesVarg` is much more complicated than `isVargs`, it is hard to 
replace `isVargs`.

##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
##
@@ -480,8 +480,14 @@ public static boolean isAssignableTo(ClassNode type, 
ClassNode toBeAssignedTo) {
 return false;
 }
 
-static boolean isVargs(final Parameter[] parameters) {
+static boolean isVargs(final Parameter[] parameters, ClassNode[] 
argumentTypes) {
 if (parameters == null || parameters.length == 0) return false;
+
+// GROOVY-10056: Inferred parameter type of lambda expression for 
multi-dimensions array is not correct
+if (null != argumentTypes && argumentTypes.length == parameters.length 
&& argumentTypes[argumentTypes.length - 1].isArray()) {
+return false;
+}
+

Review comment:
   In order to keep the method `isVargs` as it is, I even tried the 
following approach, but the build will still be broken...
   
   **Original**
   
https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java#L5286
   
   **Refined**
   ```java
   boolean isVargs = isVargs(parameters);
   if (isVargs) {
   ClassNode[] argumentTypes = expressions.stream().map(e -> 
getDeclaredOrInferredType(e)).toArray(ClassNode[]::new);
   if (null != argumentTypes && argumentTypes.length == 
parameters.length && argumentTypes[argumentTypes.length - 1].isArray()) {
   isVargs = false;
   }
   }
   ```

##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
##
@@ -480,8 +480,14 @@ public static boolean isAssignableTo(ClassNode type, 
ClassNode toBeAssignedTo) {
 return false;
 }
 
-static boolean isVargs(final Parameter[] parameters) {
+static boolean isVargs(final Parameter[] parameters, ClassNode[] 
argumentTypes) {
 if (parameters == null || parameters.length == 0) return false;
+
+// GROOVY-10056: Inferred parameter type of lambda expression for 
multi-dimensions array is not correct
+if (null != 

[GitHub] [groovy] eric-milles commented on pull request #1570: GROOVY-10056: Inferred parameter type of lambda expression for multi-…

2021-04-26 Thread GitBox


eric-milles commented on pull request #1570:
URL: https://github.com/apache/groovy/pull/1570#issuecomment-826112270


   Is there any overlap with https://issues.apache.org/jira/browse/GROOVY-9813 
and this?  Or are they satisfied out of very separate paths?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] paulk-asert commented on pull request #1554: GROOVY-4990 Make File.write() create any missing directories. Add test.

2021-04-26 Thread GitBox


paulk-asert commented on pull request #1554:
URL: https://github.com/apache/groovy/pull/1554#issuecomment-826272790


   I merged and tweaked your test and modified the DGM methods as per the 
earlier suggestion. Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] danielsun1106 commented on a change in pull request #1571: GROOVY-10056: Inferred parameter type of lambda expression for multi-…

2021-04-26 Thread GitBox


danielsun1106 commented on a change in pull request #1571:
URL: https://github.com/apache/groovy/pull/1571#discussion_r619904458



##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
##
@@ -5305,10 +5305,7 @@ protected ClassNode inferReturnTypeGenerics(final 
ClassNode receiver, final Meth
 
applyGenericsContextToParameterClass(resolvedPlaceholders, paramType));
 }
 }
-if (isVargs && lastArg && argumentType.isArray()) {
-argumentType = argumentType.getComponentType();
-}
-if (isVargs && lastArg && paramType.isArray()) {
+if (isVargs && lastArg && paramType.isArray() && 
!argumentType.isArray()) {
 paramType = paramType.getComponentType();
 }

Review comment:
   As the following code will make `argumentType` and `paramType` non-array 
type, so `isVargs && lastArg && argumentType.isArray() && paramType.isArray()` 
will be always `false` IMO.
   
   
https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java#L5297-L5300
   
   Anyway, let me try according to you suggestion.
   

##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
##
@@ -5305,10 +5305,7 @@ protected ClassNode inferReturnTypeGenerics(final 
ClassNode receiver, final Meth
 
applyGenericsContextToParameterClass(resolvedPlaceholders, paramType));
 }
 }
-if (isVargs && lastArg && argumentType.isArray()) {
-argumentType = argumentType.getComponentType();
-}
-if (isVargs && lastArg && paramType.isArray()) {
+if (isVargs && lastArg && paramType.isArray() && 
!argumentType.isArray()) {
 paramType = paramType.getComponentType();
 }

Review comment:
   As the following code will make `argumentType` and `paramType` non-array 
type, so `isVargs && lastArg && argumentType.isArray() && paramType.isArray()` 
will be always `false` IMO.
   
   ```java
   while (paramType.isArray() && argumentType.isArray()) {
   paramType = paramType.getComponentType();
   argumentType = argumentType.getComponentType();
   }
   ```
   
(https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java#L5297-L5300)
   
   Anyway, let me try according to you suggestion.
   

##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
##
@@ -5305,10 +5305,7 @@ protected ClassNode inferReturnTypeGenerics(final 
ClassNode receiver, final Meth
 
applyGenericsContextToParameterClass(resolvedPlaceholders, paramType));
 }
 }
-if (isVargs && lastArg && argumentType.isArray()) {
-argumentType = argumentType.getComponentType();
-}
-if (isVargs && lastArg && paramType.isArray()) {
+if (isVargs && lastArg && paramType.isArray() && 
!argumentType.isArray()) {
 paramType = paramType.getComponentType();
 }

Review comment:
   As the following code will make `argumentType` and `paramType` non-array 
type, so `isVargs && lastArg && argumentType.isArray() && paramType.isArray()` 
will always be `false` IMO.
   
   ```java
   while (paramType.isArray() && argumentType.isArray()) {
   paramType = paramType.getComponentType();
   argumentType = argumentType.getComponentType();
   }
   ```
   
(https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java#L5297-L5300)
   
   Anyway, let me try according to you suggestion.
   

##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
##
@@ -5305,10 +5305,7 @@ protected ClassNode inferReturnTypeGenerics(final 
ClassNode receiver, final Meth
 
applyGenericsContextToParameterClass(resolvedPlaceholders, paramType));
 }
 }
-if (isVargs && lastArg && argumentType.isArray()) {
-argumentType = argumentType.getComponentType();
-}
-if (isVargs && lastArg && paramType.isArray()) {
+if (isVargs && lastArg && paramType.isArray() 

[GitHub] [groovy] xaaria commented on pull request #1554: GROOVY-4990 Make File.write() create any missing directories. Add test.

2021-04-26 Thread GitBox


xaaria commented on pull request #1554:
URL: https://github.com/apache/groovy/pull/1554#issuecomment-826069148


   @paulk-asert We implented this (easy) feature because participating an open 
source project is a mandatory part of our university's course _Software 
Engineering Methodologies_. So to be honest I [we] have no further opinion 
about this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] asfgit closed pull request #1554: GROOVY-4990 Make File.write() create any missing directories. Add test.

2021-04-26 Thread GitBox


asfgit closed pull request #1554:
URL: https://github.com/apache/groovy/pull/1554


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] danielsun1106 closed pull request #1570: GROOVY-10056: Inferred parameter type of lambda expression for multi-…

2021-04-26 Thread GitBox


danielsun1106 closed pull request #1570:
URL: https://github.com/apache/groovy/pull/1570


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eric-milles commented on a change in pull request #1570: GROOVY-10056: Inferred parameter type of lambda expression for multi-…

2021-04-26 Thread GitBox


eric-milles commented on a change in pull request #1570:
URL: https://github.com/apache/groovy/pull/1570#discussion_r619675415



##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
##
@@ -480,8 +480,14 @@ public static boolean isAssignableTo(ClassNode type, 
ClassNode toBeAssignedTo) {
 return false;
 }
 
-static boolean isVargs(final Parameter[] parameters) {
+static boolean isVargs(final Parameter[] parameters, ClassNode[] 
argumentTypes) {
 if (parameters == null || parameters.length == 0) return false;
+
+// GROOVY-10056: Inferred parameter type of lambda expression for 
multi-dimensions array is not correct
+if (null != argumentTypes && argumentTypes.length == parameters.length 
&& argumentTypes[argumentTypes.length - 1].isArray()) {
+return false;
+}
+

Review comment:
   Instead of changing the definition of what is a variadic method, can you 
change the lastArgMatchesVarg result only?  A method is variadic regardless of 
the arguments passed.

##
File path: 
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
##
@@ -480,8 +480,14 @@ public static boolean isAssignableTo(ClassNode type, 
ClassNode toBeAssignedTo) {
 return false;
 }
 
-static boolean isVargs(final Parameter[] parameters) {
+static boolean isVargs(final Parameter[] parameters, ClassNode[] 
argumentTypes) {
 if (parameters == null || parameters.length == 0) return false;
+
+// GROOVY-10056: Inferred parameter type of lambda expression for 
multi-dimensions array is not correct
+if (null != argumentTypes && argumentTypes.length == parameters.length 
&& argumentTypes[argumentTypes.length - 1].isArray()) {
+return false;
+}
+

Review comment:
   I could take a look at this case when I get through GROOVY-10053 and 
GROOVY-10054.  I'm trying to look over all the generics fallout from 4.0a3 as a 
whole.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org