Skip to content

Consider associated types in checked_cast #12126

@jaschdoc

Description

@jaschdoc

Polymorphic functions are a little difficult. Suppose the following ApplySig happens: Trait.sig(t). Then we must look up the enclosing function and

  1. Check there is an instance of Trait defined
  2. If t or the result of applying Trait.sig to t contains an associated type of Trait then we must check if there is an equality constraint of the form Elm[t] ~ t2 and return that (can t2 be polymorphic?)
  3. Lastly, if that is not the case we should probably just check that Elm[t] for all instances of Trait is "upcastable" to the desired type.

The Instances phase contains safe ways to deal with trait / instance lookup.

See discussion in #12124

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions