@@ -896,9 +896,9 @@ static bool isBetterMatch(DeclContext *dc, ValueDecl *requirement,
896
896
return false ;
897
897
}
898
898
899
- WitnessChecker::WitnessChecker (TypeChecker &tc , ProtocolDecl *proto,
899
+ WitnessChecker::WitnessChecker (ASTContext &ctx , ProtocolDecl *proto,
900
900
Type adoptee, DeclContext *dc)
901
- : TC(tc ), Proto(proto), Adoptee(adoptee), DC(dc) {}
901
+ : Context(ctx ), Proto(proto), Adoptee(adoptee), DC(dc) {}
902
902
903
903
void
904
904
WitnessChecker::lookupValueWitnessesViaImplementsAttr (
@@ -981,6 +981,8 @@ bool WitnessChecker::findBestWitness(
981
981
bool anyFromUnconstrainedExtension;
982
982
numViable = 0 ;
983
983
984
+ // FIXME: Remove dependnecy on the lazy resolver.
985
+ auto *TC = static_cast <TypeChecker *>(getASTContext ().getLazyResolver ());
984
986
for (Attempt attempt = Regular; numViable == 0 && attempt != Done;
985
987
attempt = static_cast <Attempt>(attempt + 1 )) {
986
988
SmallVector<ValueDecl *, 4 > witnesses;
@@ -1028,8 +1030,8 @@ bool WitnessChecker::findBestWitness(
1028
1030
continue ;
1029
1031
}
1030
1032
1031
- auto match = matchWitness (TC, ReqEnvironmentCache, Proto, conformance, DC ,
1032
- requirement, witness);
1033
+ auto match = matchWitness (* TC, ReqEnvironmentCache, Proto, conformance,
1034
+ DC, requirement, witness);
1033
1035
if (match.isViable ()) {
1034
1036
++numViable;
1035
1037
bestIdx = matches.size ();
@@ -1053,7 +1055,7 @@ bool WitnessChecker::findBestWitness(
1053
1055
if (conformance && !conformance->isInvalid ()) {
1054
1056
if (auto *SF = DC->getParentSourceFile ()) {
1055
1057
if (SF->Kind == SourceFileKind::Interface) {
1056
- auto match = matchWitness (TC, ReqEnvironmentCache, Proto,
1058
+ auto match = matchWitness (* TC, ReqEnvironmentCache, Proto,
1057
1059
conformance, DC, requirement, requirement);
1058
1060
assert (match.isViable ());
1059
1061
numViable = 1 ;
@@ -1509,8 +1511,9 @@ checkIndividualConformance(NormalProtocolConformance *conformance,
1509
1511
// conformance is invalid for other reasons, so emit diagnosis now.
1510
1512
if (revivedMissingWitnesses.empty ()) {
1511
1513
// Emit any delayed diagnostics.
1512
- ConformanceChecker (TC, conformance, MissingWitnesses, false ).
1513
- emitDelayedDiags ();
1514
+ ConformanceChecker (getASTContext (), conformance, MissingWitnesses,
1515
+ false )
1516
+ .emitDelayedDiags ();
1514
1517
}
1515
1518
}
1516
1519
@@ -1712,7 +1715,7 @@ checkIndividualConformance(NormalProtocolConformance *conformance,
1712
1715
return conformance;
1713
1716
1714
1717
// The conformance checker we're using.
1715
- AllUsedCheckers.emplace_back (TC , conformance, MissingWitnesses);
1718
+ AllUsedCheckers.emplace_back (getASTContext () , conformance, MissingWitnesses);
1716
1719
MissingWitnesses.insert (revivedMissingWitnesses.begin (),
1717
1720
revivedMissingWitnesses.end ());
1718
1721
@@ -2201,16 +2204,15 @@ diagnoseMatch(ModuleDecl *module, NormalProtocolConformance *conformance,
2201
2204
}
2202
2205
2203
2206
ConformanceChecker::ConformanceChecker (
2204
- TypeChecker &tc, NormalProtocolConformance *conformance,
2205
- llvm::SetVector<ValueDecl*> &GlobalMissingWitnesses,
2206
- bool suppressDiagnostics)
2207
- : WitnessChecker(tc, conformance->getProtocol (),
2208
- conformance->getType(),
2207
+ ASTContext &ctx, NormalProtocolConformance *conformance,
2208
+ llvm::SetVector<ValueDecl *> &GlobalMissingWitnesses,
2209
+ bool suppressDiagnostics)
2210
+ : WitnessChecker(ctx, conformance->getProtocol (), conformance->getType(),
2209
2211
conformance->getDeclContext()),
2210
2212
Conformance(conformance), Loc(conformance->getLoc ()),
2211
2213
GlobalMissingWitnesses(GlobalMissingWitnesses),
2212
2214
LocalMissingWitnessesStartIndex(GlobalMissingWitnesses.size()),
2213
- SuppressDiagnostics(suppressDiagnostics) { }
2215
+ SuppressDiagnostics(suppressDiagnostics) {}
2214
2216
2215
2217
ArrayRef<AssociatedTypeDecl *>
2216
2218
ConformanceChecker::getReferencedAssociatedTypes (ValueDecl *req) {
@@ -2562,8 +2564,9 @@ void ConformanceChecker::recordTypeWitness(AssociatedTypeDecl *assocType,
2562
2564
2563
2565
auto overriddenRootConformance =
2564
2566
overriddenConformance.getConcrete ()->getRootNormalConformance ();
2565
- ConformanceChecker (TC, overriddenRootConformance, GlobalMissingWitnesses)
2566
- .recordTypeWitness (overridden, type, typeDecl);
2567
+ ConformanceChecker (getASTContext (), overriddenRootConformance,
2568
+ GlobalMissingWitnesses)
2569
+ .recordTypeWitness (overridden, type, typeDecl);
2567
2570
}
2568
2571
}
2569
2572
@@ -3368,7 +3371,8 @@ ResolveWitnessResult ConformanceChecker::resolveWitnessViaDerivation(
3368
3371
return ResolveWitnessResult::ExplicitFailed;
3369
3372
3370
3373
// Try to match the derived requirement.
3371
- auto match = matchWitness (TC, ReqEnvironmentCache, Proto, Conformance, DC,
3374
+ auto *TC = static_cast <TypeChecker *>(getASTContext ().getLazyResolver ());
3375
+ auto match = matchWitness (*TC, ReqEnvironmentCache, Proto, Conformance, DC,
3372
3376
requirement, derived);
3373
3377
if (match.isViable ()) {
3374
3378
recordWitness (requirement, match);
@@ -5231,9 +5235,8 @@ void TypeChecker::resolveTypeWitness(
5231
5235
AssociatedTypeDecl *assocType) {
5232
5236
llvm::SetVector<ValueDecl*> MissingWitnesses;
5233
5237
ConformanceChecker checker (
5234
- *this ,
5235
- const_cast <NormalProtocolConformance*>(conformance),
5236
- MissingWitnesses);
5238
+ Context, const_cast <NormalProtocolConformance *>(conformance),
5239
+ MissingWitnesses);
5237
5240
checker.resolveSingleTypeWitness (assocType);
5238
5241
checker.diagnoseMissingWitnesses (MissingWitnessDiagnosisKind::ErrorFixIt);
5239
5242
}
@@ -5242,9 +5245,8 @@ void TypeChecker::resolveWitness(const NormalProtocolConformance *conformance,
5242
5245
ValueDecl *requirement) {
5243
5246
llvm::SetVector<ValueDecl*> MissingWitnesses;
5244
5247
ConformanceChecker checker (
5245
- *this ,
5246
- const_cast <NormalProtocolConformance*>(conformance),
5247
- MissingWitnesses);
5248
+ Context, const_cast <NormalProtocolConformance *>(conformance),
5249
+ MissingWitnesses);
5248
5250
checker.resolveSingleWitness (requirement);
5249
5251
checker.diagnoseMissingWitnesses (MissingWitnessDiagnosisKind::ErrorFixIt);
5250
5252
}
@@ -5326,9 +5328,8 @@ namespace {
5326
5328
class DefaultWitnessChecker : public WitnessChecker {
5327
5329
5328
5330
public:
5329
- DefaultWitnessChecker (TypeChecker &tc,
5330
- ProtocolDecl *proto)
5331
- : WitnessChecker(tc, proto, proto->getDeclaredType (), proto) { }
5331
+ DefaultWitnessChecker (ASTContext &ctx, ProtocolDecl *proto)
5332
+ : WitnessChecker(ctx, proto, proto->getDeclaredType (), proto) {}
5332
5333
5333
5334
ResolveWitnessResult resolveWitnessViaLookup (ValueDecl *requirement);
5334
5335
void recordWitness (ValueDecl *requirement, const RequirementMatch &match);
@@ -5374,16 +5375,16 @@ void DefaultWitnessChecker::recordWitness(
5374
5375
}
5375
5376
5376
5377
void TypeChecker::inferDefaultWitnesses (ProtocolDecl *proto) {
5377
- DefaultWitnessChecker checker (* this , proto);
5378
+ DefaultWitnessChecker checker (Context , proto);
5378
5379
5379
5380
// Find the default for the given associated type.
5380
5381
auto findAssociatedTypeDefault =
5381
5382
[&](AssociatedTypeDecl *assocType,
5382
- AssociatedTypeDecl **defaultedAssocTypeOut = nullptr ) -> Type {
5383
+ AssociatedTypeDecl **defaultedAssocTypeOut = nullptr ) -> Type {
5383
5384
auto defaultedAssocType =
5384
- AssociatedTypeInference::findDefaultedAssociatedType (* this , assocType);
5385
+ AssociatedTypeInference::findDefaultedAssociatedType (assocType);
5385
5386
if (!defaultedAssocType)
5386
- return nullptr ;;
5387
+ return nullptr ;
5387
5388
5388
5389
Type defaultType = defaultedAssocType->getDefaultDefinitionType ();
5389
5390
if (!defaultType)
0 commit comments