[jira] [Comment Edited] (GROOVY-10714) STC: Callable, Runnable, Serializable overload preference for functional argument (closure, lambda, etc.)

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-10714 at 1/16/24 3:04 AM:
---

There are a couple of things at play here. When looking at a method call, the 
type checker first visits the arguments to determine the types to use for 
method selection. For the method reference "table::putItem" this means checking 
for the methods "putItem" from your table type. At this point, 
{{Closure}} is used as the type. Under STC not SC, a method 
reference produces a {{{}MethodClosure{}}}.

Next, the method "andThenTry" is looked up using the argument types. In this 
case, "andThenTry(Consumer)" and "andThenTry(Runnable)". To select from 
multiple options, a distance calculation is made. Since {{Closure}} actually 
implements {{{}Runnable{}}}, it is deemed much closer than {{{}Consumer{}}}. 
I'm not sure why you are seeing ambiguous method error when I am getting method 
selected unambiguously but then reference fails type-checking.

It is not until after selecting the target method that parameter types can be 
used to clarify argument types.


was (Author: emilles):
There are a couple of things at play here. When looking at a method call, the 
type checker first visits the arguments to determine the types to use for 
method selection. For the method reference "table::putItem" this means checking 
for the methods "putItem" from your table type. At this point, 
{{Closure}} is used as the type. Under STC not SC, a method 
reference produces a {{{}MethodClosure{}}}.

Next, the method "andThenTry" is looked up using the argument types. In this 
case, "andThenTry(Consumer)" and "andThenTry(Runnable)". To select from 
multiple options, a distance calculation is made. Since {{Closure}} actually 
implements {{{}Runnable{}}}, it is deemed much closer than {{{}Consumer{}}}. 
I'm not sure why you are seeing smbiguous method error when I am getting method 
selected unambiguously but then reference fails type-checking.

It is not until after selecting the target method that parameter types can be 
used to clarify argument types.

> STC: Callable, Runnable, Serializable overload preference for functional 
> argument (closure, lambda, etc.)
> -
>
> Key: GROOVY-10714
> URL: https://issues.apache.org/jira/browse/GROOVY-10714
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation
>Affects Versions: 4.0.4
>Reporter: Christopher Smith
>Assignee: Eric Milles
>Priority: Major
>
> This appears to be similar to GROOVY-9881, but it's specifically in the 
> method-overload procedure. Given a functional value type with two method 
> overloads:
> {code}
> interface Try {
>   Try andThenTry(Consumer)
>   Try andThenTry(Runnable)
> }
> {code}
> When this code is invoked from static code, the STC errors out on an 
> ambiguous method reference even if the method type isn't:
> {code}
> // AWS SDK 2 DynamoDbTable
> class DynamoDbTable {
>   void putItem(PutItemRequest)
>   void putItem(Consumer)
>   void putItem(T)
> }
> @CompileStatic
> class MyServiceClass {
>   void doThing() {
> Try.success(putItemRequest())
>   .andThenTry(table::putItem) // T for Try is PutItemRequest
>   }
> }
> {code}
> produces
> {code}
> [Static type checking] - Reference to method is ambiguous. Cannot choose 
> between [Try Try#andThenTry(Consumer), Try 
> Try#andThenTry(Runnable)]
> {code}
> I think this may have something to do with the relaxed SAM matching that is 
> used to bridge ambiguous closure syntax, but when a plain method reference is 
> used, there's no ambiguity available.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Re: [PR] GROOVY-9464: Made GroovyDoc list inherited properties [groovy]

2024-01-15 Thread via GitHub


moste00 commented on PR #2027:
URL: https://github.com/apache/groovy/pull/2027#issuecomment-1892793869

   > Merged, thanks! I have just been working on another Groovydoc change, so 
it won't be too hard for me to add a test.
   
   Hello again, thanks very much! 
   
   Very sorry for not adding the tests in time, I got distracted by a lot of 
things and only saw the notification just now. Thanks a lot for adding the 
tests yourself. Cheers.


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

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

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



[jira] [Commented] (GROOVY-9464) GroovyDoc: List inherited properties

2024-01-15 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot commented on GROOVY-9464:


moste00 commented on PR #2027:
URL: https://github.com/apache/groovy/pull/2027#issuecomment-1892793869

   > Merged, thanks! I have just been working on another Groovydoc change, so 
it won't be too hard for me to add a test.
   
   Hello again, thanks very much! 
   
   Very sorry for not adding the tests in time, I got distracted by a lot of 
things and only saw the notification just now. Thanks a lot for adding the 
tests yourself. Cheers.




> GroovyDoc: List inherited properties
> 
>
> Key: GROOVY-9464
> URL: https://issues.apache.org/jira/browse/GROOVY-9464
> Project: Groovy
>  Issue Type: Improvement
>  Components: GroovyDoc
>Reporter: Johannes Meyer
>Assignee: Paul King
>Priority: Major
>  Labels: contrib
> Fix For: 4.0.18, 5.0.0-alpha-5
>
>
> Groovydoc does not list inherited properties.
>  
> I think it would make sense to display these too



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Resolved] (GROOVY-11121) unexpected error when having overloaded methods, one of which receiving an Iterable

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles resolved GROOVY-11121.
--
Fix Version/s: 5.0.0-alpha-5
   Resolution: Fixed

https://github.com/apache/groovy/commit/0afe99a84cc745a8cc887ffa4b5b56703453d071

