Unfortunately it's not even a performance or complexity thing, it's a "we actually don't know how to make it work like that" thing.

The idea I've liked best so far is to have extensions on types from other modules introduce a local type by the same name that forwards everything to the original type except for conformances. But that's not source compatible, and if not done very carefully could be incredibly confusing. Like, imagine extending String to conform to Error (which lots of people have done), and then trying to throw a String you got from a system framework, and it mysteriously doesn't work because it's the system's String which doesn't have your conformance.

Another idea that's been proposed is adding a new "scoped conformances" feature, but I don't think anyone has gotten far enough to have a concrete design for how the runtime would behave. And even then, I can imagine it being confusing: would a Dictionary<Foo> work if Foo's Hashable conformance was scoped to just your module? (since Dictionary is a type not from your module)

It's possible we'll eventually find a solution for this, but it's not just a matter of perf or complexity tradeoffs.

7 Likes