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 2022/01/17 18:52:00 UTC

[jira] [Resolved] (GROOVY-6154) Property added as getName() extension method for every Object isn't accessible for null

     [ https://issues.apache.org/jira/browse/GROOVY-6154?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles resolved GROOVY-6154.
---------------------------------
    Resolution: Information Provided

> Property added as getName() extension method for every Object isn't accessible for null
> ---------------------------------------------------------------------------------------
>
>                 Key: GROOVY-6154
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6154
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>            Reporter: Mykola Golubyev
>            Priority: Major
>
> When you add an extension method using org.codehaus.groovy.runtime.ExtensionModule
>     static int getAge(Object o) { return 15; }
> you can call the method using Groovy property shortcut like
>    def value = 1
>    assert value.age == 15
>    assert value.getAge() == 15
> however when value is null Groovy property shortcut doesn't work 
> but getAge() method still works as expected
>    def value = null
>    assert value.age == 15 // Cannot get property 'age' on null object
>    assert value.getAge() == 15



--
This message was sent by Atlassian Jira
(v8.20.1#820001)