> unexpected error when having overloaded methods, one of which receiving an 
> Iterable
> ---
>
> Key: GROOVY-11121
> URL: https://issues.apache.org/jira/browse/GROOVY-11121
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Minor
>  Labels: overloading
> Fix For: 5.0.0-alpha-5
>
>
> I have the following program
> {code}
> import java.util.function.*;
> class Foo {
>   static  Foo of(Iterable values) { return null; }
>   static  Foo of(T values) { return null; }
> }
> class Main {
>   static final void test() {
> Foo.of((int s) -> s + 1);
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Main.groovy: 10: [Static type checking] - Wrong number of parameters for 
> method target: iterator()
>  @ line 10, column 38.
>var x = Foo.of((int s) -> s + 1);
> ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> h3. Notes
> Test case adapted from the following program that uses the apache-commons-io 
> library:
> {code}
> import org.apache.commons.io.function.*;
> import java.util.function.*;
> class Main {
>   static final void test() {
> var x = IOStream.of((int s) -> s + 1);
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (GROOVY-8096) setScriptBaseClass with Java base class breaks @Field initialization from Binding due to generated call to wrong constructor

2024-01-15 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot commented on GROOVY-8096:


eric-milles closed pull request #502: GROOVY-8096 setScriptBaseClass with Java 
class breaks @Field Binding init due to call to super() instead of 
super(Binding)
URL: https://github.com/apache/groovy/pull/502




> setScriptBaseClass with Java base class breaks @Field initialization from 
> Binding due to generated call to wrong constructor
> 
>
> Key: GROOVY-8096
> URL: https://issues.apache.org/jira/browse/GROOVY-8096
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler, GroovyScriptEngine
>Affects Versions: 2.4.8
>Reporter: Christoffer Hammarström
>Assignee: Eric Milles
>Priority: Major
>  Labels: test
> Fix For: 5.0.0-alpha-2
>
>
> I created a pull request on GitHub with a failing test showing the problem: 
> [https://github.com/apache/groovy/pull/502]
> This test fails because {{ModuleNode.createStatementsClass()}} calls 
> {{.getSuperClass().getDeclaredConstructor(SCRIPT_CONTEXT_CTOR)}} and gets 
> {{null}} back, though the constructor does exist!
> {{ModuleNode.setScriptBaseClassFromConfig(ClassNode)}}
>  calls {{.setSuperClass(ClassHelper.make(baseClassName))}} on the 
> {{scriptDummy ClassNode}}.
> The {{ClassNode}} created for this script's base class has {{.lazyInitDone = 
> true}} and {{.constructors = null}}
> {{ModuleNode.createStatementsClass()}} calls 
> {{.getSuperClass().getDeclaredConstructor(SCRIPT_CONTEXT_CTOR)}}
> Then {{ClassNode.constructors}} is set to an empty ArrayList in 
> {{ClassNode.getDeclaredConstructors()}}, insteaf of looking them up from the 
> Java class.
> The script constructor is then generated in 
> {{ModuleNode.createStatementsClass()}} as:
> *BROKEN BEHAVIOUR*
> {code:java}
>  Constructor(Binding context) {
>  super(); // Fields are initialized after the call to 
> super()
>   // Fields are initialized here with new 
> Binding() instead of context
>  setBinding(context); // This is too late, fields are initialized 
> after super(), before this call to setBinding
>  }
> {code}
> instead of
> *EXPECTED BEHAVIOUR*
> {code:java}
>  Constructor(Binding context) {
>  super(context); // Fields are initialized after the call to 
> super(context)
>  }
> {code}
> We're calling the default constructor in the base class with {{super()}}, 
> instead of passing along the {{Binding context}} with {{super(context)}}
> This breaks initialization of Fields that depend on the {{Binding context}}, 
> because Fields are initialized between the call to {{super()}} and the 
> {{setBinding(context)}}: [http://stackoverflow.com/a/14806340/233014]
> This leads to {{MissingPropertyException}} because we're trying to look up 
> variables from the {{new Binding()}} created in the default constructor, 
> instead of the binding we passed in.
> For convenience, here is the failing test:
> {code:java|title=GroovyShellTest2.groovy}
> void testBindingsInFieldInitializersWithConfigJavaBaseScript() {
> def config = new org.codehaus.groovy.control.CompilerConfiguration()
> config.scriptBaseClass = BindingScript.class.name
> def shell = new GroovyShell(config);
> def scriptText = '''
> @groovy.transform.Field def script_args = getProperty('args')// 
> Will get MissingPropertyException here because this @Field is initialized 
> after the call to super(), before the call to setBinding in the script 
> constructor
> assert script_args[0] == 'Hello Groovy'
> script_args[0]
> '''
> def arg0 = 'Hello Groovy'
> def result = shell.run scriptText, 
> 'TestBindingsInFieldInitializersWithConfigJavaBaseScript.groovy', [arg0]
> assert result == arg0
> }
> {code}
> and the Java script base class:
> {code:java|title=BindingScript.java}
> package groovy.lang;
> /**
>  * A Script which requires a Binding passed in the constructor and disallows 
> calling the default constructor.
>  */
> public abstract class BindingScript extends Script {
> // Making the default constructor private instead gives IllegalAccessError
> // Removing the default constructor instead gives NoSuchMethodError
> // Removing both constructors just calls to the default constructor in 
> groovy.lang.Script giving MissingPropertyException on field initialization
> protected BindingScript() {
> // This constructor erroneously gets called instead of the other one
> }
> 
> protected BindingScript(Binding binding) {
> super(binding);
> // This 

Re: [PR] GROOVY-8096 setScriptBaseClass with Java class breaks @Field Binding init due to call to super() instead of super(Binding) [groovy]

2024-01-15 Thread via GitHub


eric-milles closed pull request #502: GROOVY-8096 setScriptBaseClass with Java 
class breaks @Field Binding init due to call to super() instead of 
super(Binding)
URL: https://github.com/apache/groovy/pull/502


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

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

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



[jira] [Updated] (GROOVY-11254) Compiler crash: ClassNode#getTypeClass for TemporalAccessor called before the type class is set

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-11254:
-
Language: groovy

> Compiler crash:  ClassNode#getTypeClass for TemporalAccessor called before 
> the type class is set
> 
>
> Key: GROOVY-11254
> URL: https://issues.apache.org/jira/browse/GROOVY-11254
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.18, 5.0.0-alpha-5, 3.0.21
>
>
> I have the following well-typed program:
> {code}
> interface TemporalQuery {
>   T1 queryFrom(TemporalAccessor p0);
> }
> class TemporalAccessor {}
> class Test {
>   void test() {
>   TemporalQuery rec = null;
>   TemporalQuery gravy = rec::queryFrom;
>   }
> }
> {code}
> The program crashes the compiler and produces the following stack trace
> {code}
> >>> a serious error occurred: BUG! exception in phase 'class generation' in 
> >>> source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before 
> >>> the type class is set
> >>> stacktrace:
> BUG! exception in phase 'class generation' in source unit 'Main.groovy' 
> ClassNode#getTypeClass for Foo called before the type class is set
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1357)
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1351)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.lambda$createMethodDescriptor$0(AbstractFunctionalInterfaceWriter.java:49)
> at 
> java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
> at 
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
> at 
> java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
> at 
> java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
> at 
> java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.createMethodDescriptor(AbstractFunctionalInterfaceWriter.java:49)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:176)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:935)
> at 
> org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34)
> at 
> org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:423)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:203)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:853)
> at 
> org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:92)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:610)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:837)
> at 
> org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:86)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:762)
> at 
> org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:621)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:556)
> at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:705)
> at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1278)
> at 
> 

