@@ -141,7 +141,17 @@ void ConformanceLookupTable::destroy() {
141141}
142142
143143namespace {
144- using ConformanceConstructionInfo = Located<ProtocolDecl *>;
144+ struct ConformanceConstructionInfo : public Located <ProtocolDecl *> {
145+ // / The location of the "unchecked" attribute, if this
146+ const SourceLoc uncheckedLoc;
147+
148+ ConformanceConstructionInfo () { }
149+
150+ ConformanceConstructionInfo (
151+ ProtocolDecl *item, SourceLoc loc,
152+ SourceLoc uncheckedLoc
153+ ) : Located(item, loc), uncheckedLoc(uncheckedLoc) { }
154+ };
145155}
146156
147157template <typename NominalFunc, typename ExtensionFunc>
@@ -195,14 +205,14 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
195205 loader.first ->loadAllConformances (next, loader.second , conformances);
196206 loadAllConformances (next, conformances);
197207 for (auto conf : conformances) {
198- protocols.push_back ({conf->getProtocol (), SourceLoc ()});
208+ protocols.push_back ({conf->getProtocol (), SourceLoc (), SourceLoc () });
199209 }
200210 } else if (next->getParentSourceFile ()) {
201211 bool anyObject = false ;
202212 for (const auto &found :
203213 getDirectlyInheritedNominalTypeDecls (next, anyObject)) {
204214 if (auto proto = dyn_cast<ProtocolDecl>(found.Item ))
205- protocols.push_back ({proto, found.Loc });
215+ protocols.push_back ({proto, found.Loc , found. uncheckedLoc });
206216 }
207217 }
208218
@@ -282,7 +292,9 @@ void ConformanceLookupTable::updateLookupTable(NominalTypeDecl *nominal,
282292 // its inherited protocols directly.
283293 auto source = ConformanceSource::forExplicit (ext);
284294 for (auto locAndProto : protos)
285- addProtocol (locAndProto.Item , locAndProto.Loc , source);
295+ addProtocol (
296+ locAndProto.Item , locAndProto.Loc ,
297+ source.withUncheckedLoc (locAndProto.uncheckedLoc ));
286298 });
287299 break ;
288300
@@ -471,8 +483,10 @@ void ConformanceLookupTable::addInheritedProtocols(
471483 bool anyObject = false ;
472484 for (const auto &found :
473485 getDirectlyInheritedNominalTypeDecls (decl, anyObject)) {
474- if (auto proto = dyn_cast<ProtocolDecl>(found.Item ))
475- addProtocol (proto, found.Loc , source);
486+ if (auto proto = dyn_cast<ProtocolDecl>(found.Item )) {
487+ addProtocol (
488+ proto, found.Loc , source.withUncheckedLoc (found.uncheckedLoc ));
489+ }
476490 }
477491}
478492
@@ -843,7 +857,8 @@ ConformanceLookupTable::getConformance(NominalTypeDecl *nominal,
843857
844858 auto normalConf =
845859 ctx.getConformance (conformingType, protocol, conformanceLoc,
846- conformingDC, ProtocolConformanceState::Incomplete);
860+ conformingDC, ProtocolConformanceState::Incomplete,
861+ entry->Source .getUncheckedLoc ().isValid ());
847862 // Invalid code may cause the getConformance call below to loop, so break
848863 // the infinite recursion by setting this eagerly to shortcircuit with the
849864 // early return at the start of this function.
0 commit comments