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 2021/05/11 23:02:00 UTC
[jira] [Assigned] (GROOVY-10079) groovyc does not perform unboxing
on Character type
[ https://issues.apache.org/jira/browse/GROOVY-10079?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles reassigned GROOVY-10079:
------------------------------------
Assignee: Eric Milles
> 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
>
> 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.3.4#803005)