From 5d0c5a643fdf3ac9d9c721ec107c27d3b0aeb3a7 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 4 Sep 2023 16:12:56 -0700 Subject: [PATCH] ASTGen: add a workaround for CSC conformance visibility A thrown error is stored as `any Error` which does not conform to `CustomStringConvertible`. When we perform the conversion via the `String(describing:)` initialiser, for some reason the runtime does not find the conformance and the error is not translated properly. Explicitly casting to `PluginError` resolves the missing conformance and fixes a test failure. --- lib/ASTGen/Sources/ASTGen/Macros.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ASTGen/Sources/ASTGen/Macros.swift b/lib/ASTGen/Sources/ASTGen/Macros.swift index 72ec2681d6ae1..399b1ef29cee6 100644 --- a/lib/ASTGen/Sources/ASTGen/Macros.swift +++ b/lib/ASTGen/Sources/ASTGen/Macros.swift @@ -186,7 +186,11 @@ enum ASTGenMacroDiagnostic: DiagnosticMessage, FixItMessage { var message: String { switch self { case .thrownError(let error): - return String(describing: error) + if let err = error as? PluginError { + return err.description + } else { + return String(describing: error) + } case .oldStyleExternalMacro: return "external macro definitions are now written using #externalMacro"