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/03/02 15:16:00 UTC

[jira] [Resolved] (GROOVY-9901) Memoization doesn't seem to work for trait methods

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

Eric Milles resolved GROOVY-9901.
---------------------------------
    Fix Version/s: 4.0.0-alpha-3
       Resolution: Fixed

> Memoization doesn't seem to work for trait methods
> --------------------------------------------------
>
>                 Key: GROOVY-9901
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9901
>             Project: Groovy
>          Issue Type: Bug
>          Components: ast builder
>    Affects Versions: 2.5.12
>            Reporter: LÅ‘rinc Pap
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-alpha-3
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> I wanted to memorize a method in a trait, basically the following:
> {code:java}
> import groovy.transform.Memoized
> trait T {
>     @Memoized
>     double method() {
>         Math.random()
>     }
> }
> class A implements T {}
> class B implements T {}
> def a = new A()
> println a.method()
> println a.method()
> println new A().method()
> println new B().method(){code}
> And was surprised to see that they all returned different results.
> If this isn't supported, could we at least warn in case of AST transformations being applied to traits (i.e. [http://docs.groovy-lang.org/next/html/documentation/core-traits.html#_compatibility_with_ast_transformations)]?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)