[GitHub] [groovy] danielsun1106 commented on a change in pull request #1645: GROOVY-10298: Refine records to not use system properties

2021-10-21 Thread GitBox


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



##
File path: src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
##
@@ -1603,21 +1604,18 @@ public ClassNode visitClassDeclaration(final 
ClassDeclarationContext ctx) {
 this.initUsingGenerics(classNode);
 this.hackMixins(classNode);
 
-} else if (isEnum) {
+} else if (isEnum || isRecord) {
 classNode.setInterfaces(this.visitTypeList(ctx.is));
 this.initUsingGenerics(classNode);
+if (isRecord) {
+transformRecordHeaderToProperties(ctx, classNode);
+}
 
 } else if (isAnnotation) {
 classNode.setModifiers(classNode.getModifiers() | 
Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_ANNOTATION);
 classNode.addInterface(ClassHelper.Annotation_TYPE);
 this.hackMixins(classNode);
 
-} else if (isRecord) {
-classNode.setModifiers(classNode.getModifiers() | 
Opcodes.ACC_RECORD | Opcodes.ACC_FINAL);
-
classNode.setRecordComponentNodes(this.transformRecordHeaderToProperties(ctx, 
classNode));

Review comment:
   OK. I found it just now...




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




[GitHub] [groovy] paulk-asert commented on a change in pull request #1645: GROOVY-10298: Refine records to not use system properties

2021-10-21 Thread GitBox


paulk-asert commented on a change in pull request #1645:
URL: https://github.com/apache/groovy/pull/1645#discussion_r734125253



##
File path: src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
##
@@ -1603,21 +1604,18 @@ public ClassNode visitClassDeclaration(final 
ClassDeclarationContext ctx) {
 this.initUsingGenerics(classNode);
 this.hackMixins(classNode);
 
-} else if (isEnum) {
+} else if (isEnum || isRecord) {
 classNode.setInterfaces(this.visitTypeList(ctx.is));
 this.initUsingGenerics(classNode);
+if (isRecord) {
+transformRecordHeaderToProperties(ctx, classNode);
+}
 
 } else if (isAnnotation) {
 classNode.setModifiers(classNode.getModifiers() | 
Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_ANNOTATION);
 classNode.addInterface(ClassHelper.Annotation_TYPE);
 this.hackMixins(classNode);
 
-} else if (isRecord) {
-classNode.setModifiers(classNode.getModifiers() | 
Opcodes.ACC_RECORD | Opcodes.ACC_FINAL);
-
classNode.setRecordComponentNodes(this.transformRecordHeaderToProperties(ctx, 
classNode));

Review comment:
   It is called in `RecordTypeASTTransformation#doProcessRecordType`.




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




[GitHub] [groovy] danielsun1106 commented on a change in pull request #1645: GROOVY-10298: Refine records to not use system properties

2021-10-21 Thread GitBox


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



##
File path: src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
##
@@ -1603,21 +1604,18 @@ public ClassNode visitClassDeclaration(final 
ClassDeclarationContext ctx) {
 this.initUsingGenerics(classNode);
 this.hackMixins(classNode);
 
-} else if (isEnum) {
+} else if (isEnum || isRecord) {
 classNode.setInterfaces(this.visitTypeList(ctx.is));
 this.initUsingGenerics(classNode);
+if (isRecord) {
+transformRecordHeaderToProperties(ctx, classNode);
+}
 
 } else if (isAnnotation) {
 classNode.setModifiers(classNode.getModifiers() | 
Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_ANNOTATION);
 classNode.addInterface(ClassHelper.Annotation_TYPE);
 this.hackMixins(classNode);
 
-} else if (isRecord) {
-classNode.setModifiers(classNode.getModifiers() | 
Opcodes.ACC_RECORD | Opcodes.ACC_FINAL);
-
classNode.setRecordComponentNodes(this.transformRecordHeaderToProperties(ctx, 
classNode));

Review comment:
   `setRecordComponentNodes` is not called in the PR, so no record 
components are generated in bytecode.
   




-- 
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-6954) map.foo = "bar" not optimized by the static compiler

2021-10-21 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-6954:
-

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

> map.foo = "bar" not optimized by the static compiler
> 
>
> Key: GROOVY-6954
> URL: https://issues.apache.org/jira/browse/GROOVY-6954
> Project: Groovy
>  Issue Type: Improvement
>  Components: Static compilation
>Affects Versions: 2.3.4
>Reporter: Cédric Champeau
>Assignee: Eric Milles
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> The following code, if statically compiled:
> {code}
> map.foo = 'bar'
> {code}
> produces a call to {{setProperty}} instead of going directly through 
> {{map.put}}. It's worth noting that if not on LHS of an assignment, the 
> operation is optimized to use {{get}}.



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


[GitHub] [groovy] eric-milles opened a new pull request #1646: GROOVY-6954: SC: optimize `map.foo = 'bar'` using `java.util.Map#put(K,V)`

2021-10-21 Thread GitBox


eric-milles opened a new pull request #1646:
URL: https://github.com/apache/groovy/pull/1646


   This does not cover `map['foo'] = 'bar'` which routes through "getAt" (by 
design).
   
   This also covers:
   ```groovy
   @groovy.transform.CompileStatic
   class C extends HashMap {
 void m() {
   foo = 'bar'
 }
   }
   ```
   
   https://issues.apache.org/jira/browse/GROOVY-6954


-- 
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] [Assigned] (GROOVY-6954) map.foo = "bar" not optimized by the static compiler

2021-10-21 Thread Eric Milles (Jira)


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

Eric Milles reassigned GROOVY-6954:
---

Assignee: Eric Milles

> map.foo = "bar" not optimized by the static compiler
> 
>
> Key: GROOVY-6954
> URL: https://issues.apache.org/jira/browse/GROOVY-6954
> Project: Groovy
>  Issue Type: Improvement
>  Components: Static compilation
>Affects Versions: 2.3.4
>Reporter: Cédric Champeau
>Assignee: Eric Milles
>Priority: Major
>
> The following code, if statically compiled:
> {code}
> map.foo = 'bar'
> {code}
> produces a call to {{setProperty}} instead of going directly through 
> {{map.put}}. It's worth noting that if not on LHS of an assignment, the 
> operation is optimized to use {{get}}.



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


[jira] [Updated] (GROOVY-5502) If/else branch does not always infer the variable type

2021-10-21 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-5502:

Affects Version/s: (was: 2.4.3)
   (was: 2.3.0)

> If/else branch does not always infer the variable type
> --
>
> Key: GROOVY-5502
> URL: https://issues.apache.org/jira/browse/GROOVY-5502
> Project: Groovy
>  Issue Type: Improvement
>  Components: Static Type Checker
>Reporter: Ariel Morelli Andres
>Priority: Minor
>
> Suppose we have the following code:
> {code}
> class A {
>   void mA() {  
>   }
> }
> class B extends A {
> }
> class C extends A {
> }
> @groovy.transform.CompileStatic
> class Test {
>void m() {
>   def var = new Object()   //If instead I put just "def var" it works as 
> spected
>   if (true) {
> var = new B()
>   }
>   else {
> var = new C()
>   }
>   var.mA()  //fails here
>}
> }
> {code}
> In this case, after the if/else structure we can infer that var is instanceOf 
> A.
> But, the initialization seems to confuse the type inference.
> [Static type checking] - Cannot find matching method java.lang.Object#mA()
>  at line: 23, column: 7
> If instead of {code}def var = new Object(){code} we put just {code}def 
> var{code}, then the inference works fine.



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


[jira] [Updated] (GROOVY-5502) If/else branch does not always infer the variable type

2021-10-21 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-5502:

Description: 
Suppose we have the following code:

{code}
class A {
  void m() {  
  }
}
class B extends A {
}
class C extends A {
}

@groovy.transform.TypeChecked
class Test {

   void m() {
  def var = new Object()   //If instead I put just "def var" it works as 
spected
  if (true) {
var = new B()
  }
  else {
var = new C()
  }
  var.m()  //fails here
   }
}
{code}

In this case, after the if/else structure we can infer that var is instanceOf A.
But, the initialization seems to confuse the type inference.

[Static type checking] - Cannot find matching method java.lang.Object#mA()
 at line: 23, column: 7

If instead of {code}def var = new Object(){code} we put just {code}def 
var{code}, then the inference works fine.

  was:
Suppose we have the following code:

{code}
class A {
  void mA() {  
  }
}

class B extends A {
}

class C extends A {
}

@groovy.transform.CompileStatic
class Test {

   void m() {
  def var = new Object()   //If instead I put just "def var" it works as 
spected
  if (true) {
var = new B()
  }
  else {
var = new C()
  }
  var.mA()  //fails here
   }
}
{code}

In this case, after the if/else structure we can infer that var is instanceOf A.
But, the initialization seems to confuse the type inference.

[Static type checking] - Cannot find matching method java.lang.Object#mA()
 at line: 23, column: 7

If instead of {code}def var = new Object(){code} we put just {code}def 
var{code}, then the inference works fine.


> If/else branch does not always infer the variable type
> --
>
> Key: GROOVY-5502
> URL: https://issues.apache.org/jira/browse/GROOVY-5502
> Project: Groovy
>  Issue Type: Improvement
>  Components: Static Type Checker
>Reporter: Ariel Morelli Andres
>Priority: Minor
>
> Suppose we have the following code:
> {code}
> class A {
>   void m() {  
>   }
> }
> class B extends A {
> }
> class C extends A {
> }
> @groovy.transform.TypeChecked
> class Test {
>void m() {
>   def var = new Object()   //If instead I put just "def var" it works as 
> spected
>   if (true) {
> var = new B()
>   }
>   else {
> var = new C()
>   }
>   var.m()  //fails here
>}
> }
> {code}
> In this case, after the if/else structure we can infer that var is instanceOf 
> A.
> But, the initialization seems to confuse the type inference.
> [Static type checking] - Cannot find matching method java.lang.Object#mA()
>  at line: 23, column: 7
> If instead of {code}def var = new Object(){code} we put just {code}def 
> var{code}, then the inference works fine.



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


[jira] [Resolved] (GROOVY-7690) TypeChecked Groovy does not throw illegal assignment error at compile time when using raw generic type

2021-10-21 Thread Eric Milles (Jira)


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

Eric Milles resolved GROOVY-7690.
-
Fix Version/s: 4.0.0-beta-2
   Resolution: Fixed

> TypeChecked Groovy does not throw illegal assignment error at compile time 
> when using raw generic type
> --
>
> Key: GROOVY-7690
> URL: https://issues.apache.org/jira/browse/GROOVY-7690
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.5
>Reporter: Emanuel Seidinger
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-2
>
>
> I want to provoke a compiler error. I am omitting the type parameter of a 
> generic List and use it as a raw type. When getting an object from the raw 
> list it should be of type Object. When casting this Object implicitly to an 
> Integer the compiler should throw an illegal assignment error but it doesn't. 
> The following code example should illustrate the problem. Case 2 and 3 should 
> throw the same error but only case 3 is producing an error.
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class Test {
> static method() {
> ArrayList integerArrayList = new ArrayList<>();
> ArrayList rawArrayList = new ArrayList();
> ArrayList objectArrayList = new ArrayList<>();
> integerArrayList << 1;
> rawArrayList << new Object();
> objectArrayList << new Object();
> Integer x = integerArrayList.get(0);// Case 1: works as expected
> Integer y = rawArrayList.get(0);// Case 2: doesn't throw a 
> compile error but should
> Integer z = objectArrayList.get(0); // Case 3: throws a compile 
> error as expected
> }
> }
> {code}



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


[jira] [Assigned] (GROOVY-7690) TypeChecked Groovy does not throw illegal assignment error at compile time when using raw generic type

2021-10-21 Thread Eric Milles (Jira)


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

Eric Milles reassigned GROOVY-7690:
---

Assignee: Eric Milles

> TypeChecked Groovy does not throw illegal assignment error at compile time 
> when using raw generic type
> --
>
> Key: GROOVY-7690
> URL: https://issues.apache.org/jira/browse/GROOVY-7690
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.5
>Reporter: Emanuel Seidinger
>Assignee: Eric Milles
>Priority: Major
>
> I want to provoke a compiler error. I am omitting the type parameter of a 
> generic List and use it as a raw type. When getting an object from the raw 
> list it should be of type Object. When casting this Object implicitly to an 
> Integer the compiler should throw an illegal assignment error but it doesn't. 
> The following code example should illustrate the problem. Case 2 and 3 should 
> throw the same error but only case 3 is producing an error.
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class Test {
> static method() {
> ArrayList integerArrayList = new ArrayList<>();
> ArrayList rawArrayList = new ArrayList();
> ArrayList objectArrayList = new ArrayList<>();
> integerArrayList << 1;
> rawArrayList << new Object();
> objectArrayList << new Object();
> Integer x = integerArrayList.get(0);// Case 1: works as expected
> Integer y = rawArrayList.get(0);// Case 2: doesn't throw a 
> compile error but should
> Integer z = objectArrayList.get(0); // Case 3: throws a compile 
> error as expected
> }
> }
> {code}



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


[jira] [Updated] (GROOVY-10312) MissingMethodException in method with default parameter in trait - regression in 3.0.9

2021-10-21 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-10312:
-
Fix Version/s: 3.0.10

> MissingMethodException in method with default parameter in trait - regression 
> in 3.0.9
> --
>
> Key: GROOVY-10312
> URL: https://issues.apache.org/jira/browse/GROOVY-10312
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 4.0.0-beta-1, 3.0.9
>Reporter: Marcin Zajaczkowski
>Assignee: Eric Milles
>Priority: Minor
>  Labels: trait, traits
> Fix For: 4.0.0-beta-2, 3.0.10
>
>
> After switch from 3.0.8 to 3.0.9 Groovy throws at runtime 
> MissingMethodException for static method in a trait called from another 
> trait, but only if a given method has a default parameter.
> A stripped down code to reproduce problem:
> {code:java}
> class StaticStaticInTraitProblem implements TLevel1 {
> static void main(String[] args) {
> staticMethodWithDefaultParameter()
> }
> }
> trait TLevel1 extends TLevel2 {
> static void staticMethodWithDefaultParameter(String params = "") { 
> //default param is required to make it fail at runtime
> static2() //fails with MissingMethodException: No signature of 
> method: static foobar.TLevel1.static2() is applicable ...
> }
> }
> trait TLevel2 {
> static void static2() {}
> }{code}
> A stacktrace:
> {code:java}
> Exception in thread "main" groovy.lang.MissingMethodException: No signature 
> of method: static foobar.TLevel1.static2() is applicable for argument types: 
> () values: []
> Possible solutions: wait(), wait(long), split(groovy.lang.Closure), 
> wait(long, int), notify(), stream()
> at 
> groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1584)
> at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1570)
> at 
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:1003)
> at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:180)
> at 
> foobar.TLevel1$Trait$Helper.$static_methodMissing(StaticStaticInTraitProblem2Spec.groovy)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
> Method)
> at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
> at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:567)
> at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
> at 
> groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1582)
> at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1570)
> at 
> org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:50)
> at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130)
> at 
> foobar.TLevel1$Trait$Helper.staticMethodWithDefaultParameter(StaticStaticInTraitProblem2Spec.groovy:11)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
> Method)
> at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
> at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:567)
> at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
> at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
> at 
> org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:44)
> at 
> org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:100)
> at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:240)
> at 
> foobar.TLevel1$Trait$Helper.staticMethodWithDefaultParameter(StaticStaticInTraitProblem2Spec.groovy)
> at 
> foobar.TLevel1$Trait$Helper$staticMethodWithDefaultParameter.call(Unknown 
> Source)
> at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:12

