[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-dev
Subject:    Re: [groovy-dev] ClosureMetaClass question
From:       Jochen Theodorou <blackdrag () gmx ! org>
Date:       2007-08-25 14:52:00
Message-ID: 46D04210.3010008 () gmx ! org
[Download RAW message or body]

Paul King schrieb:
[...]
> Ok, inside visitClosureExpression() in ACG, I changed the static/dynamic
> check from this:
> 
>  if (isStaticMethod() || classNode.isStaticClass())
> 
> to this:
> 
>  if (isStaticMethod() || (classNode.isStaticClass() && 
> classNode.getSuperClass() != ClassHelper.CLOSURE_TYPE)) {
> 
> I am sure there is a better way but this makes the bug go away
> and all the current tests still pass.

hmm... I guess that would mean if I write a subclass of Closure I get a 
problem...

How about testing for the new interface GeneratedClosure? Because only 
in that case we can be sure it really is a closure amde by groovy itself 
and not some custom code.

that means:

if ((isStaticMethod() || classNode.isStaticClass()) && 
!classNode.declaresInterface(ClassHelper.GENERATED_CLOSURE_Type.getName())

but looking at that I would modify it to

if (isStaticMethod() && 
!classNode.declaresInterface(ClassHelper.GENERATED_CLOSURE_Type.getName())

becasue beeing a static means nothing that should be of itnerest here.

bye blackdrag


-- 
Jochen "blackdrag" Theodorou
Groovy Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic