@@ -1351,14 +1351,14 @@ namespace {
1351
1351
DeclContext *dc, Identifier name) {
1352
1352
// The only (current) difference between swift_newtype(struct) and
1353
1353
// 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
1355
1355
// closed, and if constructed from a rawValue, should be very explicit.
1356
1356
bool unlabeledCtor = false ;
1357
1357
1358
1358
switch (newtypeAttr->getNewtypeKind ()) {
1359
1359
case clang::SwiftNewtypeAttr::NK_Enum:
1360
1360
unlabeledCtor = false ;
1361
- // TODO: import as closed enum instead
1361
+ // TODO: import as enum instead
1362
1362
break ;
1363
1363
1364
1364
case clang::SwiftNewtypeAttr::NK_Struct:
@@ -1805,10 +1805,10 @@ namespace {
1805
1805
1806
1806
//
1807
1807
// 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);
1812
1812
computedVar->setImplicit ();
1813
1813
computedVar->setAccessibility (Accessibility::Public);
1814
1814
computedVar->setSetterAccessibility (Accessibility::Private);
@@ -1823,15 +1823,19 @@ namespace {
1823
1823
cxt, SourceLoc (), StaticSpellingKind::None, SourceLoc (),
1824
1824
computedVarPattern, nullptr , structDecl);
1825
1825
1826
+ // Don't bother synthesizing the body if we've already finished
1827
+ // type-checking.
1828
+ bool wantBody = !Impl.hasFinishedTypeChecking ();
1829
+
1826
1830
auto init = createRawValueBridgingConstructor (
1827
1831
structDecl, computedVar, storedVar,
1828
- /* wantLabel*/ true , !Impl. hasFinishedTypeChecking () );
1832
+ /* wantLabel*/ true , wantBody );
1829
1833
1830
1834
ConstructorDecl *unlabeledCtor = nullptr ;
1831
1835
if (makeUnlabeledValueInit)
1832
1836
unlabeledCtor = createRawValueBridgingConstructor (
1833
1837
structDecl, computedVar, storedVar,
1834
- /* wantLabel*/ false , !Impl. hasFinishedTypeChecking () );
1838
+ /* wantLabel*/ false , wantBody );
1835
1839
1836
1840
structDecl->setHasDelayedMembers ();
1837
1841
if (unlabeledCtor)
0 commit comments