[jira] [Updated] (GROOVY-10303) Compiler NPE within CompileStack#clear

2021-10-21 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-10303:
-
Fix Version/s: 3.0.10

> Compiler NPE within CompileStack#clear
> --
>
> Key: GROOVY-10303
> URL: https://issues.apache.org/jira/browse/GROOVY-10303
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 3.0.7, 3.0.8, 3.0.9
> Environment: OS X
>Reporter: David Estes
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-2, 3.0.10
>
>
> Unable to compile a new grails app with groovy 3.x . Running into a weird 
> compiler error with an odd stack trace on a large abstract class that is hard 
> to trace
>  
> {code:java}
> General error during instruction selection: NullPointerException while 
> processing AbstractBoxProvisionService.groovy. 
> /Users/davydotcom/projects/bertram/morpheus/morpheus-ui/grails-app/services/com/morpheus/provision/AbstractBoxProvisionService.groovy
> groovy.lang.GroovyRuntimeException: NullPointerException while processing 
> AbstractBoxProvisionService.groovy. 
> /Users/davydotcom/projects/bertram/morpheus/morpheus-ui/grails-app/services/com/morpheus/provision/AbstractBoxProvisionService.groovy
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:295)
> at 
> org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:797)
> at 
> org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:942)
> at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:610)
> at 
> org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:277)
> at 
> org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:67)
> at 
> org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:98)
> at 
> org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:77)
> at 
> org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
> at 
> org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
> at 
> org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
> at 
> org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
> at 
> org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
> at 
> org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
> at 
> org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
> at 
> org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
> at 
> org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:85)
> at 
> org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:55)
> at 
> org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
> at 
> org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
> at 
> org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at 
> org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
> at 
> org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
> at 
> org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
> at 
> org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
> at 
> org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
> at 
> org.gradle.internal.concurrent.ExecutorPolicy$C

