Main2.hx 578 B

12345678910111213141516171819202122232425262728
  1. class Foo {
  2. public function new() {}
  3. public function test() {}
  4. public function doWithBar(?bar:Bar) {
  5. trace(bar);
  6. }
  7. }
  8. @:keep
  9. class Bar {
  10. public function new() {}
  11. }
  12. function doThingsImpl(foo) {
  13. $type(foo); // Unknown<0>
  14. foo.doWithBar();
  15. $type(foo); // Unknown<0> : { doWithBar : () -> Unknown<1> }
  16. $type(foo.doWithBar); // () -> Unknown<0>
  17. if (foo != null)
  18. trace(foo);
  19. $type(foo); // Null<{ doWithBar : () -> Unknown<0> }>
  20. $type(foo.doWithBar); // () -> Unknown<0>
  21. foo.test(); // Null<{ doWithBar : () -> Unknown<0> }> has no field test
  22. }
  23. function main() {}