Issue Details (XML | Word | Printable)

Key: GROOVY-2136
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Paul King
Reporter: Peter Niederwieser
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
groovy

Static import of properties and fields does not work

Created: 23/Sep/07 11:05 AM   Updated: 10/Oct/07 06:18 AM   Resolved: 26/Sep/07 08:18 PM
Return to search
Component/s: None
Affects Version/s: 1.1-beta-3
Fix Version/s: 1.1-rc-1

Time Tracking:
Not Specified

Environment:
OS: Win XP
Groovy Version: 1.1-beta-3
JVM: 1.6.0_02-b05


 Description  « Hide

The following doesn't work with Groovy 1.1 beta 3, neither in interpreted nor in compiled mode. Adding 'public' and/or 'final' to the declaration of 'temperature' doesn't change the picture. With beta 2 the program works in compiled but not in interpreted mode.

--------------------------------------------------------

E:\dev\tmp\test>type A.groovy
class A {
static def temperature = 42
}

E:\dev\tmp\test>type B.groovy
import static A.*

class B {
static def main(args) { println temperature }
}

E:\dev\tmp\test>groovy B
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed,
B.groovy: 4: the name temperature doesn't refer to a declared variable or class.
The static scope requires to declare variables before using them. If the variab
le should have been a class check the spelling.
@ line 4, column 35.
static def main(args) { println temperature }
^

1 error

E:\dev\tmp\test>groovyc *.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed,
B.groovy: 4: the name temperature doesn't refer to a declared variable or class.
The static scope requires to declare variables before using them. If the variab
le should have been a class check the spelling.
@ line 4, column 35.
static def main(args) { println temperature }
^

1 error



Paul King made changes - 23/Sep/07 03:23 PM
Field Original Value New Value
Assignee Paul King [ paulk ]
Paul King added a comment - 26/Sep/07 06:47 PM

This is mostly fixed - moved the remaining static error detection parts into staticImportVisitor but I have a hack in place for one part - checking if Jochen has any ideas on a better way.


Paul King added a comment - 26/Sep/07 08:18 PM

Resolved remaining issue as far as I can tell, tests added


Paul King made changes - 26/Sep/07 08:18 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Fix Version/s 1.1-rc-1 [ 13165 ]
Paul King added a comment - 10/Oct/07 06:18 AM

No further feedback, assuming fixed


Paul King made changes - 10/Oct/07 06:18 AM
Status Resolved [ 5 ] Closed [ 6 ]