@@ -620,10 +620,8 @@ static bool checkConformanceToNSCopying(ASTContext &ctx, VarDecl *var,
620
620
auto dc = var->getDeclContext ();
621
621
auto proto = getNSCopyingProtocol (ctx, dc);
622
622
623
- // FIXME: Remove this usage of TypeChecker
624
- auto &TC = *(TypeChecker *) ctx.getLazyResolver ();
625
- if (!proto || !TC.conformsToProtocol (type, proto, dc, None)) {
626
- TC.diagnose (var->getLoc (), diag::nscopying_doesnt_conform);
623
+ if (!proto || !TypeChecker::conformsToProtocol (type, proto, dc, None)) {
624
+ ctx.Diags .diagnose (var->getLoc (), diag::nscopying_doesnt_conform);
627
625
return true ;
628
626
}
629
627
return false ;
@@ -1337,7 +1335,9 @@ static void synthesizeLazySetterBody(AbstractFunctionDecl *fn, void *context) {
1337
1335
underlyingStorage, ctx);
1338
1336
}
1339
1337
1340
- void TypeChecker::completeLazyVarImplementation (VarDecl *VD) {
1338
+ void swift::completeLazyVarImplementation (VarDecl *VD) {
1339
+ auto &Context = VD->getASTContext ();
1340
+
1341
1341
assert (VD->getAttrs ().hasAttribute <LazyAttr>());
1342
1342
assert (VD->getReadImpl () == ReadImplKind::Get);
1343
1343
assert (VD->getWriteImpl () == WriteImplKind::Set);
@@ -1406,13 +1406,13 @@ static bool wouldBeCircularSynthesis(AbstractStorageDecl *storage,
1406
1406
void swift::triggerAccessorSynthesis (TypeChecker &TC,
1407
1407
AbstractStorageDecl *storage) {
1408
1408
auto VD = dyn_cast<VarDecl>(storage);
1409
- maybeAddAccessorsToStorage (TC, storage);
1409
+ maybeAddAccessorsToStorage (storage);
1410
1410
1411
1411
// Synthesize accessors for lazy, all checking already been performed.
1412
1412
bool lazy = false ;
1413
1413
if (VD && VD->getAttrs ().hasAttribute <LazyAttr>() && !VD->isStatic () &&
1414
1414
!VD->getGetter ()->hasBody ()) {
1415
- TC. completeLazyVarImplementation (VD);
1415
+ completeLazyVarImplementation (VD);
1416
1416
lazy = true ;
1417
1417
}
1418
1418
@@ -1466,11 +1466,12 @@ static void maybeAddAccessorsToLazyVariable(VarDecl *var, ASTContext &ctx) {
1466
1466
// / Note that the parser synthesizes accessors in some cases:
1467
1467
// / - it synthesizes a getter and setter for an observing property
1468
1468
// / - it synthesizes a setter for get+mutableAddress
1469
- void swift::maybeAddAccessorsToStorage (TypeChecker &TC,
1470
- AbstractStorageDecl *storage) {
1469
+ void swift::maybeAddAccessorsToStorage (AbstractStorageDecl *storage) {
1470
+ auto &ctx = storage->getASTContext ();
1471
+
1471
1472
// Lazy properties require special handling.
1472
1473
if (storage->getAttrs ().hasAttribute <LazyAttr>()) {
1473
- maybeAddAccessorsToLazyVariable (cast<VarDecl>(storage), TC. Context );
1474
+ maybeAddAccessorsToLazyVariable (cast<VarDecl>(storage), ctx );
1474
1475
return ;
1475
1476
}
1476
1477
@@ -1487,7 +1488,7 @@ void swift::maybeAddAccessorsToStorage(TypeChecker &TC,
1487
1488
if (!dc->isTypeContext ()) {
1488
1489
// dynamic globals need accessors.
1489
1490
if (dc->isModuleScopeContext () && storage->isNativeDynamic ()) {
1490
- addTrivialAccessorsToStorage (storage, TC. Context );
1491
+ addTrivialAccessorsToStorage (storage, ctx );
1491
1492
return ;
1492
1493
}
1493
1494
// Fixed-layout global variables don't get accessors.
@@ -1502,12 +1503,13 @@ void swift::maybeAddAccessorsToStorage(TypeChecker &TC,
1502
1503
auto var = cast<VarDecl>(storage);
1503
1504
1504
1505
if (var->isLet ()) {
1505
- TC .diagnose (var->getLoc (),
1506
- diag::protocol_property_must_be_computed_var)
1506
+ ctx. Diags .diagnose (var->getLoc (),
1507
+ diag::protocol_property_must_be_computed_var)
1507
1508
.fixItReplace (var->getParentPatternBinding ()->getLoc (), " var" )
1508
1509
.fixItInsertAfter (var->getTypeLoc ().getLoc (), " { get }" );
1509
1510
} else {
1510
- auto diag = TC.diagnose (var->getLoc (), diag::protocol_property_must_be_computed);
1511
+ auto diag = ctx.Diags .diagnose (var->getLoc (),
1512
+ diag::protocol_property_must_be_computed);
1511
1513
auto braces = var->getBracesRange ();
1512
1514
1513
1515
if (braces.isValid ())
@@ -1517,14 +1519,14 @@ void swift::maybeAddAccessorsToStorage(TypeChecker &TC,
1517
1519
}
1518
1520
}
1519
1521
1520
- setProtocolStorageImpl (storage, TC. Context );
1522
+ setProtocolStorageImpl (storage, ctx );
1521
1523
return ;
1522
1524
1523
1525
// NSManaged properties on classes require special handling.
1524
1526
} else if (dc->getSelfClassDecl ()) {
1525
1527
auto var = dyn_cast<VarDecl>(storage);
1526
1528
if (var && var->getAttrs ().hasAttribute <NSManagedAttr>()) {
1527
- convertNSManagedStoredVarToComputed (var, TC. Context );
1529
+ convertNSManagedStoredVarToComputed (var, ctx );
1528
1530
return ;
1529
1531
}
1530
1532
@@ -1539,13 +1541,13 @@ void swift::maybeAddAccessorsToStorage(TypeChecker &TC,
1539
1541
if (auto sourceFile = dc->getParentSourceFile ())
1540
1542
if (sourceFile->Kind == SourceFileKind::SIL) {
1541
1543
if (storage->getGetter ()) {
1542
- addExpectedOpaqueAccessorsToStorage (storage, TC. Context );
1544
+ addExpectedOpaqueAccessorsToStorage (storage, ctx );
1543
1545
}
1544
1546
return ;
1545
1547
}
1546
1548
1547
1549
// Everything else gets mandatory accessors.
1548
- addTrivialAccessorsToStorage (storage, TC. Context );
1550
+ addTrivialAccessorsToStorage (storage, ctx );
1549
1551
}
1550
1552
1551
1553
static void synthesizeGetterBody (AccessorDecl *getter,
0 commit comments