@@ -5830,11 +5830,13 @@ diagnoseMissingAppendInterpolationMethod(NominalTypeDecl *typeDecl) {
5830
5830
5831
5831
void TypeChecker::checkConformancesInContext (IterableDeclContext *idc) {
5832
5832
auto *const dc = idc->getAsGenericContext ();
5833
+ auto *sf = dc->getParentSourceFile ();
5833
5834
5834
- // For anything imported from Clang, lazily check conformances.
5835
- if (isa<ClangModuleUnit>(dc-> getModuleScopeContext ()))
5836
- return ;
5835
+ assert (sf != nullptr &&
5836
+ " checkConformancesInContext() should not be called on imported "
5837
+ " or deserialized DeclContexts " ) ;
5837
5838
5839
+ // Catch invalid extensions.
5838
5840
const auto *const nominal = dc->getSelfNominalTypeDecl ();
5839
5841
if (!nominal)
5840
5842
return ;
@@ -6055,8 +6057,7 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
6055
6057
// If there were any unsatisfied requirements, check whether there
6056
6058
// are any near-matches we should diagnose.
6057
6059
if (!unsatisfiedReqs.empty () && !anyInvalid) {
6058
- SourceFile *SF = dc->getParentSourceFile ();
6059
- if (SF && SF->Kind != SourceFileKind::Interface) {
6060
+ if (sf->Kind != SourceFileKind::Interface) {
6060
6061
// Find all of the members that aren't used to satisfy
6061
6062
// requirements, and check whether they are close to an
6062
6063
// unsatisfied or defaulted requirement.
@@ -6140,27 +6141,25 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
6140
6141
}
6141
6142
}
6142
6143
6143
- if (auto *sf = dc->getParentSourceFile ()) {
6144
- // For any unsatisfied optional @objc requirements that remain
6145
- // unsatisfied, note them in the AST for @objc selector collision
6146
- // checking.
6147
- for (auto req : unsatisfiedReqs) {
6148
- // Skip non-@objc requirements.
6149
- if (!req->isObjC ()) continue ;
6144
+ // For any unsatisfied optional @objc requirements that remain
6145
+ // unsatisfied, note them in the AST for @objc selector collision
6146
+ // checking.
6147
+ for (auto req : unsatisfiedReqs) {
6148
+ // Skip non-@objc requirements.
6149
+ if (!req->isObjC ()) continue ;
6150
6150
6151
- // Skip unavailable requirements.
6152
- if (req->getAttrs ().isUnavailable (Context)) continue ;
6151
+ // Skip unavailable requirements.
6152
+ if (req->getAttrs ().isUnavailable (Context)) continue ;
6153
6153
6154
- // Record this requirement.
6155
- if (auto funcReq = dyn_cast<AbstractFunctionDecl>(req)) {
6156
- sf->ObjCUnsatisfiedOptReqs .emplace_back (dc, funcReq);
6157
- } else {
6158
- auto storageReq = cast<AbstractStorageDecl>(req);
6159
- if (auto getter = storageReq->getParsedAccessor (AccessorKind::Get))
6160
- sf->ObjCUnsatisfiedOptReqs .emplace_back (dc, getter);
6161
- if (auto setter = storageReq->getParsedAccessor (AccessorKind::Set))
6162
- sf->ObjCUnsatisfiedOptReqs .emplace_back (dc, setter);
6163
- }
6154
+ // Record this requirement.
6155
+ if (auto funcReq = dyn_cast<AbstractFunctionDecl>(req)) {
6156
+ sf->ObjCUnsatisfiedOptReqs .emplace_back (dc, funcReq);
6157
+ } else {
6158
+ auto storageReq = cast<AbstractStorageDecl>(req);
6159
+ if (auto getter = storageReq->getParsedAccessor (AccessorKind::Get))
6160
+ sf->ObjCUnsatisfiedOptReqs .emplace_back (dc, getter);
6161
+ if (auto setter = storageReq->getParsedAccessor (AccessorKind::Set))
6162
+ sf->ObjCUnsatisfiedOptReqs .emplace_back (dc, setter);
6164
6163
}
6165
6164
}
6166
6165
}
0 commit comments