Skip to content

Commit 1a9c2e6

Browse files
committed
[Parse] InitAccessors: Parse limited representation of init accessor in SIL context
1 parent 1ece483 commit 1a9c2e6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7281,7 +7281,7 @@ static void diagnoseRedundantAccessors(Parser &P, SourceLoc loc,
72817281
/*already*/ true);
72827282
}
72837283

7284-
static bool isAllowedInProtocolRequirement(AccessorKind kind) {
7284+
static bool isAllowedInProtocolRequirement(AccessorKind kind, bool forSIL) {
72857285
switch (kind) {
72867286
case AccessorKind::Get:
72877287
case AccessorKind::Set:
@@ -7293,8 +7293,10 @@ static bool isAllowedInProtocolRequirement(AccessorKind kind) {
72937293
case AccessorKind::DidSet:
72947294
case AccessorKind::Read:
72957295
case AccessorKind::Modify:
7296-
case AccessorKind::Init:
72977296
return false;
7297+
7298+
case AccessorKind::Init:
7299+
return forSIL;
72987300
}
72997301
llvm_unreachable("bad accessor kind");
73007302
}
@@ -7688,7 +7690,8 @@ ParserStatus Parser::parseGetSet(ParseDeclOptions Flags, ParameterList *Indices,
76887690

76897691
// For now, immediately reject illegal accessors in protocols just to
76907692
// avoid having to deal with them everywhere.
7691-
if (parsingLimitedSyntax && !isAllowedInProtocolRequirement(Kind)) {
7693+
if (parsingLimitedSyntax &&
7694+
!isAllowedInProtocolRequirement(Kind, SF.Kind == SourceFileKind::SIL)) {
76927695
diagnose(Loc, diag::expected_getset_in_protocol);
76937696
continue;
76947697
}

0 commit comments

Comments
 (0)