[jira] [Updated] (GROOVY-11254) Compiler crash: ClassNode#getTypeClass for TemporalAccessor called before the type class is set

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-11254:
-
Component/s: (was: Static Type Checker)

> Compiler crash:  ClassNode#getTypeClass for TemporalAccessor called before 
> the type class is set
> 
>
> Key: GROOVY-11254
> URL: https://issues.apache.org/jira/browse/GROOVY-11254
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.18, 5.0.0-alpha-5, 3.0.21
>
>
> I have the following well-typed program:
> {code}
> interface TemporalQuery {
>   T1 queryFrom(TemporalAccessor p0);
> }
> class TemporalAccessor {}
> class Test {
>   void test() {
>   TemporalQuery rec = null;
>   TemporalQuery gravy = rec::queryFrom;
>   }
> }
> {code}
> The program crashes the compiler and produces the following stack trace
> {code}
> >>> a serious error occurred: BUG! exception in phase 'class generation' in 
> >>> source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before 
> >>> the type class is set
> >>> stacktrace:
> BUG! exception in phase 'class generation' in source unit 'Main.groovy' 
> ClassNode#getTypeClass for Foo called before the type class is set
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1357)
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1351)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.lambda$createMethodDescriptor$0(AbstractFunctionalInterfaceWriter.java:49)
> at 
> java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
> at 
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
> at 
> java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
> at 
> java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
> at 
> java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.createMethodDescriptor(AbstractFunctionalInterfaceWriter.java:49)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:176)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:935)
> at 
> org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34)
> at 
> org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:423)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:203)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:853)
> at 
> org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:92)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:610)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:837)
> at 
> org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:86)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:762)
> at 
> org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:621)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:556)
> at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:705)
> at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1278)
> at 
> 

[jira] [Updated] (GROOVY-11121) unexpected error when having overloaded methods, one of which receiving an Iterable

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-11121:
-
Language: groovy

> unexpected error when having overloaded methods, one of which receiving an 
> Iterable
> ---
>
> Key: GROOVY-11121
> URL: https://issues.apache.org/jira/browse/GROOVY-11121
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Minor
>  Labels: overloading
>
> I have the following program
> {code}
> import java.util.function.*;
> class Foo {
>   static  Foo of(Iterable values) { return null; }
>   static  Foo of(T values) { return null; }
> }
> class Main {
>   static final void test() {
> Foo.of((int s) -> s + 1);
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Main.groovy: 10: [Static type checking] - Wrong number of parameters for 
> method target: iterator()
>  @ line 10, column 38.
>var x = Foo.of((int s) -> s + 1);
> ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> h3. Notes
> Test case adapted from the following program that uses the apache-commons-io 
> library:
> {code}
> import org.apache.commons.io.function.*;
> import java.util.function.*;
> class Main {
>   static final void test() {
> var x = IOStream.of((int s) -> s + 1);
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (GROOVY-11254) Compiler crash: ClassNode#getTypeClass for TemporalAccessor called before the type class is set

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-11254:
-
Priority: Major  (was: Minor)

> Compiler crash:  ClassNode#getTypeClass for TemporalAccessor called before 
> the type class is set
> 
>
> Key: GROOVY-11254
> URL: https://issues.apache.org/jira/browse/GROOVY-11254
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.18, 5.0.0-alpha-5, 3.0.21
>
>
> I have the following well-typed program:
> {code}
> interface TemporalQuery {
>   T1 queryFrom(TemporalAccessor p0);
> }
> class TemporalAccessor {}
> class Test {
>   void test() {
>   TemporalQuery rec = null;
>   TemporalQuery gravy = rec::queryFrom;
>   }
> }
> {code}
> The program crashes the compiler and produces the following stack trace
> {code}
> >>> a serious error occurred: BUG! exception in phase 'class generation' in 
> >>> source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before 
> >>> the type class is set
> >>> stacktrace:
> BUG! exception in phase 'class generation' in source unit 'Main.groovy' 
> ClassNode#getTypeClass for Foo called before the type class is set
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1357)
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1351)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.lambda$createMethodDescriptor$0(AbstractFunctionalInterfaceWriter.java:49)
> at 
> java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
> at 
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
> at 
> java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
> at 
> java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
> at 
> java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.createMethodDescriptor(AbstractFunctionalInterfaceWriter.java:49)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:176)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:935)
> at 
> org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34)
> at 
> org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:423)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:203)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:853)
> at 
> org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:92)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:610)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:837)
> at 
> org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:86)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:762)
> at 
> org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:621)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:556)
> at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:705)
> at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1278)
> at 
> 

[jira] [Updated] (GROOVY-11254) Compiler crash: ClassNode#getTypeClass for TemporalAccessor called before the type class is set

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-11254:
-
Fix Version/s: 3.0.21

