@@ -5830,11 +5830,13 @@ diagnoseMissingAppendInterpolationMethod(NominalTypeDecl *typeDecl) {
58305830
58315831void TypeChecker::checkConformancesInContext (IterableDeclContext *idc) {
58325832 auto *const dc = idc->getAsGenericContext ();
5833+ auto *sf = dc->getParentSourceFile ();
58335834
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 " ) ;
58375838
5839+ // Catch invalid extensions.
58385840 const auto *const nominal = dc->getSelfNominalTypeDecl ();
58395841 if (!nominal)
58405842 return ;
@@ -6055,8 +6057,7 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
60556057 // If there were any unsatisfied requirements, check whether there
60566058 // are any near-matches we should diagnose.
60576059 if (!unsatisfiedReqs.empty () && !anyInvalid) {
6058- SourceFile *SF = dc->getParentSourceFile ();
6059- if (SF && SF->Kind != SourceFileKind::Interface) {
6060+ if (sf->Kind != SourceFileKind::Interface) {
60606061 // Find all of the members that aren't used to satisfy
60616062 // requirements, and check whether they are close to an
60626063 // unsatisfied or defaulted requirement.
@@ -6140,27 +6141,25 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
61406141 }
61416142 }
61426143
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 ;
61506150
6151- // Skip unavailable requirements.
6152- if (req->getAttrs ().isUnavailable (Context)) continue ;
6151+ // Skip unavailable requirements.
6152+ if (req->getAttrs ().isUnavailable (Context)) continue ;
61536153
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);
61646163 }
61656164 }
61666165 }
0 commit comments