[jira] [Updated] (GROOVY-8034) Compile error when using generic type with lower bound

2022-09-11 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-8034:

Fix Version/s: 2.5.19

> Compile error when using generic type with lower bound
> --
>
> Key: GROOVY-8034
> URL: https://issues.apache.org/jira/browse/GROOVY-8034
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.4.6, 2.4.7
>Reporter: Yuriy Kiselev
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-alpha-3, 2.5.19, 3.0.13
>
>
> I'm trying to implement chained generics. It works as Java code but fails to 
> compile by groovyc:
> {code}
> Error:(38, 9) Groovyc: [Static type checking] - Cannot call  com.github.ykiselev.ChainTest.A> 
> com.github.ykiselev.ChainTest$A  java.lang.Object, ?>#andThen(C) 
> with arguments [com.github.ykiselev.ChainTest$A ]
> {code}
> Code (JUnit4 unit test)
> {code}
> package com.github.ykiselev
> import groovy.transform.TypeChecked
> import org.junit.Test
> @TypeChecked
> class ChainTest {
> static class A {
> def > C andThen(C next) {
> return next
> }
> }
> static > C chain(A self, C next) {
> self.andThen(next)
> return next
> }
> @Test
> void "should chain"() {
> def a1 = new A()
> def a2 = new A()
> def a3 = new A()
> def a4 = new A()
> def a5 = new A()
> a1.andThen(a2) // ok
> a2.andThen(a3) // ok
> a3.andThen(a4) // ok
> a4.andThen(a5) // ok (even without "? super O")
> chain(a1, a2).andThen(a3) // ok
> chain(chain(chain(chain(a1, a2), a3), a4), a5) // ok
> a1.andThen(a2)
> .andThen(a3) // static type checker error
> .andThen(a4)
> .andThen(a5)
> }
> }
> {code}
> This would compile if I change bounded type parameter like this:
> {code}
> def > C andThen(C next) {
> return next
> }
> {code}
> but I need it bounded.



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


[jira] [Updated] (GROOVY-8034) Compile error when using generic type with lower bound

2022-09-11 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-8034:

Fix Version/s: 3.0.13

> Compile error when using generic type with lower bound
> --
>
> Key: GROOVY-8034
> URL: https://issues.apache.org/jira/browse/GROOVY-8034
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.4.6, 2.4.7
> Environment: groovy JDK 2.4.7, 2.4.6, 
> Java used: jdk1.7.0_51, jdk1.8.0_40, 9-ea+114, 
> RedHat\java-1.8.0-openjdk-1.8.0.111-3
>Reporter: Yuriy Kiselev
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-alpha-3, 3.0.13
>
>
> I'm trying to implement chained generics. It works as Java code but fails to 
> compile by groovyc:
> {code}
> Error:(38, 9) Groovyc: [Static type checking] - Cannot call  com.github.ykiselev.ChainTest.A> 
> com.github.ykiselev.ChainTest$A  java.lang.Object, ?>#andThen(C) 
> with arguments [com.github.ykiselev.ChainTest$A ]
> {code}
> Code (JUnit4 unit test)
> {code}
> package com.github.ykiselev
> import groovy.transform.TypeChecked
> import org.junit.Test
> @TypeChecked
> class ChainTest {
> static class A {
> def > C andThen(C next) {
> return next
> }
> }
> static > C chain(A self, C next) {
> self.andThen(next)
> return next
> }
> @Test
> void "should chain"() {
> def a1 = new A()
> def a2 = new A()
> def a3 = new A()
> def a4 = new A()
> def a5 = new A()
> a1.andThen(a2) // ok
> a2.andThen(a3) // ok
> a3.andThen(a4) // ok
> a4.andThen(a5) // ok (even without "? super O")
> chain(a1, a2).andThen(a3) // ok
> chain(chain(chain(chain(a1, a2), a3), a4), a5) // ok
> a1.andThen(a2)
> .andThen(a3) // static type checker error
> .andThen(a4)
> .andThen(a5)
> }
> }
> {code}
> This would compile if I change bounded type parameter like this:
> {code}
> def > C andThen(C next) {
> return next
> }
> {code}
> but I need it bounded.



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


[jira] [Updated] (GROOVY-8034) Compile error when using generic type with lower bound

2022-09-11 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-8034:

