Skip to content

Commit 5dfeb4c

Browse files
authored
[ModuleInterface] Don't setAddedImplicitInitializers() in Parse (#18933)
...wait until Sema. Parse shouldn't be messing with Sema-level properties in the decls it builds. No functionality change.
1 parent 809764f commit 5dfeb4c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5481,8 +5481,6 @@ ParserResult<EnumDecl> Parser::parseDeclEnum(ParseDeclOptions Flags,
54815481
{ }, nullptr, CurDeclContext);
54825482
setLocalDiscriminator(ED);
54835483
ED->getAttrs() = Attributes;
5484-
if (SF.Kind == SourceFileKind::Interface)
5485-
ED->setAddedImplicitInitializers();
54865484

54875485
ContextChange CC(*this, ED);
54885486

@@ -5755,8 +5753,6 @@ ParserResult<StructDecl> Parser::parseDeclStruct(ParseDeclOptions Flags,
57555753
CurDeclContext);
57565754
setLocalDiscriminator(SD);
57575755
SD->getAttrs() = Attributes;
5758-
if (SF.Kind == SourceFileKind::Interface)
5759-
SD->setAddedImplicitInitializers();
57605756

57615757
ContextChange CC(*this, SD);
57625758

@@ -5845,8 +5841,6 @@ ParserResult<ClassDecl> Parser::parseDeclClass(ParseDeclOptions Flags,
58455841
{ }, nullptr, CurDeclContext);
58465842
setLocalDiscriminator(CD);
58475843
CD->getAttrs() = Attributes;
5848-
if (SF.Kind == SourceFileKind::Interface)
5849-
CD->setAddedImplicitInitializers();
58505844

58515845
ContextChange CC(*this, CD);
58525846

lib/Sema/TypeCheckDecl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5263,6 +5263,14 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
52635263
if (decl->isInvalid())
52645264
return;
52655265

5266+
// Don't add implicit constructors in textual interfaces.
5267+
if (auto *SF = decl->getParentSourceFile()) {
5268+
if (SF->Kind == SourceFileKind::Interface) {
5269+
decl->setAddedImplicitInitializers();
5270+
return;
5271+
}
5272+
}
5273+
52665274
// Bail out if we're validating one of our constructors already; we'll
52675275
// revisit the issue later.
52685276
if (isa<ClassDecl>(decl)) {

0 commit comments

Comments
 (0)