@@ -53,18 +53,6 @@ DeclContext *ConformanceLookupTable::ConformanceSource::getDeclContext() const {
5353 llvm_unreachable (" Unhandled ConformanceEntryKind in switch." );
5454}
5555
56- bool ConformanceLookupTable::ConformanceSource::isUnsafeContext (DeclContext *dc) {
57- if (auto enclosingNominal = dc->getSelfNominalTypeDecl ())
58- if (enclosingNominal->isUnsafe ())
59- return true ;
60-
61- if (auto ext = dyn_cast<ExtensionDecl>(dc))
62- if (ext->getAttrs ().hasAttribute <UnsafeAttr>())
63- return true ;
64-
65- return false ;
66- }
67-
6856ProtocolDecl *ConformanceLookupTable::ConformanceEntry::getProtocol () const {
6957 if (auto protocol = Conformance.dyn_cast <ProtocolDecl *>())
7058 return protocol;
@@ -166,13 +154,17 @@ namespace {
166154 // / The location of the "preconcurrency" attribute if present.
167155 const SourceLoc preconcurrencyLoc;
168156
157+ // / The location of the "unsafe" attribute if present.
158+ const SourceLoc unsafeLoc;
159+
169160 ConformanceConstructionInfo () { }
170161
171162 ConformanceConstructionInfo (ProtocolDecl *item, SourceLoc loc,
172163 SourceLoc uncheckedLoc,
173- SourceLoc preconcurrencyLoc)
164+ SourceLoc preconcurrencyLoc,
165+ SourceLoc unsafeLoc)
174166 : Located(item, loc), uncheckedLoc(uncheckedLoc),
175- preconcurrencyLoc (preconcurrencyLoc) {}
167+ preconcurrencyLoc (preconcurrencyLoc), unsafeLoc(unsafeLoc) {}
176168 };
177169}
178170
@@ -228,7 +220,7 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
228220 registerProtocolConformances (next, conformances);
229221 for (auto conf : conformances) {
230222 protocols.push_back (
231- {conf->getProtocol (), SourceLoc (), SourceLoc (), SourceLoc ()});
223+ {conf->getProtocol (), SourceLoc (), SourceLoc (), SourceLoc (), SourceLoc () });
232224 }
233225 } else if (next->getParentSourceFile () ||
234226 next->getParentModule ()->isBuiltinModule ()) {
@@ -238,7 +230,8 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
238230 getDirectlyInheritedNominalTypeDecls (next, inverses, anyObject)) {
239231 if (auto proto = dyn_cast<ProtocolDecl>(found.Item ))
240232 protocols.push_back (
241- {proto, found.Loc , found.uncheckedLoc , found.preconcurrencyLoc });
233+ {proto, found.Loc , found.uncheckedLoc ,
234+ found.preconcurrencyLoc , found.unsafeLoc });
242235 }
243236 }
244237
@@ -343,7 +336,8 @@ void ConformanceLookupTable::updateLookupTable(NominalTypeDecl *nominal,
343336 addProtocol (
344337 locAndProto.Item , locAndProto.Loc ,
345338 source.withUncheckedLoc (locAndProto.uncheckedLoc )
346- .withPreconcurrencyLoc (locAndProto.preconcurrencyLoc ));
339+ .withPreconcurrencyLoc (locAndProto.preconcurrencyLoc )
340+ .withUnsafeLoc (locAndProto.unsafeLoc ));
347341 });
348342 break ;
349343
0 commit comments