hylo icon indicating copy to clipboard operation
hylo copied to clipboard

Gather requirements on associated types in top-level environments

Open kyouko-taiga opened this issue 3 years ago • 0 comments

The generic environment of a declaration is responsible for tracking conformance and equivalence relationships on the generic type parameters associated with the declaration. We should also track relationships on associated types, so that we can handle situations where two views are defining the same abstract type.

view V {
  type A
  fun foo() -> A
}

view U {
  type A
  fun bar() -> A
}

// This function should type-check.
fun f<X where X: V, U>(x: X) {
  var a = x.foo()
  a = x.bar()
}

Gathering all relationships in the declaration's environment will also improve the efficiency of lookup requests on associated type. For instance, we'll be able to check the conformance table using X::A as a key rather than going through all of A's conformance and look for Self::A in every one of them.

kyouko-taiga avatar Dec 10 '21 12:12 kyouko-taiga