@@ -5022,16 +5022,19 @@ static void diagnoseConformanceIsolationErrors(
5022
5022
if (potentialIsolation && potentialIsolation->isGlobalActor () &&
5023
5023
!conformance->isIsolated ()) {
5024
5024
bool isMainActor = false ;
5025
- Type globalActorIsolation = potentialIsolation->getGlobalActor ();
5026
- if (auto nominal = globalActorIsolation ->getAnyNominal ())
5025
+ Type globalActorType = potentialIsolation->getGlobalActor ();
5026
+ if (auto nominal = globalActorType ->getAnyNominal ())
5027
5027
isMainActor = nominal->isMainActor ();
5028
5028
5029
- auto diag = ctx.Diags .diagnose (
5030
- conformance->getProtocolNameLoc (),
5031
- diag::note_isolate_conformance_to_global_actor, globalActorIsolation,
5032
- isMainActor, globalActorIsolation.getString ());
5033
- conformance->applyConformanceAttribute (
5034
- diag, " @" + globalActorIsolation.getString ());
5029
+ // Take permanent ownership of the string. The diagnostic may outlive this
5030
+ // function call.
5031
+ auto globalActorTypeStr = ctx.AllocateCopy (globalActorType.getString ());
5032
+ auto diag =
5033
+ ctx.Diags .diagnose (conformance->getProtocolNameLoc (),
5034
+ diag::note_isolate_conformance_to_global_actor,
5035
+ globalActorType, isMainActor, globalActorTypeStr);
5036
+ conformance->applyConformanceAttribute (diag,
5037
+ " @" + globalActorTypeStr.str ());
5035
5038
}
5036
5039
5037
5040
// If marking witnesses as 'nonisolated' could work, suggest that.
0 commit comments