-
Notifications
You must be signed in to change notification settings - Fork 178
Open
Labels
Description
Polymorphic functions are a little difficult. Suppose the following ApplySig happens: Trait.sig(t). Then we must look up the enclosing function and
- Check there is an instance of
Traitdefined - If
tor the result of applyingTrait.sigtotcontains an associated type ofTraitthen we must check if there is an equality constraint of the formElm[t] ~ t2and return that (cant2be polymorphic?) - Lastly, if that is not the case we should probably just check that
Elm[t]for all instances ofTraitis "upcastable" to the desired type.
The Instances phase contains safe ways to deal with trait / instance lookup.
See discussion in #12124