@@ -177,6 +177,25 @@ class PrintMetadataSource
177177 }
178178};
179179
180+ // / Determine whether the given generic nominal that involves inverse
181+ // / requirements (e.g., Optional, Span) is always available for demangling
182+ // / purposes.
183+ static bool nominalIsAlwaysAvailableForDemangling (const NominalTypeDecl *nom) {
184+ // Only consider standard library types for this.
185+ if (!nom->getModuleContext ()->isStdlibModule ())
186+ return false ;
187+
188+ // If there's an @_originallyDefined(in:) attribute, then the nominal is
189+ // not always available for demangling.
190+ for (auto attr: nom->getAttrs ().getAttributes <OriginallyDefinedInAttr>()) {
191+ if (!attr->isInvalid () && attr->isActivePlatform (nom->getASTContext ()))
192+ return false ;
193+ }
194+
195+ // Everything else is available.
196+ return true ;
197+ }
198+
180199std::optional<llvm::VersionTuple>
181200getRuntimeVersionThatSupportsDemanglingType (CanType type) {
182201 enum VersionRequirement {
@@ -185,9 +204,10 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
185204 Swift_5_5,
186205 Swift_6_0,
187206 Swift_6_1,
207+ Swift_6_2,
188208
189209 // Short-circuit if we find this requirement.
190- Latest = Swift_6_1
210+ Latest = Swift_6_2
191211 };
192212
193213 VersionRequirement latestRequirement = None;
@@ -204,6 +224,11 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
204224 auto isolation = fn->getIsolation ();
205225 auto sendingResult = fn->hasSendingResult ();
206226
227+ // The mangling for nonisolated(nonsending) function types was introduced
228+ // in Swift 6.2.
229+ if (isolation.isNonIsolatedCaller ())
230+ return addRequirement (Swift_6_2);
231+
207232 // The Swift 6.1 runtime fixes a bug preventing successful demangling
208233 // when @isolated(any) or global actor isolation is combined with a
209234 // sending result.
@@ -246,16 +271,16 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
246271 // / signature uses NoncopyableGenerics. Since inverses are mangled into
247272 // / symbols, a Swift 6.0+ runtime is generally needed to demangle them.
248273 // /
249- // / We make an exception for types in the stdlib, like Optional, since the
250- // / runtime should still be able to demangle them, based on the availability
251- // / of the type.
274+ // / We make an exception for some types in the stdlib, like Optional, since
275+ // / the runtime should still be able to demangle them, based on the
276+ // / availability of the type.
252277 if (auto nominalTy = dyn_cast<NominalOrBoundGenericNominalType>(t)) {
253278 auto *nom = nominalTy->getDecl ();
254279 if (auto sig = nom->getGenericSignature ()) {
255280 SmallVector<InverseRequirement, 2 > inverses;
256281 SmallVector<Requirement, 2 > reqs;
257282 sig->getRequirementsWithInverses (reqs, inverses);
258- if (!inverses.empty () && !nom-> getModuleContext ()-> isStdlibModule ( )) {
283+ if (!inverses.empty () && !nominalIsAlwaysAvailableForDemangling (nom )) {
259284 return addRequirement (Swift_6_0);
260285 }
261286 }
@@ -271,6 +296,7 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
271296 });
272297
273298 switch (latestRequirement) {
299+ case Swift_6_2: return llvm::VersionTuple (6 , 2 );
274300 case Swift_6_1: return llvm::VersionTuple (6 , 1 );
275301 case Swift_6_0: return llvm::VersionTuple (6 , 0 );
276302 case Swift_5_5: return llvm::VersionTuple (5 , 5 );
0 commit comments