[jira] [Commented] (GROOVY-10303) Compiler NPE within CompileStack#clear

2021-10-21 Thread David Estes (Jira)


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

David Estes commented on GROOVY-10303:
--

Can this be resolved in 3 as this breaks some grails apps and should probably 
be fixed in groovy 3 as well

> Compiler NPE within CompileStack#clear
> --
>
> Key: GROOVY-10303
> URL: https://issues.apache.org/jira/browse/GROOVY-10303
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 3.0.7, 3.0.8, 3.0.9
> Environment: OS X
>Reporter: David Estes
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-2
>
>
> Unable to compile a new grails app with groovy 3.x . Running into a weird 
> compiler error with an odd stack trace on a large abstract class that is hard 
> to trace
>  
> {code:java}
> General error during instruction selection: NullPointerException while 
> processing AbstractBoxProvisionService.groovy. 
> /Users/davydotcom/projects/bertram/morpheus/morpheus-ui/grails-app/services/com/morpheus/provision/AbstractBoxProvisionService.groovy
> groovy.lang.GroovyRuntimeException: NullPointerException while processing 
> AbstractBoxProvisionService.groovy. 
> /Users/davydotcom/projects/bertram/morpheus/morpheus-ui/grails-app/services/com/morpheus/provision/AbstractBoxProvisionService.groovy
> at 
> org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:295)
> at 
> org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:797)
> at 
> org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:942)
> at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:610)
> at 
> org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:277)
> at 
> org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:67)
> at 
> org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:98)
> at 
> org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:77)
> at 
> org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
> at 
> org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
> at 
> org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
> at 
> org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
> at 
> org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
> at 
> org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
> at 
> org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
> at 
> org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
> at 
> org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:85)
> at 
> org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:55)
> at 
> org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
> at 
> org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
> at 
> org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at 
> org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
> at 
> org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
> at 
> org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
> at 
> org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
> at 
> org.gradle.inte

