You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/07/23 14:17:05 UTC
[jira] [Closed] (GROOVY-9580) STC: return type checking for
generic, covariant property gives false error
[ https://issues.apache.org/jira/browse/GROOVY-9580?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-9580.
-----------------------------
> STC: return type checking for generic, covariant property gives false error
> ---------------------------------------------------------------------------
>
> Key: GROOVY-9580
> URL: https://issues.apache.org/jira/browse/GROOVY-9580
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 3.0.4, 2.5.12
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Minor
> Fix For: 4.0.0-alpha-1, 3.0.5, 2.5.13
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Follow up to GROOVY-7691. When getter generated for property is used, return type check fails.
> {code:groovy}
> import groovy.transform.*
> @CompileStatic
> @TupleConstructor(includeFields=true)
> abstract class A<N extends Number> {
> final N number
> }
> @CompileStatic
> class C<L extends Long> extends A<L> {
> C(L longNumber) {
> super(longNumber)
> }
> L getValue() {
> return getNumber() // property method stubbed by StaticTypeCheckingVisitor
> }
> }
> assert new C<Long>(42L).value == 42L
> {code}
> "[Static type checking] - Cannot return value of type N on method returning type L"
> StaticTypeCheckingVisitor has set the wrong declaring class for {{getNumber}} and so generics resolution from N to Long fails.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)