Main.hx 603 B

12345678910111213141516171819202122232425
  1. typedef Foo = {
  2. final id:String;
  3. final ?project:String;
  4. }
  5. typedef Bar = {
  6. final id:String;
  7. final createDate:Date;
  8. final ?project:String;
  9. }
  10. class Main {
  11. static function constrained<T,R:T>(v:R):T
  12. return null;
  13. static function fn<T>(s:T):T {
  14. return s;
  15. }
  16. static function main() {
  17. var A:Int = fn('s'); // Error "String should be Int"
  18. var B:Int = constrained('s'); //Error "Int should be String" instead of "String should be Int"
  19. var C:Bar = constrained((null:Foo)); // compiles, but should error "Foo should be Bar; { ?project : Null<String>, id : String } has no field createDate"
  20. }
  21. }