@@ -513,7 +513,7 @@ namespace {
513
513
514
514
return SubstitutionMap::get (sig,
515
515
QueryTypeSubstitutionMap{subs},
516
- LookUpConformanceInModule (cs. DC ->getParentModule ()));
516
+ LookUpConformanceInModule (dc ->getParentModule ()));
517
517
}
518
518
519
519
// / Determine whether the given reference is to a method on
@@ -532,7 +532,7 @@ namespace {
532
532
// Determine the declaration selected for this overloaded reference.
533
533
auto &ctx = cs.getASTContext ();
534
534
535
- auto semantics = decl->getAccessSemanticsFromContext (cs. DC ,
535
+ auto semantics = decl->getAccessSemanticsFromContext (dc ,
536
536
/* isAccessOnSelf*/ false );
537
537
538
538
// If this is a member of a nominal type, build a reference to the
@@ -552,7 +552,7 @@ namespace {
552
552
// the protocol requirement with Self == the concrete type, and SILGen
553
553
// (or later) can devirtualize as appropriate.
554
554
auto conformance =
555
- TypeChecker::conformsToProtocol (baseTy, proto, cs. DC ->getParentModule ());
555
+ TypeChecker::conformsToProtocol (baseTy, proto, dc ->getParentModule ());
556
556
if (conformance.isConcrete ()) {
557
557
if (auto witness = conformance.getConcrete ()->getWitnessDecl (decl)) {
558
558
bool isMemberOperator = witness->getDeclContext ()->isTypeContext ();
@@ -859,7 +859,7 @@ namespace {
859
859
resultTy = cs.getType (result);
860
860
if (resultTy->hasOpenedExistentialWithRoot (record.Archetype )) {
861
861
Type erasedTy = resultTy->typeEraseOpenedArchetypesWithRoot (
862
- record.Archetype , cs. DC );
862
+ record.Archetype , dc );
863
863
auto range = result->getSourceRange ();
864
864
result = coerceToType (result, erasedTy, locator);
865
865
// FIXME: Implement missing tuple-to-tuple conversion
@@ -1288,7 +1288,7 @@ namespace {
1288
1288
// reference.
1289
1289
if (auto *TD = dyn_cast<TypeDecl>(member)) {
1290
1290
Type refType = simplifyType (openedType);
1291
- auto ref = TypeExpr::createForDecl (memberLoc, TD, cs. DC );
1291
+ auto ref = TypeExpr::createForDecl (memberLoc, TD, dc );
1292
1292
cs.setType (ref, refType);
1293
1293
auto *result = new (context) DotSyntaxBaseIgnoredExpr (
1294
1294
base, dotLoc, ref, refType);
@@ -1354,7 +1354,7 @@ namespace {
1354
1354
// Erase opened existentials from the type of the thunk; we're
1355
1355
// going to open the existential inside the thunk's body.
1356
1356
containerTy = containerTy->typeEraseOpenedArchetypesWithRoot (
1357
- knownOpened->second , cs. DC );
1357
+ knownOpened->second , dc );
1358
1358
selfTy = containerTy;
1359
1359
}
1360
1360
}
@@ -1414,7 +1414,7 @@ namespace {
1414
1414
// existential.
1415
1415
if (openedExistential) {
1416
1416
refType = refType->typeEraseOpenedArchetypesWithRoot (
1417
- baseTy->castTo <OpenedArchetypeType>(), cs. DC );
1417
+ baseTy->castTo <OpenedArchetypeType>(), dc );
1418
1418
}
1419
1419
1420
1420
cs.setType (ref, refType);
@@ -1555,7 +1555,7 @@ namespace {
1555
1555
if (knownOpened != solution.OpenedExistentialTypes .end ()) {
1556
1556
curryThunkTy = curryThunkTy
1557
1557
->typeEraseOpenedArchetypesWithRoot (
1558
- knownOpened->second , cs. DC )
1558
+ knownOpened->second , dc )
1559
1559
->castTo <FunctionType>();
1560
1560
}
1561
1561
@@ -1569,7 +1569,7 @@ namespace {
1569
1569
SourceLoc (),
1570
1570
/* argument label*/ SourceLoc (), Identifier (),
1571
1571
/* parameter name*/ SourceLoc (), context.Id_self ,
1572
- cs. DC );
1572
+ dc );
1573
1573
1574
1574
auto selfParamTy = selfParam.getPlainType ();
1575
1575
bool isLValue = selfParam.isInOut ();
@@ -2212,7 +2212,7 @@ namespace {
2212
2212
auto bridgedToObjectiveCConformance
2213
2213
= TypeChecker::conformsToProtocol (valueType,
2214
2214
bridgedProto,
2215
- cs. DC ->getParentModule ());
2215
+ dc ->getParentModule ());
2216
2216
2217
2217
FuncDecl *fn = nullptr ;
2218
2218
@@ -2473,7 +2473,7 @@ namespace {
2473
2473
ProtocolDecl *protocol = TypeChecker::getProtocol (
2474
2474
ctx, expr->getLoc (), KnownProtocolKind::ExpressibleByStringLiteral);
2475
2475
2476
- if (!TypeChecker::conformsToProtocol (type, protocol, cs. DC ->getParentModule ())) {
2476
+ if (!TypeChecker::conformsToProtocol (type, protocol, dc ->getParentModule ())) {
2477
2477
// If the type does not conform to ExpressibleByStringLiteral, it should
2478
2478
// be ExpressibleByExtendedGraphemeClusterLiteral.
2479
2479
protocol = TypeChecker::getProtocol (
@@ -2482,7 +2482,7 @@ namespace {
2482
2482
isStringLiteral = false ;
2483
2483
isGraphemeClusterLiteral = true ;
2484
2484
}
2485
- if (!TypeChecker::conformsToProtocol (type, protocol, cs. DC ->getParentModule ())) {
2485
+ if (!TypeChecker::conformsToProtocol (type, protocol, dc ->getParentModule ())) {
2486
2486
// ... or it should be ExpressibleByUnicodeScalarLiteral.
2487
2487
protocol = TypeChecker::getProtocol (
2488
2488
cs.getASTContext (), expr->getLoc (),
@@ -2597,7 +2597,7 @@ namespace {
2597
2597
assert (proto && " Missing string interpolation protocol?" );
2598
2598
2599
2599
auto conformance =
2600
- TypeChecker::conformsToProtocol (type, proto, cs. DC ->getParentModule ());
2600
+ TypeChecker::conformsToProtocol (type, proto, dc ->getParentModule ());
2601
2601
assert (conformance && " string interpolation type conforms to protocol" );
2602
2602
2603
2603
DeclName constrName (ctx, DeclBaseName::createConstructor (), argLabels);
@@ -2711,7 +2711,7 @@ namespace {
2711
2711
assert (proto && " Missing object literal protocol?" );
2712
2712
auto conformance =
2713
2713
TypeChecker::conformsToProtocol (conformingType, proto,
2714
- cs. DC ->getParentModule ());
2714
+ dc ->getParentModule ());
2715
2715
assert (conformance && " object literal type conforms to protocol" );
2716
2716
2717
2717
auto constrName = TypeChecker::getObjectLiteralConstructorName (ctx, expr);
@@ -2931,7 +2931,7 @@ namespace {
2931
2931
diagnoseBadInitRef = false ;
2932
2932
// Make sure the reference to 'self' occurs within an initializer.
2933
2933
if (!dyn_cast_or_null<ConstructorDecl>(
2934
- cs. DC ->getInnermostMethodContext ())) {
2934
+ dc ->getInnermostMethodContext ())) {
2935
2935
if (!SuppressDiagnostics)
2936
2936
de.diagnose (dotLoc, diag::init_delegation_outside_initializer);
2937
2937
return nullptr ;
@@ -2944,7 +2944,7 @@ namespace {
2944
2944
if (diagnoseBadInitRef) {
2945
2945
// Determine whether 'super' would have made sense as a base.
2946
2946
bool hasSuper = false ;
2947
- if (auto func = cs. DC ->getInnermostMethodContext ()) {
2947
+ if (auto func = dc ->getInnermostMethodContext ()) {
2948
2948
if (auto classDecl = func->getDeclContext ()->getSelfClassDecl ()) {
2949
2949
hasSuper = classDecl->hasSuperclass ();
2950
2950
}
@@ -2984,7 +2984,7 @@ namespace {
2984
2984
};
2985
2985
2986
2986
auto result =
2987
- TypeChecker::lookupUnqualified (cs. DC , UDE->getName (), UDE->getLoc ());
2987
+ TypeChecker::lookupUnqualified (dc , UDE->getName (), UDE->getLoc ());
2988
2988
assert (result && " names can't just disappear" );
2989
2989
// These should all come from the same place.
2990
2990
auto exampleInner = result.front ();
@@ -3066,7 +3066,7 @@ namespace {
3066
3066
auto &ctx = cs.getASTContext ();
3067
3067
auto baseMetaTy = baseTy->getAs <MetatypeType>();
3068
3068
auto baseInstTy = (baseMetaTy ? baseMetaTy->getInstanceType () : baseTy);
3069
- auto classTy = ctx.getBridgedToObjC (cs. DC , baseInstTy);
3069
+ auto classTy = ctx.getBridgedToObjC (dc , baseInstTy);
3070
3070
3071
3071
if (baseMetaTy) {
3072
3072
// FIXME: We're dropping side effects in the base here!
@@ -3328,7 +3328,7 @@ namespace {
3328
3328
3329
3329
auto conformance =
3330
3330
TypeChecker::conformsToProtocol (arrayTy, arrayProto,
3331
- cs. DC ->getParentModule ());
3331
+ dc ->getParentModule ());
3332
3332
assert (conformance && " Type does not conform to protocol?" );
3333
3333
3334
3334
DeclName name (ctx, DeclBaseName::createConstructor (),
@@ -3373,7 +3373,7 @@ namespace {
3373
3373
3374
3374
auto conformance =
3375
3375
TypeChecker::conformsToProtocol (dictionaryTy, dictionaryProto,
3376
- cs. DC ->getParentModule ());
3376
+ dc ->getParentModule ());
3377
3377
if (conformance.isInvalid ())
3378
3378
return nullptr ;
3379
3379
@@ -3498,7 +3498,7 @@ namespace {
3498
3498
// initializer.
3499
3499
Expr *unwrappedSubExpr = expr->getSubExpr ()->getSemanticsProvidingExpr ();
3500
3500
Type valueTy = cs.getType (unwrappedSubExpr)->getOptionalObjectType ();
3501
- auto inCtor = cast<ConstructorDecl>(cs. DC ->getInnermostMethodContext ());
3501
+ auto inCtor = cast<ConstructorDecl>(dc ->getInnermostMethodContext ());
3502
3502
if (valueTy && !inCtor->isFailable ()) {
3503
3503
bool isChaining;
3504
3504
auto *otherCtorRef = expr->getCalledConstructor (isChaining);
@@ -3588,7 +3588,7 @@ namespace {
3588
3588
SuppressDiagnostics ? CheckedCastContextKind::None
3589
3589
: CheckedCastContextKind::IsExpr;
3590
3590
auto castKind = TypeChecker::typeCheckCheckedCast (
3591
- fromType, toType, castContextKind, cs. DC , expr->getLoc (), sub,
3591
+ fromType, toType, castContextKind, dc , expr->getLoc (), sub,
3592
3592
castTypeRepr->getSourceRange ());
3593
3593
3594
3594
switch (castKind) {
@@ -4302,7 +4302,7 @@ namespace {
4302
4302
Expr *callExpr = CallExpr::createImplicit (ctx, fnRef, argList);
4303
4303
4304
4304
auto resultTy = TypeChecker::typeCheckExpression (
4305
- callExpr, cs. DC , /* contextualInfo=*/ {valueType, CTP_CannotFail});
4305
+ callExpr, dc , /* contextualInfo=*/ {valueType, CTP_CannotFail});
4306
4306
assert (resultTy && " Conversion cannot fail!" );
4307
4307
(void )resultTy;
4308
4308
@@ -4470,8 +4470,8 @@ namespace {
4470
4470
// Check that we requested a property getter or setter.
4471
4471
switch (E->getSelectorKind ()) {
4472
4472
case ObjCSelectorExpr::Method: {
4473
- bool isSettable = var->isSettable (cs. DC ) &&
4474
- var->isSetterAccessibleFrom (cs. DC );
4473
+ bool isSettable = var->isSettable (dc ) &&
4474
+ var->isSetterAccessibleFrom (dc );
4475
4475
auto primaryDiag =
4476
4476
de.diagnose (E->getLoc (), diag::expr_selector_expected_method,
4477
4477
isSettable, var->getName ());
@@ -4512,15 +4512,15 @@ namespace {
4512
4512
4513
4513
case ObjCSelectorExpr::Setter:
4514
4514
// Make sure we actually have a setter.
4515
- if (!var->isSettable (cs. DC )) {
4515
+ if (!var->isSettable (dc )) {
4516
4516
de.diagnose (E->getLoc (), diag::expr_selector_property_not_settable,
4517
4517
var->getDescriptiveKind (), var->getName ());
4518
4518
de.diagnose (var, diag::decl_declared_here, var->getName ());
4519
4519
return E;
4520
4520
}
4521
4521
4522
4522
// Make sure the setter is accessible.
4523
- if (!var->isSetterAccessibleFrom (cs. DC )) {
4523
+ if (!var->isSetterAccessibleFrom (dc )) {
4524
4524
de.diagnose (E->getLoc (),
4525
4525
diag::expr_selector_property_setter_inaccessible,
4526
4526
var->getDescriptiveKind (), var->getName ());
@@ -4802,7 +4802,7 @@ namespace {
4802
4802
FunctionType::get ({FunctionType::Param (baseTy)}, leafTy, closureInfo);
4803
4803
auto closure = new (ctx)
4804
4804
AutoClosureExpr (/* set body later*/ nullptr , leafTy,
4805
- discriminator, cs. DC );
4805
+ discriminator, dc );
4806
4806
auto param = new (ctx) ParamDecl (
4807
4807
SourceLoc (),
4808
4808
/* argument label*/ SourceLoc (), Identifier (),
@@ -4821,7 +4821,7 @@ namespace {
4821
4821
closureTy, outerClosureInfo);
4822
4822
auto outerClosure = new (ctx)
4823
4823
AutoClosureExpr (/* set body later*/ nullptr , closureTy,
4824
- discriminator, cs. DC );
4824
+ discriminator, dc );
4825
4825
auto outerParam =
4826
4826
new (ctx) ParamDecl (SourceLoc (),
4827
4827
/* argument label*/ SourceLoc (), Identifier (),
@@ -4989,7 +4989,7 @@ namespace {
4989
4989
// with all of the generic parameters resolved.
4990
4990
auto hashableConformance =
4991
4991
TypeChecker::conformsToProtocol (indexType, hashable,
4992
- cs. DC ->getParentModule ());
4992
+ dc ->getParentModule ());
4993
4993
assert (hashableConformance);
4994
4994
4995
4995
conformances.push_back (hashableConformance);
@@ -5270,7 +5270,7 @@ Expr *ExprRewriter::coerceSuperclass(Expr *expr, Type toType) {
5270
5270
// concrete superclass.
5271
5271
auto fromArchetype =
5272
5272
OpenedArchetypeType::getAny (fromType->getCanonicalType (),
5273
- cs. DC ->getGenericSignatureOfContext ());
5273
+ dc ->getGenericSignatureOfContext ());
5274
5274
5275
5275
auto *archetypeVal = cs.cacheType (new (ctx) OpaqueValueExpr (
5276
5276
expr->getSourceRange (), fromArchetype));
@@ -6023,7 +6023,8 @@ static Expr *buildElementConversion(ExprRewriter &rewriter,
6023
6023
auto &cs = rewriter.getConstraintSystem ();
6024
6024
if (bridged &&
6025
6025
TypeChecker::typeCheckCheckedCast (srcType, destType,
6026
- CheckedCastContextKind::None, cs.DC ,
6026
+ CheckedCastContextKind::None,
6027
+ rewriter.dc ,
6027
6028
SourceLoc (), nullptr , SourceRange ())
6028
6029
!= CheckedCastKind::Coercion) {
6029
6030
if (auto conversion =
@@ -6279,7 +6280,7 @@ Expr *ExprRewriter::coerceExistential(Expr *expr, Type toType,
6279
6280
6280
6281
auto conformances =
6281
6282
collectExistentialConformances (fromInstanceType, toInstanceType,
6282
- cs. DC ->getParentModule ());
6283
+ dc ->getParentModule ());
6283
6284
6284
6285
// Use the requirements of any parameterized protocols to build out fake
6285
6286
// argument conversions that can be used to infer opaque types.
@@ -6336,7 +6337,7 @@ Expr *ExprRewriter::coerceExistential(Expr *expr, Type toType,
6336
6337
// For existential-to-existential coercions, open the source existential.
6337
6338
if (fromType->isAnyExistentialType ()) {
6338
6339
fromType = OpenedArchetypeType::getAny (fromType->getCanonicalType (),
6339
- cs. DC ->getGenericSignatureOfContext ());
6340
+ dc ->getGenericSignatureOfContext ());
6340
6341
6341
6342
auto *archetypeVal = cs.cacheType (
6342
6343
new (ctx) OpaqueValueExpr (expr->getSourceRange (), fromType));
@@ -6500,7 +6501,7 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
6500
6501
auto hashable = ctx.getProtocol (KnownProtocolKind::Hashable);
6501
6502
auto conformance =
6502
6503
TypeChecker::conformsToProtocol (
6503
- cs.getType (expr), hashable, cs. DC ->getParentModule ());
6504
+ cs.getType (expr), hashable, dc ->getParentModule ());
6504
6505
assert (conformance && " must conform to Hashable" );
6505
6506
6506
6507
return cs.cacheType (
@@ -6759,7 +6760,7 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
6759
6760
// leave an explicit escape to noescape cast here such that SILGen can skip
6760
6761
// the cast and emit a code for the escaping function.
6761
6762
bool isInDefaultArgumentContext = false ;
6762
- if (auto initalizerCtx = dyn_cast<Initializer>(cs. DC ))
6763
+ if (auto initalizerCtx = dyn_cast<Initializer>(dc ))
6763
6764
isInDefaultArgumentContext = (initalizerCtx->getInitializerKind () ==
6764
6765
InitializerKind::DefaultArgument);
6765
6766
auto toEI = toFunc->getExtInfo ();
@@ -7209,7 +7210,7 @@ Expr *ExprRewriter::convertLiteralInPlace(
7209
7210
// initialize via the builtin protocol.
7210
7211
if (builtinProtocol) {
7211
7212
auto builtinConformance = TypeChecker::conformsToProtocol (
7212
- type, builtinProtocol, cs. DC ->getParentModule ());
7213
+ type, builtinProtocol, dc ->getParentModule ());
7213
7214
if (builtinConformance) {
7214
7215
// Find the witness that we'll use to initialize the type via a builtin
7215
7216
// literal.
@@ -7233,7 +7234,7 @@ Expr *ExprRewriter::convertLiteralInPlace(
7233
7234
// This literal type must conform to the (non-builtin) protocol.
7234
7235
assert (protocol && " requirements should have stopped recursion" );
7235
7236
auto conformance = TypeChecker::conformsToProtocol (type, protocol,
7236
- cs. DC ->getParentModule ());
7237
+ dc ->getParentModule ());
7237
7238
assert (conformance && " must conform to literal protocol" );
7238
7239
7239
7240
// Dig out the literal type and perform a builtin literal conversion to it.
@@ -7358,7 +7359,7 @@ std::pair<Expr *, ArgumentList *> ExprRewriter::buildDynamicCallable(
7358
7359
ctx.getProtocol (KnownProtocolKind::ExpressibleByDictionaryLiteral);
7359
7360
auto conformance =
7360
7361
TypeChecker::conformsToProtocol (argumentType, dictLitProto,
7361
- cs. DC ->getParentModule ());
7362
+ dc ->getParentModule ());
7362
7363
auto keyType = conformance.getTypeWitnessByName (argumentType, ctx.Id_Key );
7363
7364
auto valueType =
7364
7365
conformance.getTypeWitnessByName (argumentType, ctx.Id_Value );
@@ -8478,14 +8479,16 @@ static Optional<SolutionApplicationTarget> applySolutionToForEachStmt(
8478
8479
8479
8480
resultTarget.setExpr (sequence);
8480
8481
8482
+ auto *dc = target.getDeclContext ();
8483
+
8481
8484
// Get the conformance of the sequence type to the Sequence protocol.
8482
8485
auto stmt = forEachStmtInfo.stmt ;
8483
8486
auto sequenceProto = TypeChecker::getProtocol (
8484
8487
cs.getASTContext (), stmt->getForLoc (),
8485
8488
stmt->getAwaitLoc ().isValid () ?
8486
8489
KnownProtocolKind::AsyncSequence : KnownProtocolKind::Sequence);
8487
8490
auto sequenceConformance = TypeChecker::conformsToProtocol (
8488
- forEachStmtInfo.sequenceType , sequenceProto, cs. DC ->getParentModule ());
8491
+ forEachStmtInfo.sequenceType , sequenceProto, dc ->getParentModule ());
8489
8492
assert (!sequenceConformance.isInvalid () &&
8490
8493
" Couldn't find sequence conformance" );
8491
8494
@@ -8503,7 +8506,6 @@ static Optional<SolutionApplicationTarget> applySolutionToForEachStmt(
8503
8506
}
8504
8507
8505
8508
// Apply the solution to the filtering condition, if there is one.
8506
- auto dc = target.getDeclContext ();
8507
8509
if (forEachStmtInfo.whereExpr ) {
8508
8510
auto *boolDecl = dc->getASTContext ().getBoolDecl ();
8509
8511
assert (boolDecl);
0 commit comments