Skip to content

Commit bd3e590

Browse files
committed
[Clang importer] Comments and cleanup. NFC
1 parent 12ec07f commit bd3e590

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,14 +1351,14 @@ namespace {
13511351
DeclContext *dc, Identifier name) {
13521352
// The only (current) difference between swift_newtype(struct) and
13531353
// swift_newtype(enum), until we can get real enum support, is that enums
1354-
// have no un-labeld inits(). This is because enums are to be considered
1354+
// have no un-labeled inits(). This is because enums are to be considered
13551355
// closed, and if constructed from a rawValue, should be very explicit.
13561356
bool unlabeledCtor = false;
13571357

13581358
switch (newtypeAttr->getNewtypeKind()) {
13591359
case clang::SwiftNewtypeAttr::NK_Enum:
13601360
unlabeledCtor = false;
1361-
// TODO: import as closed enum instead
1361+
// TODO: import as enum instead
13621362
break;
13631363

13641364
case clang::SwiftNewtypeAttr::NK_Struct:
@@ -1805,10 +1805,10 @@ namespace {
18051805

18061806
//
18071807
// Create a computed value variable
1808-
auto computedVar =
1809-
new (cxt) VarDecl(/*static*/ false,
1810-
/*IsLet*/ false, SourceLoc(), computedVarName,
1811-
bridgedType, structDecl);
1808+
auto computedVar = new (cxt) VarDecl(/*static*/ false,
1809+
/*IsLet*/ false, SourceLoc(),
1810+
computedVarName, bridgedType,
1811+
structDecl);
18121812
computedVar->setImplicit();
18131813
computedVar->setAccessibility(Accessibility::Public);
18141814
computedVar->setSetterAccessibility(Accessibility::Private);
@@ -1823,15 +1823,19 @@ namespace {
18231823
cxt, SourceLoc(), StaticSpellingKind::None, SourceLoc(),
18241824
computedVarPattern, nullptr, structDecl);
18251825

1826+
// Don't bother synthesizing the body if we've already finished
1827+
// type-checking.
1828+
bool wantBody = !Impl.hasFinishedTypeChecking();
1829+
18261830
auto init = createRawValueBridgingConstructor(
18271831
structDecl, computedVar, storedVar,
1828-
/*wantLabel*/ true, !Impl.hasFinishedTypeChecking());
1832+
/*wantLabel*/ true, wantBody);
18291833

18301834
ConstructorDecl *unlabeledCtor = nullptr;
18311835
if (makeUnlabeledValueInit)
18321836
unlabeledCtor = createRawValueBridgingConstructor(
18331837
structDecl, computedVar, storedVar,
1834-
/*wantLabel*/ false, !Impl.hasFinishedTypeChecking());
1838+
/*wantLabel*/ false, wantBody);
18351839

18361840
structDecl->setHasDelayedMembers();
18371841
if (unlabeledCtor)

0 commit comments

Comments
 (0)