> Compiler crash:  ClassNode#getTypeClass for TemporalAccessor called before 
> the type class is set
> 
>
> Key: GROOVY-11254
> URL: https://issues.apache.org/jira/browse/GROOVY-11254
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Minor
> Fix For: 4.0.18, 5.0.0-alpha-5, 3.0.21
>
>
> I have the following well-typed program:
> {code}
> interface TemporalQuery {
>   T1 queryFrom(TemporalAccessor p0);
> }
> class TemporalAccessor {}
> class Test {
>   void test() {
>   TemporalQuery rec = null;
>   TemporalQuery gravy = rec::queryFrom;
>   }
> }
> {code}
> The program crashes the compiler and produces the following stack trace
> {code}
> >>> a serious error occurred: BUG! exception in phase 'class generation' in 
> >>> source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before 
> >>> the type class is set
> >>> stacktrace:
> BUG! exception in phase 'class generation' in source unit 'Main.groovy' 
> ClassNode#getTypeClass for Foo called before the type class is set
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1357)
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1351)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.lambda$createMethodDescriptor$0(AbstractFunctionalInterfaceWriter.java:49)
> at 
> java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
> at 
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
> at 
> java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
> at 
> java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
> at 
> java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.createMethodDescriptor(AbstractFunctionalInterfaceWriter.java:49)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:176)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:935)
> at 
> org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34)
> at 
> org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:423)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:203)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:853)
> at 
> org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:92)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:610)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:837)
> at 
> org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:86)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:762)
> at 
> org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:621)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:556)
> at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:705)
> at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1278)
> at 
> 

[jira] [Assigned] (GROOVY-11121) unexpected error when having overloaded methods, one of which receiving an Iterable

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles reassigned GROOVY-11121:


Assignee: Eric Milles

> unexpected error when having overloaded methods, one of which receiving an 
> Iterable
> ---
>
> Key: GROOVY-11121
> URL: https://issues.apache.org/jira/browse/GROOVY-11121
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Minor
>  Labels: overloading
>
> I have the following program
> {code}
> import java.util.function.*;
> class Foo {
>   static  Foo of(Iterable values) { return null; }
>   static  Foo of(T values) { return null; }
> }
> class Main {
>   static final void test() {
> Foo.of((int s) -> s + 1);
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Main.groovy: 10: [Static type checking] - Wrong number of parameters for 
> method target: iterator()
>  @ line 10, column 38.
>var x = Foo.of((int s) -> s + 1);
> ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> h3. Notes
> Test case adapted from the following program that uses the apache-commons-io 
> library:
> {code}
> import org.apache.commons.io.function.*;
> import java.util.function.*;
> class Main {
>   static final void test() {
> var x = IOStream.of((int s) -> s + 1);
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] (GROOVY-11121) unexpected error when having overloaded methods, one of which receiving an Iterable

2024-01-15 Thread Eric Milles (Jira)


[ https://issues.apache.org/jira/browse/GROOVY-11121 ]


Eric Milles deleted comment on GROOVY-11121:
--

was (Author: emilles):
Without a fix for GROOVY-10714 and GROOVY-11010 there is no disambiguation by 
parameter count.  If they are resolved, this should be resolved too.

> unexpected error when having overloaded methods, one of which receiving an 
> Iterable
> ---
>
> Key: GROOVY-11121
> URL: https://issues.apache.org/jira/browse/GROOVY-11121
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Priority: Minor
>  Labels: overloading
>
> I have the following program
> {code}
> import java.util.function.*;
> class Foo {
>   static  Foo of(Iterable values) { return null; }
>   static  Foo of(T values) { return null; }
> }
> class Main {
>   static final void test() {
> Foo.of((int s) -> s + 1);
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Main.groovy: 10: [Static type checking] - Wrong number of parameters for 
> method target: iterator()
>  @ line 10, column 38.
>var x = Foo.of((int s) -> s + 1);
> ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> h3. Notes
> Test case adapted from the following program that uses the apache-commons-io 
> library:
> {code}
> import org.apache.commons.io.function.*;
> import java.util.function.*;
> class Main {
>   static final void test() {
> var x = IOStream.of((int s) -> s + 1);
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (GROOVY-11254) Compiler crash: ClassNode#getTypeClass for TemporalAccessor called before the type class is set

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-11254:
-
Fix Version/s: 4.0.18

> Compiler crash:  ClassNode#getTypeClass for TemporalAccessor called before 
> the type class is set
> 
>
> Key: GROOVY-11254
> URL: https://issues.apache.org/jira/browse/GROOVY-11254
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Minor
> Fix For: 4.0.18, 5.0.0-alpha-5
>
>
> I have the following well-typed program:
> {code}
> interface TemporalQuery {
>   T1 queryFrom(TemporalAccessor p0);
> }
> class TemporalAccessor {}
> class Test {
>   void test() {
>   TemporalQuery rec = null;
>   TemporalQuery gravy = rec::queryFrom;
>   }
> }
> {code}
> The program crashes the compiler and produces the following stack trace
> {code}
> >>> a serious error occurred: BUG! exception in phase 'class generation' in 
> >>> source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before 
> >>> the type class is set
> >>> stacktrace:
> BUG! exception in phase 'class generation' in source unit 'Main.groovy' 
> ClassNode#getTypeClass for Foo called before the type class is set
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1357)
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1351)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.lambda$createMethodDescriptor$0(AbstractFunctionalInterfaceWriter.java:49)
> at 
> java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
> at 
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
> at 
> java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
> at 
> java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
> at 
> java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.createMethodDescriptor(AbstractFunctionalInterfaceWriter.java:49)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:176)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:935)
> at 
> org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34)
> at 
> org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:423)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:203)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:853)
> at 
> org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:92)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:610)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:837)
> at 
> org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:86)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:762)
> at 
> org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:621)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:556)
> at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:705)
> at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1278)
> at 
> 

[jira] [Comment Edited] (GROOVY-11010) Ambiguous method reference when expecting a SAM type

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-11010 at 1/15/24 1:44 PM:
---

Replacing “Main::m” with “(String s) -> Main.m(s)” should allow disambiguation 
by param count (see GROOVY-9881).

GROOVY-10714 seeks to apply the same for method pointer/reference. A change in 
the order of steps caused a regression here for Groovy 5.


was (Author: emilles):
Replacing “Main::m” with “s -> Main.m(s)” should allow disambiguation by param 
count (see GROOVY-9881).

GROOVY-10714 seeks to apply the same for method pointer/reference. A change in 
the order of steps caused a regression here for Groovy 5. 

