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>.
This commit is contained in:
Slava Pestov
2018-07-09 22:27:22 -07:00
parent e3ff63a289
commit eeb5c953aa
7 changed files with 55 additions and 6 deletions

View File

@@ -1833,6 +1833,10 @@ WARNING(protocol_composition_with_postfix,none,
"protocol-constrained type with postfix '%0' is ambiguous "
"and will be rejected in future version of Swift", (StringRef))
ERROR(protocol_where_clause_self_requirement,none,
"constraint with subject type of 'Self' is not supported; "
"consider adding requirement to protocol inheritance clause instead", ())
ERROR(invalid_protocol_composition_member,none,
"non-protocol, non-class type %0 cannot be used within a "
"protocol-constrained type", (Type))