Commit Graph

3 Commits

Author SHA1 Message Date
Slava Pestov
64f12ff936 Sema: Allow protocols with 'Self' constraints again
These two declarations are now equivalent:

  protocol P : SomeClass { ... }
  protocol P where Self : SomeClass { ... }

There's a long, complicated story here:

- Swift 4.2 rejected classes in the inheritance clause of a
  protocol, but it accepted the 'where' clause form, even
  though it didn't always work and would sometimes crash

- Recently we got the inheritance clause form working, and
  added a diagnostic to ban the 'where' clause form, because
  we thought it would simplify name lookup to not have to
  consider the 'where' clause

- However, we already had to support looking at the 'where'
  clause from name lookup anyway, because you could write

  extension P where Self : SomeClass { ... }

- It turns out that despite the crashes, protocols with
  'Self' constraints were already common enough that it was
  worth supporting the existing behavior, instead of banning
  it

Fixes <rdar://problem/43028442>.
2018-10-12 03:06:52 -07:00
Slava Pestov
eeb5c953aa Sema: Ban protocol where clauses that place constraints on 'Self'
These will never work properly because of phase ordering issues with
the current declaration checker design. Since we can always express
the same thing with the protocol inheritance clause instead, just
diagnose this as an error instead of trying to hack around it.

Fixes <rdar://problem/38077232>, <https://bugs.swift.org/browse/SR-5581>.
2018-07-10 00:34:02 -07:00
Doug Gregor
4860607700 [GSB] Record unresolved potential archetypes as delayed requirements.
Whenever we form a potential archetype that is unresolved (because it
names a member wasn't known at the time the potential archetype was
formed), create a corresponding delayed requirement to resolve the
potential archetype. This ensures that all potential archetypes get a
chance to be resolve, fixing the

  nested type should have matched associated type

assertion in rdar://problem/31401161 (and others).
2017-06-19 22:20:21 -07:00