Last active
August 29, 2015 14:26
-
-
Save j3k0/fcfa309ae0918cc93aef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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