Allow initializer requirements on protocols and check conformance to them.

Swift SVN r14320
This commit is contained in:
Doug Gregor
2014-02-24 23:17:09 +00:00
parent 048c67350b
commit 96be672daf
6 changed files with 64 additions and 18 deletions

View File

@@ -2789,8 +2789,7 @@ Parser::parseDeclConstructor(ParseDeclOptions Flags,
assert(Tok.is(tok::kw_init));
SourceLoc ConstructorLoc = consumeToken();
const bool ConstructorsNotAllowed =
!(Flags & PD_HasContainerType) || (Flags & PD_InProtocol);
const bool ConstructorsNotAllowed = !(Flags & PD_HasContainerType);
// Reject constructors outside of types.
if (ConstructorsNotAllowed) {
@@ -2836,7 +2835,7 @@ Parser::parseDeclConstructor(ParseDeclOptions Flags,
if (SignatureStatus.hasCodeCompletion())
CodeCompletion->setDelayedParsedDecl(CD);
if (ConstructorsNotAllowed) {
if (ConstructorsNotAllowed || SignatureStatus.isError()) {
// Tell the type checker not to touch this constructor.
CD->setInvalid();
}