[jira] [Comment Edited] (GROOVY-9347) STC: lambda expression on wildcard generics fail to resolve param type(s)

2019-12-19 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-9347 at 12/19/19 7:36 PM:
---

{{StaticTypeCheckingVisitor#inferSAMType}} cannot collect generics correctly 
from {{forEach(Consumer c)}} and so the param type is Object.

PR #1126 fixes the assignment case, which is handled by separate methods:
{code:groovy}
@groovy.transform.CompileStatic
void test() {
int sum = 0
java.util.function.Consumer add = i -> sum += i
}
{code}


was (Author: emilles):
{{StaticTypeCheckingVisitor#inferSAMType}} cannot collect generics correctly 
from {{forEach(Consumer c)}} and so the param type is Object.

PR #1126 fixes the assignment case, which is handled by separate methods:
{code:groovy}
int sum = 0
java.util.function.Consumer add = i -> sum += i
{code}

> STC: lambda expression on wildcard generics fail to resolve param type(s)
> -
>
> Key: GROOVY-9347
> URL: https://issues.apache.org/jira/browse/GROOVY-9347
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-rc-2
>Reporter: Eric Milles
>Priority: Major
>
> Follow up to GROOVY-9342.  Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach(e -> acc += e) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> TestScript60.groovy: 5: [Static type checking] - Cannot find matching 
> method int#plus(java.lang.Object). Please check if the declared type is 
> correct and if the method exists.
>  @ line 5, column 49.
>atic { [1, 2, 3].forEach(e -> acc += e)
>  ^
> 1 error
> at 
> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
> at 
> org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1091)
> at 
> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
> at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
> at 
> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:367)
> at 
> groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:310)
> ...
> {code}



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


[jira] [Resolved] (GROOVY-9342) SC: Lambda in static initializer that uses static field on LHS of += produces errors

2019-12-19 Thread Eric Milles (Jira)


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

Eric Milles resolved GROOVY-9342.
-
Resolution: Fixed

> SC: Lambda in static initializer that uses static field on LHS of += produces 
> errors
> 
>
> Key: GROOVY-9342
> URL: https://issues.apache.org/jira/browse/GROOVY-9342
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-rc-2
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.0-rc-3
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Follow up to GROOVY-9332 and GROOVY-9333.  Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach((Integer i) -> acc += i) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> java.lang.ExceptionInInitializerError\r\n
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n
>   at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n
>   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n
>   at java.lang.reflect.Method.invoke(Method.java:498)\r\n
> {code}



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


[jira] [Issue Comment Deleted] (GROOVY-9342) SC: Lambda in static initializer that uses static field on LHS of += produces errors

2019-12-19 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-9342:

Comment: was deleted

(was: "Cannot find matching method int#plus(java.lang.Object)..." is still an 
issue because  {{StaticTypeCheckingVisitor#inferSAMType}} cannot collect 
generics correctly from {{forEach(Consumer c)}} and so the param 
type is Object.

PR #1126 fixes the assignment case, which is handled by separate methods:
{code:groovy}
int sum = 0
java.util.function.Consumer add = i -> sum += i
{code}
)

> SC: Lambda in static initializer that uses static field on LHS of += produces 
> errors
> 
>
> Key: GROOVY-9342
> URL: https://issues.apache.org/jira/browse/GROOVY-9342
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-rc-2
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.0-rc-3
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Follow up to GROOVY-9332 and GROOVY-9333.  Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach((Integer i) -> acc += i) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> java.lang.ExceptionInInitializerError\r\n
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n
>   at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n
>   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n
>   at java.lang.reflect.Method.invoke(Method.java:498)\r\n
> {code}



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


[jira] [Commented] (GROOVY-9347) STC: lambda expression on wildcard generics fail to resolve param type(s)

2019-12-19 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9347:
-

{{StaticTypeCheckingVisitor#inferSAMType}} cannot collect generics correctly 
from {{forEach(Consumer c)}} and so the param type is Object.

PR #1126 fixes the assignment case, which is handled by separate methods:
{code:groovy}
int sum = 0
java.util.function.Consumer add = i -> sum += i
{code}

> STC: lambda expression on wildcard generics fail to resolve param type(s)
> -
>
> Key: GROOVY-9347
> URL: https://issues.apache.org/jira/browse/GROOVY-9347
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-rc-2
>Reporter: Eric Milles
>Priority: Major
>
> Follow up to GROOVY-9342.  Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach(e -> acc += e) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> TestScript60.groovy: 5: [Static type checking] - Cannot find matching 
> method int#plus(java.lang.Object). Please check if the declared type is 
> correct and if the method exists.
>  @ line 5, column 49.
>atic { [1, 2, 3].forEach(e -> acc += e)
>  ^
> 1 error
> at 
> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
> at 
> org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1091)
> at 
> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
> at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
> at 
> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:367)
> at 
> groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:310)
> ...
> {code}



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


[jira] [Created] (GROOVY-9347) STC: lambda expression on wildcard generics fail to resolve param type(s)

2019-12-19 Thread Eric Milles (Jira)
Eric Milles created GROOVY-9347:
---

 Summary: STC: lambda expression on wildcard generics fail to 
resolve param type(s)
 Key: GROOVY-9347
 URL: https://issues.apache.org/jira/browse/GROOVY-9347
 Project: Groovy
  Issue Type: Bug
Affects Versions: 3.0.0-rc-2
Reporter: Eric Milles


Follow up to GROOVY-9342.  Consider the following:
{code:groovy}
@groovy.transform.CompileStatic
class Test1 {
static int acc = 1
static { [1, 2, 3].forEach(e -> acc += e) }
}
assert Test1.acc == 7
{code}

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
TestScript60.groovy: 5: [Static type checking] - Cannot find matching 
method int#plus(java.lang.Object). Please check if the declared type is correct 
and if the method exists.
 @ line 5, column 49.
   atic { [1, 2, 3].forEach(e -> acc += e)
 ^

1 error
at 
org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
at 
org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1091)
at 
org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
at 
groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:367)
at 
groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:310)
...
{code}



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


[jira] [Updated] (GROOVY-9342) SC: Lambda in static initializer that uses static field on LHS of += produces errors

2019-12-19 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-9342:

Description: 
Follow up to GROOVY-9332 and GROOVY-9333.  Consider the following:
{code:groovy}
@groovy.transform.CompileStatic
class Test1 {
static int acc = 1
static { [1, 2, 3].forEach((Integer i) -> acc += i) }
}
assert Test1.acc == 7
{code}

{code}
java.lang.ExceptionInInitializerError\r\n
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n
at java.lang.reflect.Method.invoke(Method.java:498)\r\n
{code}

  was:
Follow up to GROOVY-9332 and GROOVY-9333.  Consider the following:
{code:groovy}
@groovy.transform.CompileStatic
class Test1 {
static int acc = 1
static { [1, 2, 3].forEach(e -> acc += e) }
}
assert Test1.acc == 7
{code}

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
TestScript60.groovy: 5: [Static type checking] - Cannot find matching 
method int#plus(java.lang.Object). Please check if the declared type is correct 
and if the method exists.
 @ line 5, column 49.
   atic { [1, 2, 3].forEach(e -> acc += e)
 ^

1 error
at 
org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
at 
org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1091)
at 
org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
at 
groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:367)
at 
groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:310)
...
{code}


