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

John Wagenleitner commented on GROOVY-7807:
-------------------------------------------

I tested a slightly different version in 2.4.3 and 2.4.4 and both work.

{code}
class Foo1 {
    boolean asBoolean() { true }
}

class Foo2 {
    boolean asBoolean() { false }
}

@groovy.transform.CompileStatic
class Bar {
    int m1() {
        return new Foo1() ? 3 : 5
    }
    int m2() {
        return new Foo2() ? 7 : 11
    }
}

assert new Bar().m1() == 3
assert new Bar().m2() == 11
{code}

> CompileStatic doesn't call asBoolean
> ------------------------------------
>
>                 Key: GROOVY-7807
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7807
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.4
>            Reporter: Johann
>
> I have a class that implements asBoolean:
> {code:java}
> class Foo {
>    
>     /**
>      * @return whether any properties are <tt>true</tt>
>      */
>     boolean asBoolean() {
>         foo || bar || keks || blorb
>     }
> }
> {code}
> When using this class in a class that has {{@CompileStatic}} applied to it, 
> the {{asBoolean}} method is not called in a ternary expression.
> May be related to GROOVY-6802.



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

Reply via email to