> Ambiguous method reference when expecting a SAM type
> 
>
> Key: GROOVY-11010
> URL: https://issues.apache.org/jira/browse/GROOVY-11010
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Minor
>
> I have the following program
> {code}
> import java.util.function.*;
> class Main {
>   static final void test() {
> from(Main::m);
>   }
>   static  void from(Function f) {}
>   static  void from(Supplier f) {}
>   static int m(String x) { return 1; }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 6: [Static type checking] - Reference to method is ambiguous. 
> Cannot choose between [void Main#from(java.util.function.Supplier), void 
> Main#from(java.util.function.Function)]
>  @ line 6, column 5.
>from(Main::m);
>^
> 1 error
> {code}
> h3. Expected behavior 
> Compile successfully
> h3. Notes
> Tested against master (commit: 5bcd83e0fde722971f97d479f1a4d6da6cd4aa5f)
> Test case adapted from (Guava library)
> {code}
> import java.util.function.*;
> class Main {
>   static final void test() {
> com.google.common.cache.CacheLoader.from(Main::m);
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Resolved] (GROOVY-11254) Compiler crash: ClassNode#getTypeClass for TemporalAccessor called before the type class is set

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles resolved GROOVY-11254.
--
Fix Version/s: 5.0.0-alpha-5
   Resolution: Fixed

https://github.com/apache/groovy/commit/3acb6395a802b8eb68481b104ff5b328178c4acb

> Compiler crash:  ClassNode#getTypeClass for TemporalAccessor called before 
> the type class is set
> 
>
> Key: GROOVY-11254
> URL: https://issues.apache.org/jira/browse/GROOVY-11254
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Minor
> Fix For: 5.0.0-alpha-5
>
>
> I have the following well-typed program:
> {code}
> interface TemporalQuery {
>   T1 queryFrom(TemporalAccessor p0);
> }
> class TemporalAccessor {}
> class Test {
>   void test() {
>   TemporalQuery rec = null;
>   TemporalQuery gravy = rec::queryFrom;
>   }
> }
> {code}
> The program crashes the compiler and produces the following stack trace
> {code}
> >>> a serious error occurred: BUG! exception in phase 'class generation' in 
> >>> source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before 
> >>> the type class is set
> >>> stacktrace:
> BUG! exception in phase 'class generation' in source unit 'Main.groovy' 
> ClassNode#getTypeClass for Foo called before the type class is set
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1357)
> at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1351)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.lambda$createMethodDescriptor$0(AbstractFunctionalInterfaceWriter.java:49)
> at 
> java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
> at 
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
> at 
> java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
> at 
> java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
> at 
> java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
> at 
> java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
> at 
> org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.createMethodDescriptor(AbstractFunctionalInterfaceWriter.java:49)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:176)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:935)
> at 
> org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34)
> at 
> org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:423)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:203)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:853)
> at 
> org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:92)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:610)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:837)
> at 
> org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
> at 
> org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:86)
> at 
> org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:762)
> at 
> org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:621)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:556)
> at 
> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:705)
> at 

[jira] [Commented] (GROOVY-9239) Java compatibility: consider supporting method reference with generics

2024-01-15 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9239:
-

https://github.com/apache/groovy/commit/d8726d7e2f0f554c6e947679cc183adcb60b79e2

> Java compatibility: consider supporting method reference with generics
> --
>
> Key: GROOVY-9239
> URL: https://issues.apache.org/jira/browse/GROOVY-9239
> Project: Groovy
>  Issue Type: Improvement
>  Components: parser-antlr4
>Reporter: Eric Milles
>Priority: Minor
>
> A bit of a rare use case, but ran into it and noticed 
> {{MethodReferenceExpression}} has no support for this sort thing.  Java 
> supports generics for method references.
> For example:
> {code:groovy}
> def  T chars() { ... }
> Supplier s = this::chars
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (GROOVY-11229) Support pattern matching and destructure

2024-01-15 Thread Jochen Theodorou (Jira)


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

Jochen Theodorou commented on GROOVY-11229:
---

[~emilles][~daniel_sun] The de-structuring also give access to x and y? That is 
something still available through o or p of course, but the jep441 also targets 
further nesting.

So yes, the Java16 version is a bit useless to us, the Java21 version though I 
see differently. Well... to be frank I find this feature massively overrated. 
And there is more coming of this in the future from Java...

