[ https://issues.apache.org/jira/browse/GROOVY-10628?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-10628. ---------------------------------- Fix Version/s: 5.0.0-alpha-1 Resolution: Fixed https://github.com/apache/groovy/commit/a976ecdee1f17f7fafc55767de2d857c44d44697 > Elvis assignment operator loses type information > ------------------------------------------------ > > Key: GROOVY-10628 > URL: https://issues.apache.org/jira/browse/GROOVY-10628 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker > Affects Versions: 4.0.2 > Reporter: Christopher Smith > Assignee: Eric Milles > Priority: Major > Fix For: 5.0.0-alpha-1 > > > This class works as expected: > {code} > class RoutingInfo { > String to > void hello() { this.to ?= 'alice' } > } > {code} > Trying to use Elvis assignment from a class _in another file_ (it must be > another file) causes the STC to lose track of the type of the RHS and > complain that it can't assign Object to String: > {code} > class Other { > void world() { > new RoutingInfo().to ?= 'bob' > } > } > {code} > {code} > Groovy:[Static type checking] - Cannot assign value of type java.lang.Object > to variable of type java.lang.String > {code} -- This message was sent by Atlassian Jira (v8.20.7#820007)