@@ -5002,16 +5002,19 @@ static void diagnoseConformanceIsolationErrors(
5002
5002
if (potentialIsolation && potentialIsolation->isGlobalActor () &&
5003
5003
!conformance->isIsolated ()) {
5004
5004
bool isMainActor = false ;
5005
- Type globalActorIsolation = potentialIsolation->getGlobalActor ();
5006
- if (auto nominal = globalActorIsolation ->getAnyNominal ())
5005
+ Type globalActorType = potentialIsolation->getGlobalActor ();
5006
+ if (auto nominal = globalActorType ->getAnyNominal ())
5007
5007
isMainActor = nominal->isMainActor ();
5008
5008
5009
- auto diag = ctx.Diags .diagnose (
5010
- conformance->getProtocolNameLoc (),
5011
- diag::note_isolate_conformance_to_global_actor, globalActorIsolation,
5012
- isMainActor, globalActorIsolation.getString ());
5013
- conformance->applyConformanceAttribute (
5014
- diag, " @" + globalActorIsolation.getString ());
5009
+ // Take permanent ownership of the string. The diagnostic may outlive this
5010
+ // function call.
5011
+ auto globalActorTypeStr = ctx.AllocateCopy (globalActorType.getString ());
5012
+ auto diag =
5013
+ ctx.Diags .diagnose (conformance->getProtocolNameLoc (),
5014
+ diag::note_isolate_conformance_to_global_actor,
5015
+ globalActorType, isMainActor, globalActorTypeStr);
5016
+ conformance->applyConformanceAttribute (diag,
5017
+ " @" + globalActorTypeStr.str ());
5015
5018
}
5016
5019
5017
5020
// If marking witnesses as 'nonisolated' could work, suggest that.
0 commit comments