> Support pattern matching and destructure
> 
>
> Key: GROOVY-11229
> URL: https://issues.apache.org/jira/browse/GROOVY-11229
> Project: Groovy
>  Issue Type: New Feature
>Reporter: Daniel Sun
>Priority: Major
>
> See also:
> [https://openjdk.org/jeps/394]
> [https://openjdk.java.net/jeps/440]
> [https://openjdk.org/jeps/441]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (GROOVY-11269) GroovyClassDoc has empty 'enumConstants' when call method GroovyDocParser.getClassDocsFromSingleSource(...)

2024-01-15 Thread Dmitry (Jira)


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

Dmitry edited comment on GROOVY-11269 at 1/15/24 10:31 AM:
---

[~paulk] 

I tried to use old parser (set the {{groovy.antlr4}} system property to 
{{{}false{}}}):
 
 {{./gradlew clean -x test server:dslDocs -Dgroovy.antlr4=false}}
but it failed with our first exception:
{code:java}
Execution failed for task ':server:dslDocs'.
> startup failed:
  TaggableClasses.groovy: 21: unexpected token: 2 @ line 21, column 15.
COURSE_CLASS(2),
   ^
  
  1 error{code}
{{When we updated gradle to 8.2.1 and try to execute server:dslDocs without 
'GroovyDocParser' with getClassDocsFromSingleSource - we use or old 
implementation (parseGroovy method in 59 line): 
[https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]}}
{{I got the same Exception with 'TaggableClasses.groovy'}}

here I created the issue with the same case: 
https://issues.apache.org/jira/browse/GROOVY-10886

and here we've already discussed this: 
https://issues.apache.org/jira/browse/GROOVY-11130


was (Author: JIRAUSER289117):
[~paulk] 

I tried to use old old parser (set the {{groovy.antlr4}} system property to 
{{{}false{}}}):
 
 {{./gradlew clean -x test server:dslDocs -Dgroovy.antlr4=false}}
but it failed with our first exception:
{code:java}
Execution failed for task ':server:dslDocs'.
> startup failed:
  TaggableClasses.groovy: 21: unexpected token: 2 @ line 21, column 15.
COURSE_CLASS(2),
   ^
  
  1 error{code}
{{When we updated gradle to 8.2.1 and try to execute server:dslDocs without 
'GroovyDocParser' with getClassDocsFromSingleSource - we use or old 
implementation (parseGroovy method in 59 line): 
[https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]}}
{{I got the same Exception with 'TaggableClasses.groovy'}}

here I created the issue with the same case: 
https://issues.apache.org/jira/browse/GROOVY-10886

and here we've already discussed this: 
https://issues.apache.org/jira/browse/GROOVY-11130

> GroovyClassDoc has empty 'enumConstants' when call method 
> GroovyDocParser.getClassDocsFromSingleSource(...)
> ---
>
> Key: GROOVY-11269
> URL: https://issues.apache.org/jira/browse/GROOVY-11269
> Project: Groovy
>  Issue Type: Bug
>  Components: parser
>Affects Versions: 2.5.12, 3.0.17
>Reporter: Dmitry
>Assignee: Paul King
>Priority: Major
> Fix For: 4.0.18, 5.0.0-alpha-5
>
> Attachments: image-2024-01-05-20-21-01-570.png, 
> image-2024-01-05-20-21-42-826.png, image-2024-01-05-20-28-41-678.png, 
> image-2024-01-05-20-30-29-173.png, image-2024-01-05-20-32-52-646.png, 
> image-2024-01-05-20-32-58-921.png
>
>
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> In our project we try to update gradle from 6.8.2 to 8.2.1.
> And gradle 6.8.2 -> use groovy 2.5.12
> But gradle 8.2.1 -> use groovy 3.0.17
> How we parse java/groovy files now ->
> 59 line 
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file){code}
> [https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]
>  
> But it doesn't work for gradle 8.2.1 (groovy 3.0.17).
> After discussion this issue in these tasks:
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> I try to use GroovyDocParser from org.codehaus.groovy.tools.groovydoc.antlr4
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file)
>   throws RecognitionException, TokenStreamException {
>GroovyDocParser groovyDocParser = new GroovyDocParser(links, properties)
>def GroovyClassDocMap = 
> groovyDocParser.getClassDocsFromSingleSource(packagePath, file, src)
>return GroovyClassDocMap
> }{code}
>  
> And It seems to work. But I found this problem:
> When I parse groovy enums, GroovyClassDoc has empty 'enumConstants' and all 
> enum values are in 'fields'.
> !image-2024-01-05-20-21-42-826.png!!image-2024-01-05-20-21-01-570.png!
> But our old implementation has:
> !image-2024-01-05-20-30-29-173.png!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (GROOVY-11269) GroovyClassDoc has empty 'enumConstants' when call method GroovyDocParser.getClassDocsFromSingleSource(...)

2024-01-15 Thread Dmitry (Jira)


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

Dmitry edited comment on GROOVY-11269 at 1/15/24 10:30 AM:
---

[~paulk] 

I tried to use old old parser (set the {{groovy.antlr4}} system property to 
{{{}false{}}}):
 
 {{./gradlew clean -x test server:dslDocs -Dgroovy.antlr4=false}}
but it failed with our first exception:
{code:java}
Execution failed for task ':server:dslDocs'.
> startup failed:
  TaggableClasses.groovy: 21: unexpected token: 2 @ line 21, column 15.
COURSE_CLASS(2),
   ^
  
  1 error{code}
{{When we updated gradle to 8.2.1 and try to execute server:dslDocs without 
'GroovyDocParser' with getClassDocsFromSingleSource - we use or old 
implementation (parseGroovy method in 59 line): 
[https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]}}
{{I got the same Exception with 'TaggableClasses.groovy'}}

here I created the issue with the same case: 
https://issues.apache.org/jira/browse/GROOVY-10886

and here we've already discussed this: 
https://issues.apache.org/jira/browse/GROOVY-11130


was (Author: JIRAUSER289117):
[~paulk] 

I tried to use old old parser (set the {{groovy.antlr4}} system property to 
{{{}false{}}}):
 
 {{./gradlew clean -x test server:dslDocs -Dgroovy.antlr4=false}}
but it failed with our first exception:


{code:java}
Execution failed for task ':server:dslDocs'.
> startup failed:
  TaggableClasses.groovy: 21: unexpected token: 2 @ line 21, column 15.
COURSE_CLASS(2),
   ^
  
  1 error{code}

{{When we updated gradle to 8.2.1 and try to execute server:dslDocs without 
'GroovyDocParser' with getClassDocsFromSingleSource - we use or old 
implementation (parseGroovy method in 59 line): 
[https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]}}
{{I got the same Exception with 'TaggableClasses.groovy'}}

here I created the issue with the same case: 
https://issues.apache.org/jira/browse/GROOVY-10886
{{}}
and here we've already discussed this: 
https://issues.apache.org/jira/browse/GROOVY-11130
{{}}
{{}}
{{}}

> GroovyClassDoc has empty 'enumConstants' when call method 
> GroovyDocParser.getClassDocsFromSingleSource(...)
> ---
>
> Key: GROOVY-11269
> URL: https://issues.apache.org/jira/browse/GROOVY-11269
> Project: Groovy
>  Issue Type: Bug
>  Components: parser
>Affects Versions: 2.5.12, 3.0.17
>Reporter: Dmitry
>Assignee: Paul King
>Priority: Major
> Fix For: 4.0.18, 5.0.0-alpha-5
>
> Attachments: image-2024-01-05-20-21-01-570.png, 
> image-2024-01-05-20-21-42-826.png, image-2024-01-05-20-28-41-678.png, 
> image-2024-01-05-20-30-29-173.png, image-2024-01-05-20-32-52-646.png, 
> image-2024-01-05-20-32-58-921.png
>
>
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> In our project we try to update gradle from 6.8.2 to 8.2.1.
> And gradle 6.8.2 -> use groovy 2.5.12
> But gradle 8.2.1 -> use groovy 3.0.17
> How we parse java/groovy files now ->
> 59 line 
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file){code}
> [https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]
>  
> But it doesn't work for gradle 8.2.1 (groovy 3.0.17).
> After discussion this issue in these tasks:
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> I try to use GroovyDocParser from org.codehaus.groovy.tools.groovydoc.antlr4
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file)
>   throws RecognitionException, TokenStreamException {
>GroovyDocParser groovyDocParser = new GroovyDocParser(links, properties)
>def GroovyClassDocMap = 
> groovyDocParser.getClassDocsFromSingleSource(packagePath, file, src)
>return GroovyClassDocMap
> }{code}
>  
> And It seems to work. But I found this problem:
> When I parse groovy enums, GroovyClassDoc has empty 'enumConstants' and all 
> enum values are in 'fields'.
> !image-2024-01-05-20-21-42-826.png!!image-2024-01-05-20-21-01-570.png!
> But our old implementation has:
> !image-2024-01-05-20-30-29-173.png!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (GROOVY-11269) GroovyClassDoc has empty 'enumConstants' when call method GroovyDocParser.getClassDocsFromSingleSource(...)

