Main.hx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. // the enum @:deprecated trumps the enum field one... should be fine
  28. switch (None) {
  29. case None:
  30. }
  31. switch (None2) {
  32. case None2:
  33. }
  34. }
  35. // deprecating fields work
  36. @:deprecated static var deprecatedField:String;
  37. @:deprecated static function deprecatedFunc() return;
  38. // ... however deprecating getters and setters have some gotcha
  39. @:deprecated static var deprecatedProperty(get, set):String;
  40. static function get_deprecatedProperty():String return "0";
  41. static function set_deprecatedProperty(_):String return "0";
  42. static var deprecatedGetSet(get, set):String;
  43. @:deprecated static function get_deprecatedGetSet():String return "0";
  44. @:deprecated static function set_deprecatedGetSet(_):String return "0";
  45. }
  46. @:deprecated
  47. class MyClass { public function new() {} }
  48. @:deprecated
  49. interface MyInterface { }
  50. @:deprecated
  51. enum MyEnum { @:deprecated None; }
  52. enum MyEnum2 { @:deprecated None2; }
  53. @:deprecated
  54. abstract MyAbstract(String) { public function new(value:String) this = value; }
  55. @:deprecated
  56. typedef TClass = MyClass;
  57. @:deprecated
  58. typedef TInterface = MyInterface;
  59. @:deprecated
  60. typedef TEnum = MyEnum;
  61. @:deprecated
  62. typedef TAbstract = MyAbstract;
  63. @:deprecated
  64. typedef TAnon = { a:String };