and a different error if lambda uses specific parameter type:
{code:groovy}
@groovy.transform.CompileStatic
class Test1 {
static int acc = 1
static { [1, 2, 3].forEach((Integer i) -> acc += i) }
}
assert Test1.acc == 7
{code}

{code}
java.lang.ExceptionInInitializerError\r\n
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n
at java.lang.reflect.Method.invoke(Method.java:498)\r\n
{code}


> SC: Lambda in static initializer that uses static field on LHS of += produces 
> errors
> 
>
> Key: GROOVY-9342
> URL: https://issues.apache.org/jira/browse/GROOVY-9342
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-rc-2
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.0-rc-3
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Follow up to GROOVY-9332 and GROOVY-9333.  Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach((Integer i) -> acc += i) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> java.lang.ExceptionInInitializerError\r\n
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n
>   at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n
>   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n
>   at java.lang.reflect.Method.invoke(Method.java:498)\r\n
> {code}



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


[jira] [Comment Edited] (GROOVY-9342) SC: Lambda in static initializer that uses static field on LHS of += produces errors

2019-12-19 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-9342 at 12/19/19 7:30 PM:
---

"Cannot find matching method int#plus(java.lang.Object)..." is still an issue 
because  {{StaticTypeCheckingVisitor#inferSAMType}} cannot collect generics 
correctly from {{forEach(Consumer c)}} and so the param type is 
Object.

PR #1126 fixes the assignment case, which is handled by separate methods:
{code:groovy}
int sum = 0
java.util.function.Consumer add = i -> sum += i
{code}



was (Author: emilles):
"Cannot resolve method int#plus(Object)..." is still an issue because  
{{StaticTypeCheckingVisitor#inferSAMType}} cannot collect generics correctly 
from {{forEach(Consumer c)}} and so the param type is Object.

PR #1126 fixes the assignment case, which is handled by separate methods:
{code:groovy}
int sum = 0
java.util.function.Consumer add = i -> sum += i
{code}


> SC: Lambda in static initializer that uses static field on LHS of += produces 
> errors
> 
>
> Key: GROOVY-9342
> URL: https://issues.apache.org/jira/browse/GROOVY-9342
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-rc-2
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.0-rc-3
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Follow up to GROOVY-9332 and GROOVY-9333.  Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach(e -> acc += e) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> TestScript60.groovy: 5: [Static type checking] - Cannot find matching 
> method int#plus(java.lang.Object). Please check if the declared type is 
> correct and if the method exists.
>  @ line 5, column 49.
>atic { [1, 2, 3].forEach(e -> acc += e)
>  ^
> 1 error
> at 
> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
> at 
> org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1091)
> at 
> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
> at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
> at 
> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:367)
> at 
> groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:310)
> ...
> {code}
> and a different error if lambda uses specific parameter type:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach((Integer i) -> acc += i) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> java.lang.ExceptionInInitializerError\r\n
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n
>   at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n
>   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n
>   at java.lang.reflect.Method.invoke(Method.java:498)\r\n
> {code}



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


[jira] [Comment Edited] (GROOVY-9342) SC: Lambda in static initializer that uses static field on LHS of += produces errors

2019-12-19 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-9342 at 12/19/19 7:25 PM:
---

"Cannot resolve method int#plus(Object)..." is still an issue because  
{{StaticTypeCheckingVisitor#inferSAMType}} cannot collect generics correctly 
from {{forEach(Consumer c)}} and so the param type is Object.

PR #1126 fixes the assignment case, which is handled by separate methods:
{code:groovy}
int sum = 0
java.util.function.Consumer add = i -> sum += i
{code}



was (Author: emilles):
"Cannot resolve method int#plus(Object)..." is still an issue because  
{{StaticTypeCheckingVisitor#inferSAMType}} cannot collect generics correctly 
from {{forEach(Consumer c)}}.

PR #1126 fixes the assignment case, which is handled by separate methods:
{code:groovy}
int sum = 0
java.util.function.Consumer add = i -> sum += i
{code}


> SC: Lambda in static initializer that uses static field on LHS of += produces 
> errors
> 
>
> Key: GROOVY-9342
> URL: https://issues.apache.org/jira/browse/GROOVY-9342
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-rc-2
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.0-rc-3
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Follow up to GROOVY-9332 and GROOVY-9333.  Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach(e -> acc += e) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> TestScript60.groovy: 5: [Static type checking] - Cannot find matching 
> method int#plus(java.lang.Object). Please check if the declared type is 
> correct and if the method exists.
>  @ line 5, column 49.
>atic { [1, 2, 3].forEach(e -> acc += e)
>  ^
> 1 error
> at 
> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
> at 
> org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1091)
> at 
> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
> at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
> at 
> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:367)
> at 
> groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:310)
> ...
> {code}
> and a different error if lambda uses specific parameter type:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach((Integer i) -> acc += i) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> java.lang.ExceptionInInitializerError\r\n
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n
>   at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n
>   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n
>   at java.lang.reflect.Method.invoke(Method.java:498)\r\n
> {code}



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


[jira] [Reopened] (GROOVY-9342) SC: Lambda in static initializer that uses static field on LHS of += produces errors

2019-12-19 Thread Eric Milles (Jira)


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

Eric Milles reopened GROOVY-9342:
-

"Cannot resolve method int#plus(Object)..." is still an issue because  
{{StaticTypeCheckingVisitor#inferSAMType}} cannot collect generics correctly 
from {{forEach(Consumer c)}}.

PR #1126 fixes the assignment case, which is handled by separate methods:
{code:groovy}
int sum = 0
java.util.function.Consumer add = i -> sum += i
{code}


> SC: Lambda in static initializer that uses static field on LHS of += produces 
> errors
> 
>
> Key: GROOVY-9342
> URL: https://issues.apache.org/jira/browse/GROOVY-9342
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.0-rc-2
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
> Fix For: 3.0.0-rc-3
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Follow up to GROOVY-9332 and GROOVY-9333.  Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach(e -> acc += e) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> TestScript60.groovy: 5: [Static type checking] - Cannot find matching 
> method int#plus(java.lang.Object). Please check if the declared type is 
> correct and if the method exists.
>  @ line 5, column 49.
>atic { [1, 2, 3].forEach(e -> acc += e)
>  ^
> 1 error
> at 
> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
> at 
> org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1091)
> at 
> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
> at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
> at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
> at 
> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:367)
> at 
> groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:310)
> ...
> {code}
> and a different error if lambda uses specific parameter type:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Test1 {
> static int acc = 1
> static { [1, 2, 3].forEach((Integer i) -> acc += i) }
> }
> assert Test1.acc == 7
> {code}
> {code}
> java.lang.ExceptionInInitializerError\r\n
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n
>   at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n
>   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n
>   at java.lang.reflect.Method.invoke(Method.java:498)\r\n
> {code}



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


[GitHub] [groovy] eric-milles opened a new pull request #1126: GROOVY-9340: return type, not type redirect

2019-12-19 Thread GitBox
eric-milles opened a new pull request #1126: GROOVY-9340: return type, not type 
redirect
URL: https://github.com/apache/groovy/pull/1126
 
 
   https://issues.apache.org/jira/browse/GROOVY-9340


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


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

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

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


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

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

{code}



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


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

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

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


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

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

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

assert cs() != null
{code}



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


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

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

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


{code}
class A {}
class B {}

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

assert cs() != null
{code}



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


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

2019-12-19 Thread Daniil Ovchinnikov (Jira)


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

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

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



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


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

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

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


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

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

assert cs() == 42

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

assert cs2() == 43
{code}



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


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

2019-12-19 Thread Daniil Ovchinnikov (Jira)


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

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

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

assert cs() == 42

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

assert cs2() == 42
{code}

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

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

assert cs() == 42

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

assert cs2() == 43
{code}


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



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