2024-01-15 Thread Dmitry (Jira)


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

Dmitry commented on GROOVY-11269:
-

[~paulk] 

I tried to use old old parser (set the {{groovy.antlr4}} system property to 
{{{}false{}}}):
 
 {{./gradlew clean -x test server:dslDocs -Dgroovy.antlr4=false}}
but it failed with our first exception:
 {{}}
{code:java}
Execution failed for task ':server:dslDocs'.
> startup failed:
  TaggableClasses.groovy: 21: unexpected token: 2 @ line 21, column 15.
COURSE_CLASS(2),
   ^
  
  1 error{code}
{{}}
{{}}
{{}}
When we updated gradle to 8.2.1 and try to execute server:dslDocs without 
'GroovyDocParser' with getClassDocsFromSingleSource - we use or old 
implementation (parseGroovy method in 59 line): 
[https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]
{{}}
I got the same Exception with 'TaggableClasses.groovy'
{{}}
here I created the issue with the same case: 
https://issues.apache.org/jira/browse/GROOVY-10886
{{}}
and here we've already discussed this: 
https://issues.apache.org/jira/browse/GROOVY-11130
{{}}
{{}}
{{}}

> GroovyClassDoc has empty 'enumConstants' when call method 
> GroovyDocParser.getClassDocsFromSingleSource(...)
> ---
>
> Key: GROOVY-11269
> URL: https://issues.apache.org/jira/browse/GROOVY-11269
> Project: Groovy
>  Issue Type: Bug
>  Components: parser
>Affects Versions: 2.5.12, 3.0.17
>Reporter: Dmitry
>Assignee: Paul King
>Priority: Major
> Fix For: 4.0.18, 5.0.0-alpha-5
>
> Attachments: image-2024-01-05-20-21-01-570.png, 
> image-2024-01-05-20-21-42-826.png, image-2024-01-05-20-28-41-678.png, 
> image-2024-01-05-20-30-29-173.png, image-2024-01-05-20-32-52-646.png, 
> image-2024-01-05-20-32-58-921.png
>
>
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> In our project we try to update gradle from 6.8.2 to 8.2.1.
> And gradle 6.8.2 -> use groovy 2.5.12
> But gradle 8.2.1 -> use groovy 3.0.17
> How we parse java/groovy files now ->
> 59 line 
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file){code}
> [https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]
>  
> But it doesn't work for gradle 8.2.1 (groovy 3.0.17).
> After discussion this issue in these tasks:
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> I try to use GroovyDocParser from org.codehaus.groovy.tools.groovydoc.antlr4
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file)
>   throws RecognitionException, TokenStreamException {
>GroovyDocParser groovyDocParser = new GroovyDocParser(links, properties)
>def GroovyClassDocMap = 
> groovyDocParser.getClassDocsFromSingleSource(packagePath, file, src)
>return GroovyClassDocMap
> }{code}
>  
> And It seems to work. But I found this problem:
> When I parse groovy enums, GroovyClassDoc has empty 'enumConstants' and all 
> enum values are in 'fields'.
> !image-2024-01-05-20-21-42-826.png!!image-2024-01-05-20-21-01-570.png!
> But our old implementation has:
> !image-2024-01-05-20-30-29-173.png!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (GROOVY-11269) GroovyClassDoc has empty 'enumConstants' when call method GroovyDocParser.getClassDocsFromSingleSource(...)

2024-01-15 Thread Dmitry (Jira)


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

Dmitry edited comment on GROOVY-11269 at 1/15/24 10:30 AM:
---

[~paulk] 

I tried to use old old parser (set the {{groovy.antlr4}} system property to 
{{{}false{}}}):
 
 {{./gradlew clean -x test server:dslDocs -Dgroovy.antlr4=false}}
but it failed with our first exception:


{code:java}
Execution failed for task ':server:dslDocs'.
> startup failed:
  TaggableClasses.groovy: 21: unexpected token: 2 @ line 21, column 15.
COURSE_CLASS(2),
   ^
  
  1 error{code}

{{When we updated gradle to 8.2.1 and try to execute server:dslDocs without 
'GroovyDocParser' with getClassDocsFromSingleSource - we use or old 
implementation (parseGroovy method in 59 line): 
[https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]}}
{{I got the same Exception with 'TaggableClasses.groovy'}}

here I created the issue with the same case: 
https://issues.apache.org/jira/browse/GROOVY-10886
{{}}
and here we've already discussed this: 
https://issues.apache.org/jira/browse/GROOVY-11130
{{}}
{{}}
{{}}


was (Author: JIRAUSER289117):
[~paulk] 

I tried to use old old parser (set the {{groovy.antlr4}} system property to 
{{{}false{}}}):
 
 {{./gradlew clean -x test server:dslDocs -Dgroovy.antlr4=false}}
but it failed with our first exception:
 {{}}
{code:java}
Execution failed for task ':server:dslDocs'.
> startup failed:
  TaggableClasses.groovy: 21: unexpected token: 2 @ line 21, column 15.
