diff --git a/Sources/SwiftCompilerPlugin/CompilerPlugin.swift b/Sources/SwiftCompilerPlugin/CompilerPlugin.swift index 3ced3a43de1..b9c9073d154 100644 --- a/Sources/SwiftCompilerPlugin/CompilerPlugin.swift +++ b/Sources/SwiftCompilerPlugin/CompilerPlugin.swift @@ -112,6 +112,6 @@ extension CompilerPlugin { let connection = try StandardIOMessageConnection() let provider = MacroProviderAdapter(plugin: Self()) let impl = CompilerPluginMessageListener(connection: connection, provider: provider) - impl.main() + try impl.main() } } diff --git a/Sources/SwiftCompilerPluginMessageHandling/CompilerPluginMessageHandler.swift b/Sources/SwiftCompilerPluginMessageHandling/CompilerPluginMessageHandler.swift index 6c78e03e845..97e9e3e5401 100644 --- a/Sources/SwiftCompilerPluginMessageHandling/CompilerPluginMessageHandler.swift +++ b/Sources/SwiftCompilerPluginMessageHandling/CompilerPluginMessageHandler.swift @@ -96,12 +96,13 @@ public class CompilerPluginMessageListener PluginToHostMessage + + /// Deterministically and synchronously cleans up resources that cannot be dealt with in + /// a deinitializer due to possible errors thrown during the clean up. Usually this + /// includes closure of file handles, sockets, shutting down external processes and IPC + /// resources set up for these processes, etc. + func shutDown() throws } /// A `PluginMessageHandler` that uses a `PluginProvider`. @@ -226,6 +233,10 @@ public class PluginProviderMessageHandler: PluginMessa return .loadPluginLibraryResult(loaded: diags.isEmpty, diagnostics: diags) } } + + /// Empty implementation for the default message handler, since all resources are automatically + /// cleaned up in the synthesized initializer. + public func shutDown() throws {} } @_spi(PluginMessage)