Flex development -- variable definition can clash with package name, but IntelliJ 10.5.2 does not complain


Today I encountered an issue in Flex that for me as a Java programmer was strange and new, and apparently also IntelliJ doesn't know about it.

I didn't know namespaces for packages and variables were basically one and the same in Flex. Apparently in Flex you cannot have a package called e.g. "components" and then a class that (1) uses classes in this package, say "import components.MyImage;", and (2) defines a class variable called components, e.g. "private static var components:ArrayCollection;". What happens is that the compiler cannot resolve calls like "components.addItem(...)" anymore. The components call refers to the package instead of the class variable. I have not tested whether the same phenomenon exists with instance variables, or with local variables, by the way.

Anyway, the point is as I mentioned that IntelliJ also does not seem to know this. It gives suggestions consistent with ArrayCollection when pressing Ctrl-Space behind "components." and does not indicate e.g. "components.addItem(...)" as being erroneous, while the Flex compiler does, with an incredibly vague error message (the earlier mentioned message that "components.addItem(...)" is not a valid method call.

I don't have a bug tracker account (yet) so this is why I post to the forum. Also I don't really see it as a bug...

Best! Steven

Please sign in to leave a comment.