COURSE_CLASS(2),
   ^
  
  1 error{code}
{{}}
{{}}
{{}}
When we updated gradle to 8.2.1 and try to execute server:dslDocs without 
'GroovyDocParser' with getClassDocsFromSingleSource - we use or old 
implementation (parseGroovy method in 59 line): 
[https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]
{{}}
I got the same Exception with 'TaggableClasses.groovy'
{{}}
here I created the issue with the same case: 
https://issues.apache.org/jira/browse/GROOVY-10886
{{}}
and here we've already discussed this: 
https://issues.apache.org/jira/browse/GROOVY-11130
{{}}
{{}}
{{}}

> GroovyClassDoc has empty 'enumConstants' when call method 
> GroovyDocParser.getClassDocsFromSingleSource(...)
> ---
>
> Key: GROOVY-11269
> URL: https://issues.apache.org/jira/browse/GROOVY-11269
> Project: Groovy
>  Issue Type: Bug
>  Components: parser
>Affects Versions: 2.5.12, 3.0.17
>Reporter: Dmitry
>Assignee: Paul King
>Priority: Major
> Fix For: 4.0.18, 5.0.0-alpha-5
>
> Attachments: image-2024-01-05-20-21-01-570.png, 
> image-2024-01-05-20-21-42-826.png, image-2024-01-05-20-28-41-678.png, 
> image-2024-01-05-20-30-29-173.png, image-2024-01-05-20-32-52-646.png, 
> image-2024-01-05-20-32-58-921.png
>
>
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> In our project we try to update gradle from 6.8.2 to 8.2.1.
> And gradle 6.8.2 -> use groovy 2.5.12
> But gradle 8.2.1 -> use groovy 3.0.17
> How we parse java/groovy files now ->
> 59 line 
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file){code}
> [https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]
>  
> But it doesn't work for gradle 8.2.1 (groovy 3.0.17).
> After discussion this issue in these tasks:
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> I try to use GroovyDocParser from org.codehaus.groovy.tools.groovydoc.antlr4
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file)
>   throws RecognitionException, TokenStreamException {
>GroovyDocParser groovyDocParser = new GroovyDocParser(links, properties)
>def GroovyClassDocMap = 
> groovyDocParser.getClassDocsFromSingleSource(packagePath, file, src)
>return GroovyClassDocMap
> }{code}
>  
> And It seems to work. But I found this problem:
> When I parse groovy enums, GroovyClassDoc has empty 'enumConstants' and all 
> enum values are in 'fields'.
> !image-2024-01-05-20-21-42-826.png!!image-2024-01-05-20-21-01-570.png!
> But our old implementation has:
> !image-2024-01-05-20-30-29-173.png!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (GROOVY-11269) GroovyClassDoc has empty 'enumConstants' when call method GroovyDocParser.getClassDocsFromSingleSource(...)

2024-01-15 Thread Dmitry (Jira)


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

Dmitry commented on GROOVY-11269:
-

[~paulk] hi,

1) we can't use latest groovy snapshot, because the gradle forces us to use the 
default groovy version from gradle. In our case, gradle 8.2.1 uses groovy 
3.0.17.

2) How and where should I set set the {{groovy.antlr4}} system property to 
{{false? To create GroovyClassDoc I use this one:}}
{{}}
{code:java}
GroovyDocParser groovyDocParser = new GroovyDocParser(links, properties)
def GroovyClassDocMap = 
groovyDocParser.getClassDocsFromSingleSource(packagePath, file, src) {code}
{{ here you can find full file: 
https://github.com/ishgroup/oncourse/pull/1192/files#diff-33ed7c0380b15143b4e46d30aa40b05e3d35998a58fcbed6da2ce3c6c349861a}}

> GroovyClassDoc has empty 'enumConstants' when call method 
> GroovyDocParser.getClassDocsFromSingleSource(...)
> ---
>
> Key: GROOVY-11269
> URL: https://issues.apache.org/jira/browse/GROOVY-11269
> Project: Groovy
>  Issue Type: Bug
>  Components: parser
>Affects Versions: 2.5.12, 3.0.17
>Reporter: Dmitry
>Assignee: Paul King
>Priority: Major
> Fix For: 4.0.18, 5.0.0-alpha-5
>
> Attachments: image-2024-01-05-20-21-01-570.png, 
> image-2024-01-05-20-21-42-826.png, image-2024-01-05-20-28-41-678.png, 
> image-2024-01-05-20-30-29-173.png, image-2024-01-05-20-32-52-646.png, 
> image-2024-01-05-20-32-58-921.png
>
>
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> In our project we try to update gradle from 6.8.2 to 8.2.1.
> And gradle 6.8.2 -> use groovy 2.5.12
> But gradle 8.2.1 -> use groovy 3.0.17
> How we parse java/groovy files now ->
> 59 line 
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file){code}
> [https://github.com/ishgroup/oncourse/blob/main/buildSrc/apidoc/src/main/groovy/au/com/ish/docs/DslGroovyRootDocBuilder.groovy]
>  
> But it doesn't work for gradle 8.2.1 (groovy 3.0.17).
> After discussion this issue in these tasks:
> https://issues.apache.org/jira/browse/GROOVY-10886
> https://issues.apache.org/jira/browse/GROOVY-11130
> I try to use GroovyDocParser from org.codehaus.groovy.tools.groovydoc.antlr4
> {code:java}
> private Map parseGroovy(String src, String 
> packagePath, String file)
>   throws RecognitionException, TokenStreamException {
>GroovyDocParser groovyDocParser = new GroovyDocParser(links, properties)
>def GroovyClassDocMap = 
> groovyDocParser.getClassDocsFromSingleSource(packagePath, file, src)
>return GroovyClassDocMap
> }{code}
>  
> And It seems to work. But I found this problem:
> When I parse groovy enums, GroovyClassDoc has empty 'enumConstants' and all 
> enum values are in 'fields'.
> !image-2024-01-05-20-21-42-826.png!!image-2024-01-05-20-21-01-570.png!
> But our old implementation has:
> !image-2024-01-05-20-30-29-173.png!
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)