|
package { public class XXX { override public function toString() : String { return "XXX"; } } } The code above will also not compile. So the compiler is very clear about this, however the Flash VM, interpretes toString on serveral occasions. But that's a different story... The way it works consistent looks to me like this:
1) Dynamic classes like {} have the "toString" property ALWAYS assigned. If not overwritten (like in your example) it contains a function. So the chances are quite high toString contains a function in dynamic objects. It will be the case usually. If toString is certainly defined then toString is for sure. Never the less I think a .toString code-completion has a 99.9% chance of being useful. 2) Normal classes that don't have a toString property/method defined do have the Object's toString method. That concludes to me: And not to forget: the other methods are not really less important ok - I tried this:
var foo : EmptyClass = new EmptyClass(); trace (foo["toString"]); // returns function trace (foo.toString); // does not compile var a : Object = {}; trace (a.toString); // return function So... at runtime "toString" always exists. But it will only compile:
Only on those occasions FDT should propose "toString". So "toString" cannot be added to Object (because of inheritance), but to "dynamic or untyped objects". You are right - it makes sense to add a special problem for that in order to switch it off - maybe that can be default. Thank you for clarifying that! Greets, Nico. duplicate, sorry
http://bugs.powerflasher.com/jira/browse/FDT-2026 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I am not sure if what you suggest is right. Please review this example:
So... class Object does not contain the method "toString" (not as in Java). You can add "toString" as an "int" to a dynamic object. However, if FDT would bind "toString" to a dynamic object, then it would cause an error at "o.toString = 1". So, from a semantic point of view, the FDT behavoir is right.
FDT could add "toString() : String" to autocompletion, but I think it's not correct to give proposals that are in fact not right.
Any thoughts on this?
Greets, Nico.