|
Graeme Rocher made changes - 20/Jul/07 09:16 AM
I splitted ResolveVisitor inot the normal resolving process and a StaticImportVisitor that is doing only static imports. The new class works after ResolveVisitor was run and should then no longer have a problem with not yet parsed classes.
Jochen Theodorou made changes - 20/Jul/07 01:35 PM
I'm using snapshot build 447 and this still isn't working for me: [nvw384@ma34jasper sandbox]$ groovy -version nvw384@ma34jasper sandbox]$ echo $GROOVY_HOME [nvw384@ma34jasper sandbox]$ less test1/mytest.groovy import static test1.test2.Utils.* printMe(); [nvw384@ma34jasper sandbox]$ less test1/test2/Utils.groovy class Utils {
Jason Weden made changes - 24/Jul/07 01:10 PM
I did a quick jad of code generated using groovyc. For this code: import static java.lang.Math.* println cos(2*PI) beta-2 generates: ...
ScriptBytecodeAdapter.invokeStaticMethodN(class1, java.lang.Math.class, "cos", new Object[] {
ScriptBytecodeAdapter.invokeMethodN(class1, new Integer(2), "multiply", new Object[] {
ScriptBytecodeAdapter.getProperty(class1, java.lang.Math.class, "PI")
})
})
...
beta-3-SNAPSHOT generates: ...
ScriptBytecodeAdapter.invokeMethodOnCurrentN(class1, (GroovyObject)ScriptBytecodeAdapter.castToType(this, groovy.lang.GroovyObject.class), "cos", new Object[] {
ScriptBytecodeAdapter.invokeMethodN(class1, new Integer(2), "multiply", new Object[] {
ScriptBytecodeAdapter.getGroovyObjectProperty(class1, this, "PI")
})
})
...
The static import visitor seems to be doing the right thing but that isn't reflected in the generated code. Can you try again with HEAD.
Guillaume Laforge made changes - 20/Sep/07 03:11 PM
If you can't reproduce it with beta-3, you can close it. Thanks for the nudge. Sorry, I've been so busy. Using the same example code listed in my previous comment, I can see that this is fixed. And.....THANK YOU. [nvw384@ma34jasper 1978]$ groovy -version [nvw384@ma34jasper 1978]$ groovy test1/mytest.groovy [nvw384@ma34jasper 1978]$ /opt/groovy-1.1-beta-3/bin/groovy test1/mytest.groovy
Jason Weden made changes - 21/Sep/07 07:08 AM
Paul King made changes - 21/Sep/07 07:37 AM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ok, after looking into this I found the reason... at the point the ResolveVisitor finds the static import the class is not yet parsed. Which means finding the static method must be done at a later step than it is currently done.