[jira] [Created] (GROOVY-10324) STC is unable to infer type variable when combining parameterized types and the diamond operator

2021-10-21 Thread Thodoris Sotiropoulos (Jira)
Thodoris Sotiropoulos created GROOVY-10324:
--

 Summary: STC is unable to infer type variable when combining 
parameterized types and the diamond operator
 Key: GROOVY-10324
 URL: https://issues.apache.org/jira/browse/GROOVY-10324
 Project: Groovy
  Issue Type: Bug
Reporter: Thodoris Sotiropoulos


I have the following program

{code:java}
class A {
   T foo(C t) { return null; }
}


class C {}

class B {

  void test() {
C x = (new A()).foo(new C<>());
  }
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 12: [Static type checking] - Cannot assign value of type 
java.lang.Object to variable of type C
 @ line 12, column 19.
   C x = (new A()).foo(new C<>());
 ^

1 error
{code}

h3. Expected behaviour
Compile successfully

Note that compilation fails only if the expected return type is parameterized 
(i.e., `D`). If I replace the declared type of `x` with a regular type 
(i.e., `String`), the code compiles fine.

Tested against master.



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


[jira] [Created] (GROOVY-10323) Compiler crashes on parameterized function with duplicate type variables

2021-10-21 Thread Thodoris Sotiropoulos (Jira)
Thodoris Sotiropoulos created GROOVY-10323:
--

