[
https://issues.apache.org/jira/browse/GROOVY-10079?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-10079.
------------------------------
> groovyc does not perform unboxing on Character type
> ---------------------------------------------------
>
> Key: GROOVY-10079
> URL: https://issues.apache.org/jira/browse/GROOVY-10079
> 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
>
>
> I have the following code
> {code:java}
> public class Main {
> public static char foo() {
> return (Character) 'd';
> }
> }
> {code}
> h3. Actual behaviour
> groovyc rejects this code with
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> test.groovy: 4: [Static type checking] - Cannot return value of type
> java.lang.Character on method returning type char
> @ line 4, column 12.
> return (Character) 'd';
> ^1 error
> {code}
> h3. Expected behaviour
> Compile successfully
>
> Note that javac accepts this code. Beyond that, groovyc performs unboxing as
> expected when encountering other wrapper classes, e.g. Short. So, for example
> the following code is accepted by groovyc.
>
> {code:java}
> public class Main {
> public static short foo() {
> return (Short) 1;
> }
> }
> {code}
> Tested against master:
> https://github.com/apache/groovy/commit/1def25301b42132f0fce82f2f524aa09c53835d4
--
This message was sent by Atlassian Jira
(v8.20.1#820001)