Clean up extends checks to improve performance
Summary:
Clean up code in `Typing_extends.ml`. Most importantly, remove the poor checking of consts: for every interface that a class directly implements, we currently construct (the same) map from the list returned from `Cls.consts` on the class, in order to check against the consts defined by that interface. This is O(n^2) or worse.
Refactor the code so that `Typing_extends.ml` deals with *all* interfaces (and parent and traits) declared by a class, instead of iterating over them in `Typing_toplevel.ml`. Avoid calling `Cls.consts` on the class itself, instead just use `Cls.get_const` on demand. Also get rid of the construction and deconstruction of the class instantiated at its generic parameters. There is no need - and there is no need to construct the identity substitution simply in order to apply it to elements of the class! (This results in some slight changes to errors - see tests).
Reviewed By: francesco-zappa-nardelli
Differential Revision:
D30453437
fbshipit-source-id:
54bc1cda329b8a5d805fcd57167e18916a124688