The existential version of this function would read to me as “registerVehicleId
accepts any type which is a witness for Vehicle.Id
in some visible conformance.” This seems… well founded to me at first blush but I’m not sure what you could usefully do with it, since there are no constraints on the Id
associated type.
The generic version seems a bit trickier—since associated type witnesses aren’t unique, there’s no straightforward way to determine the identity of T
in a call where you pass an arbitrary ID. E.g., if Car
and Truck
both conform to Vehicle
with Id == String
, the call to registerVehicleId("someID")
would be ambiguous.
If the intention that the call above wouldn’t compile because "someID"
wasn’t ‘derived’ from a vehicle conformance (i.e., it wasn’t the result of a call to Vehicle.id
) I think you can make this sound, but it would require a lot of type system complexity and it’s not entirely clear what benefit it would bring.