Main.hx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. class Main {
  2. static function main() {
  3. // deprecating type objects work
  4. MyClass;
  5. MyInterface;
  6. MyEnum;
  7. // MyAbstract; // this compiles when analyzer=yes, but is another issue
  8. TClass;
  9. TInterface;
  10. TEnum;
  11. // TAbstract; // this compiles when analyzer=yes, but is another issue
  12. // TAnon; // this won't and shouldn't compile anyway
  13. // deprecating types instantiated work
  14. new MyClass();
  15. MyEnum.None;
  16. new MyAbstract(null); // but doesn't work on abstracts...
  17. new TClass();
  18. TEnum.None;
  19. new TAbstract(null); // neither
  20. // some physical access to deprecated API
  21. deprecatedField;
  22. deprecatedFunc();
  23. deprecatedProperty; // this won't show warnings
  24. var x = deprecatedProperty; // this also
  25. deprecatedGetSet; // however this will
  26. var x = deprecatedGetSet; // this also
  27. }
  28. // deprecating fields work
  29. @:deprecated static var deprecatedField:String;
  30. @:deprecated static function deprecatedFunc() return;
  31. // ... however deprecating getters and setters have some gotcha
  32. @:deprecated static var deprecatedProperty(get, set):String;
  33. static function get_deprecatedProperty():String return "0";
  34. static function set_deprecatedProperty(value):String return "0";
  35. static var deprecatedGetSet(get, set):String;
  36. @:deprecated static function get_deprecatedGetSet():String return "0";
  37. @:deprecated static function set_deprecatedGetSet(value):String return "0";
  38. }
  39. @:deprecated
  40. class MyClass { public function new() {} }
  41. @:deprecated
  42. interface MyInterface { }
  43. @:deprecated
  44. enum MyEnum { None; }
  45. @:deprecated
  46. abstract MyAbstract(String) { public function new(value:String) this = value; }
  47. @:deprecated
  48. typedef TClass = MyClass;
  49. @:deprecated
  50. typedef TInterface = MyInterface;
  51. @:deprecated
  52. typedef TEnum = MyEnum;
  53. @:deprecated
  54. typedef TAbstract = MyAbstract;
  55. @:deprecated
  56. typedef TAnon = { a:String };