Skip to content

Instantly share code, notes, and snippets.

@j3k0
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j3k0/fcfa309ae0918cc93aef to your computer and use it in GitHub Desktop.
Save j3k0/fcfa309ae0918cc93aef to your computer and use it in GitHub Desktop.
typedef A = { a:Int };
typedef B = { > A, b:Int };
class TypedefTest {
public static function f(x:A):A
return x.a == 0 ? x : null;
static function main() {
var b:B = { a:1, b:2 };
var fb:B = f(b);
// compiler complains:
// A should be B
// { a : Int } should be B
// { a : Int } should be { b : Int, a : Int }
// { a : Int } has no field b
// casting returns null.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment