AssociatedTypes lookup won't work for subtypes in current scheme. #11
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The current strategy for looking up associated types will fail once we want two distinct types, like DenseMatrix and Matrix, such that one extends the other.
That's because there is one key for each type, and in the type for that key it specifies (each of) the associated types, as well as the type itself. The lookup then considers just the keys corresponding to types that the parameter type extends, and essentially unions them all (by indexing the whole AssociatedTypes interface by the matching keys).
But this means that if Sub extends Sup but we want them both to be types in the system, then we have in AssociatedTypes:
Now just consider looking up the associated type
type
of Sub. We want it to be Sub. But Sub extends both the Sup and Sub types, so both of those keys match, so the lookup returns the union of Sup and Sub, which is just Sup, not sub.It looks like we need to switch to taking the intersection of all of the clauses where the given type extends the associated type. I think that will work.