Skip to content

Commit eafc04d

Browse files
committed
---
yaml --- r: 341757 b: refs/heads/rxwei-patch-1 c: 5ee4b06 h: refs/heads/master i: 341755: cb57bdf
1 parent d2b5de9 commit eafc04d

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 4820d16d7fd6c661035c5a26ab241d5b44d8337b
1018+
refs/heads/rxwei-patch-1: 5ee4b06edbbee771731711e04025540753b05292
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3777,7 +3777,7 @@ DestructorDecl *ClassDecl::getDestructor() {
37773777

37783778
/// Synthesizer callback for an empty implicit function body.
37793779
static std::pair<BraceStmt *, bool>
3780-
synthesizeEmplyFunctionBody(AbstractFunctionDecl *afd, void *context) {
3780+
synthesizeEmptyFunctionBody(AbstractFunctionDecl *afd, void *context) {
37813781
ASTContext &ctx = afd->getASTContext();
37823782
return { BraceStmt::create(ctx, afd->getLoc(), { }, afd->getLoc(), true),
37833783
/*isTypeChecked=*/true };
@@ -3794,7 +3794,7 @@ void ClassDecl::addImplicitDestructor() {
37943794
DD->setValidationToChecked();
37953795

37963796
// Synthesize an empty body for the destructor as needed.
3797-
DD->setBodySynthesizer(synthesizeEmplyFunctionBody);
3797+
DD->setBodySynthesizer(synthesizeEmptyFunctionBody);
37983798
addMember(DD);
37993799

38003800
// Propagate access control and versioned-ness.

branches/rxwei-patch-1/lib/Sema/TypeCheckDecl.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5599,6 +5599,16 @@ void TypeChecker::synthesizeMemberForLookup(NominalTypeDecl *target,
55995599
}
56005600
}
56015601

5602+
/// Synthesizer callback for a function body consisting of "return".
5603+
static std::pair<BraceStmt *, bool>
5604+
synthesizeSingleReturnFunctionBody(AbstractFunctionDecl *afd, void *) {
5605+
ASTContext &ctx = afd->getASTContext();
5606+
SmallVector<ASTNode, 1> stmts;
5607+
stmts.push_back(new (ctx) ReturnStmt(afd->getLoc(), nullptr));
5608+
return { BraceStmt::create(ctx, afd->getLoc(), stmts, afd->getLoc(), true),
5609+
/*isTypeChecked=*/true };
5610+
}
5611+
56025612
void TypeChecker::defineDefaultConstructor(NominalTypeDecl *decl) {
56035613
FrontendStatsTracer StatsTracer(Context.Stats, "define-default-ctor", decl);
56045614
PrettyStackTraceDecl stackTrace("defining default constructor for",
@@ -5624,11 +5634,8 @@ void TypeChecker::defineDefaultConstructor(NominalTypeDecl *decl) {
56245634
// Add the constructor.
56255635
decl->addMember(ctor);
56265636

5627-
// Create an empty body for the default constructor.
5628-
SmallVector<ASTNode, 1> stmts;
5629-
stmts.push_back(new (Context) ReturnStmt(decl->getLoc(), nullptr));
5630-
ctor->setBody(BraceStmt::create(Context, SourceLoc(), stmts, SourceLoc()),
5631-
AbstractFunctionDecl::BodyKind::TypeChecked);
5637+
// Lazily synthesize an empty body for the default constructor.
5638+
ctor->setBodySynthesizer(synthesizeSingleReturnFunctionBody);
56325639
}
56335640

56345641
static void validateAttributes(TypeChecker &TC, Decl *D) {

0 commit comments

Comments
 (0)