Environment: (was: groovy JDK 2.4.7, 2.4.6, 
Java used: jdk1.7.0_51, jdk1.8.0_40, 9-ea+114, 
RedHat\java-1.8.0-openjdk-1.8.0.111-3)

> Compile error when using generic type with lower bound
> --
>
> Key: GROOVY-8034
> URL: https://issues.apache.org/jira/browse/GROOVY-8034
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.4.6, 2.4.7
>Reporter: Yuriy Kiselev
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-alpha-3, 3.0.13
>
>
> I'm trying to implement chained generics. It works as Java code but fails to 
> compile by groovyc:
> {code}
> Error:(38, 9) Groovyc: [Static type checking] - Cannot call  com.github.ykiselev.ChainTest.A> 
> com.github.ykiselev.ChainTest$A  java.lang.Object, ?>#andThen(C) 
> with arguments [com.github.ykiselev.ChainTest$A ]
> {code}
> Code (JUnit4 unit test)
> {code}
> package com.github.ykiselev
> import groovy.transform.TypeChecked
> import org.junit.Test
> @TypeChecked
> class ChainTest {
> static class A {
> def > C andThen(C next) {
> return next
> }
> }
> static > C chain(A self, C next) {
> self.andThen(next)
> return next
> }
> @Test
> void "should chain"() {
> def a1 = new A()
> def a2 = new A()
> def a3 = new A()
> def a4 = new A()
> def a5 = new A()
> a1.andThen(a2) // ok
> a2.andThen(a3) // ok
> a3.andThen(a4) // ok
> a4.andThen(a5) // ok (even without "? super O")
> chain(a1, a2).andThen(a3) // ok
> chain(chain(chain(chain(a1, a2), a3), a4), a5) // ok
> a1.andThen(a2)
> .andThen(a3) // static type checker error
> .andThen(a4)
> .andThen(a5)
> }
> }
> {code}
> This would compile if I change bounded type parameter like this:
> {code}
> def > C andThen(C next) {
> return next
> }
> {code}
> but I need it bounded.



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


[jira] [Updated] (GROOVY-8974) STC ignores declaration type

2022-09-11 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-8974:

Fix Version/s: 2.5.19

> STC ignores declaration type
> 
>
> Key: GROOVY-8974
> URL: https://issues.apache.org/jira/browse/GROOVY-8974
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.5
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-1, 3.0.10, 2.5.19
>
>
> {code:java}
> static  T id(T arg) { arg }
> @groovy.transform.CompileStatic
> def ddd() {
>   List ls = id(new ArrayList<>())
>   ls.get(0).toUpperCase() // Cannot find matching method 
> java.lang.Object#toUpperCase()
> }
> println ddd()
> {code}



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


[jira] [Updated] (GROOVY-10107) Cannot assign null to a variable with a bounded generic type

2022-09-11 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-10107:
-
Fix Version/s: 2.5.19

> Cannot assign null to a variable with a bounded generic type
> 
>
> Key: GROOVY-10107
> URL: https://issues.apache.org/jira/browse/GROOVY-10107
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-1, 3.0.9, 2.5.19
>
>
> I have the following program
> {code:java}
> final class Test {
>   final void m() {
> T v = null;
>   }
> }
> {code}
> h3. Actual Behaviour
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 5: [Static type checking] - Cannot assign value of type  parameter type> to variable of type T
>  @ line 5, column 11.
>T v = null;
>  ^1 error
> {code}
> h3. Expected Behaviour
>  
> Tested against master 
> https://github.com/apache/groovy/commit/7a56d7130aaf7b5244fa5a82fa0505fb7509f51f



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


[jira] [Updated] (GROOVY-9033) Bad code green: empty list literal with each method

2022-09-11 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-9033:

Fix Version/s: 2.5.17

> Bad code green: empty list literal with each method
> ---
>
> Key: GROOVY-9033
> URL: https://issues.apache.org/jira/browse/GROOVY-9033
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.6
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-1, 2.5.17, 3.0.11
>
>  Time Spent: 50m
>  Remaining Estimate: 0h
>
> {code:groovy}
> @groovy.transform.CompileStatic
> List usage() {
>   def l = [].each {}
>   return l // expected error: Incompatible generic argument types. Cannot 
> assign java.util.List  to: java.util.List  
> }{code}



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