You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Theodorou (JIRA)" <ji...@apache.org> on 2016/05/23 17:24:12 UTC

[jira] [Commented] (GROOVY-7845) Impossible to explicitely call a specific method with null argument.

    [ https://issues.apache.org/jira/browse/GROOVY-7845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15296675#comment-15296675 ] 

Jochen Theodorou commented on GROOVY-7845:
------------------------------------------

If this does not work with Spock, then this is a semantic change done by spock, because this works:
{code:Java}
public class Foo {
    public static String toStringSpecial(Object object) {return "Object: "+object;}                                 
    public static String toStringSpecial(Set object)  {return "Set: "+object;}
    public static String toStringSpecial(String object) {return "String: "+object;}
}

assert Foo.toStringSpecial(null) == "Object: null"
assert Foo.toStringSpecial((Set)null) == "Set: null"
assert Foo.toStringSpecial((String)null) == "String: null"
{code}

> Impossible to explicitely call a specific method with null argument.
> --------------------------------------------------------------------
>
>                 Key: GROOVY-7845
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7845
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.6
>            Reporter: Joern Huxhorn
>              Labels: user
>
> - Clone the repository https://github.com/huxi/bugs
> - cd bugs/groovy/calls-with-null
> - ./gradlew
> The example class has three public static 'toStringSpecial' methods. It's impossible to call toStringSpecial(Set) or toStringSpecial(String) with a null argument.
> This is possible in Java by casting null to the desired type.
> It's currently impossible (AFAIK) to use Spock for testing such Java methods.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)