You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/07/23 16:23:00 UTC
[jira] [Updated] (GROOVY-10367) STC fails to infer the correct type for type variable in the presence of the diamond operator and bounded polymorphism
[ https://issues.apache.org/jira/browse/GROOVY-10367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-10367:
---------------------------------
Fix Version/s: (was: 5.0.0-alpha-1)
> STC fails to infer the correct type for type variable in the presence of the diamond operator and bounded polymorphism
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-10367
> URL: https://issues.apache.org/jira/browse/GROOVY-10367
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
> Fix For: 3.0.11, 4.0.2
>
>
> This issue may be related to GROOVY-10343.
> I have the following program
> {code:java}
> class A<Z, P extends Z> {
> Z f;
> A(Z f) {}
> }
> class B<Z extends Number> {
> Z f;
> void test() {
> f = new A<>((Z) null).f;
> }
> }
> {code}
> h3. Actual behaviour
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 10: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type Z
> @ line 10, column 9.
> f = new A<>((Z) null).f;
> ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> NOTE: Replacing `Z extends Number` with `Z` leads to a successful compilation.
> Tested against master (https://github.com/apache/groovy/commit/cf2f77fb033a10d36c4db3a7ff07a2b04631afcf)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)