SE-0352: Implicitly Opened Existentials

Yes, this issue was introduced by SE-0309. Here's a self-contained example that doesn't use anything from this proposal:

protocol P {
  associatedtype A
}

protocol Q {
  associatedtype B: P where B.A == Int

  func f() -> B
}

func g(q: any Q) {
  let a = g.f()  // okay: a has type `any P`
}

Whatever solution we arrive at should apply equally to this proposal and SE-0309, but it's going to end up changing somewhat if the constrained existentials pitch becomes an accepted proposal, since now we'll be able to express the existential result with the bounds. There's a procedural question for the Core Team here as to whether this proposal should try to address this problem or whether they'd prefer a separate amendment to SE-0309, which is at the "root" of this issue and which this proposal builds upon.

I'd also love to hear the opinions of the authors of SE-0309: @anthonylatsis, @filip-sakel, and @suyashsrijan.

Doug

2 Likes