 Summary: Compiler crashes on parameterized function with duplicate 
type variables
 Key: GROOVY-10323
 URL: https://issues.apache.org/jira/browse/GROOVY-10323
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Reporter: Thodoris Sotiropoulos


The following program

{code:java}
class A {
   T foo(T t) { return t; }
}


class C {}

class B {

  void test() {
(new A()).foo(new C());
  }
}
{code}

crashes the compiler with the stacktrace below

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during canonicalization: Duplicate key T (attempted merging 
values T and T)

java.lang.IllegalStateException: Duplicate key T (attempted merging values T 
and T)
at 
java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:133)
at 
java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
at 
java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at 
java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at 
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at 
java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at 
java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at 
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at 
java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.extractGenericsConnectionsFromArguments(StaticTypeCheckingVisitor.java:5387)
at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferReturnTypeGenerics(StaticTypeCheckingVisitor.java:5313)
at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:3538)
at 
org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:414)
at 
org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:77)
at 
org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:204)
at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2190)
at 
org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
at 
org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:168)
at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBlockStatement(StaticTypeCheckingVisitor.java:3971)
at 
org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:142)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:2601)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2590)
at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2564)
at 
org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:239)
at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1133)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1126)
at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
at 
org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:439)
at 
org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:197)
at 
org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:68)
at 
org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.call(ASTTransformationCustomizer.groovy:298)
at 
org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(Compilati

[jira] [Created] (GROOVY-10322) Type variable of function does not shadow the corresponding type variable of class

2021-10-21 Thread Thodoris Sotiropoulos (Jira)
Thodoris Sotiropoulos created GROOVY-10322:
--

 Summary: Type variable of function does not shadow the 
corresponding type variable of class
 Key: GROOVY-10322
 URL: https://issues.apache.org/jira/browse/GROOVY-10322
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Reporter: Thodoris Sotiropoulos


I have the following program

{code:java}
class A {
   T foo(T t) { return t; }
}


class B {

  void bar(int x) {}

  void test() {
int x = (new A()).foo(1);
  }
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 11: [Static type checking] - Cannot find matching method 
A#foo(int). Please check if the declared type is correct and if the method 
exists.
 @ line 11, column 13.
   int x = (new A()).foo(1);
   ^

1 error

{code}

h3. Expected behaviour

Compile successfully

Tested against master



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