My assumption is that both functions call doSomething() via virtual table, because, as I have heard, Swift doesn't generate copies of a class with generics for every T (as C++ does), so it seems impossible to use static dispatch here. But probably I'm wrong and the compiler manages to call doSomething() directly somehow.
I believe the answer is, it depends. If this is a public function in a library, you have no idea how it’s called, so it uses a vtable. But if it’s a private method and the compiler can see that it’s only ever called with T==Int or T==Double, it’ll just emit those two versions instead.
Both of the above replies are correct. One further detail: if you mark the public function in the library as "inlineable", it will be able to do specialized versions of it for calls from outside the library too, at the cost of limiting your ability to change the implementation in the future.