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 2020/02/04 20:32:00 UTC
[jira] [Resolved] (GROOVY-9374) Type-inference fails for tap on
inner classes with type checking
[ https://issues.apache.org/jira/browse/GROOVY-9374?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-9374.
---------------------------------
Fix Version/s: 3.0.0-rc-4
Assignee: Eric Milles
Resolution: Fixed
> Type-inference fails for tap on inner classes with type checking
> ----------------------------------------------------------------
>
> Key: GROOVY-9374
> URL: https://issues.apache.org/jira/browse/GROOVY-9374
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.5.9
> Environment: Groovy 2.5.9. on Zulu JDK 11.0.3; Linux
> Reporter: Jan Hackel
> Assignee: Eric Milles
> Priority: Major
> Fix For: 3.0.0-rc-4
>
>
> The following code will not compile with Groovy 2.5.9. It produces an error "[Static type checking] - Cannot assign value of type java.lang.Object to variable of type java.time.LocalDate". Same thing happens for instance fields.
> A workaround is to qualify the source field either by {{this}} or by class name.
> {code:groovy}
> import groovy.transform.CompileStatic
> import java.time.LocalDate
> @CompileStatic
> class TapTypeChecking {
> private static final LocalDate DATE = LocalDate.of(2020, 2, 1)
> static Inner inner() {
> return new Inner().tap {
> someDate = DATE
> }
> }
> static class Inner {
> LocalDate someDate
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)