We've recently added the capability for objects to be called as functions by adding a method to a nominal type with a base name of "callAsFunction
" and any desired parameter tuple. Can such objects be used for code that takes in a closure? I haven't tried it; it's just a thought experiment right now. One part of me thinks they should not match because a closure is a function type and a nominal type with callAsFunction
still isn't a function type. Another part of me thinks they should match because the feature would be 99% useless otherwise.
Which way is it? And if it's allowed, how does that get past the type checker?