element.firstElementChild() doesn't cause an error
firstElementChild is of type Element and I'd expect trying to call it as a function would cause a compiler error call to type is not a function. but it compiles with no error.
This is the full statement which doesn't get an error:
element.insertBefore(indicator.element,element.firstElementChild());
element and indicator.element are both of type org.apache.royale.core.WrappedHTMLElement
Actually, it looks like this is a global problem.
I just picked EdgeData (because it's a simple class) and added this.bottom() in the constructor and no error. If I add private var foo:String to the class, there is an error, so it looks to me like a getter passes the function check, but a simple var doesn't.
@aharui @joshtynjala Thoughts?
Confirmed that them Royale compiler does not produce a compile-time error when attempting to call a getter or setter as a function.
The Flex SDK produces the following compiler error:
Error: Call to a possibly undefined method foo through a reference with static type MyClass.
Update. I've determined that there are actually two issues here.
- Attempting to call a getter/setter as a function isn't producing a compiler error.
- Attempting to call a variable as a function, if the type is anything other than Number/Boolean/String/int/uint isn't producing a compiler error. (no error should result from a variable of type Function, Class, Object, or *, of course)
The Flex SDK produces a compiler error in both cases.
The commit looked like it was only for case 1 (getter/setter)?
Correct. Another commit is on the way soon.
It may be too early in the morning for me, but are you sure that the error shouldn't also be added for type Class? And what about XML and instances of classes?
Bonus if you can output a warning for type Object and type *
I checked the Flex SDK, and it does not output any errors or warnings when calling a variable of type Function, Class, Object, or * as a function.
If the variable has any other type, there's an error (at least for the types that I tested, which included XML and custom classes)
I've determined that the Royale compiler used to be as strict as the Flex SDK compiler. However, it was made more lenient in commit 1152253d28ce140f5e1339e525645ec9e64424fe. It seems that we needed a hack to allow jquery's $ to expose its own methods and also be called as a function.
Well, if you have time, you are welcome to restore the old code and come up with a different solution for the JQuery issue.
One possibility is that we should create a way to mark a typedef as "dynamic" (if there isn't already a way I didn't know about) which I think JQuery is.