Fix array casting & dispatcher not respecting can_compile flag
Also refactor the function type generation code
Merge pull request #827 from sklam/fix_casting

Fix array casting & dispatcher not respecting can_compile flag