Skip to content

Commit 5d0c5a6

Browse files
committed
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.
1 parent d0a8c4e commit 5d0c5a6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/ASTGen/Sources/ASTGen/Macros.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ enum ASTGenMacroDiagnostic: DiagnosticMessage, FixItMessage {
186186
var message: String {
187187
switch self {
188188
case .thrownError(let error):
189-
return String(describing: error)
189+
if let err = error as? PluginError {
190+
return err.description
191+
} else {
192+
return String(describing: error)
193+
}
190194

191195
case .oldStyleExternalMacro:
192196
return "external macro definitions are now written using #externalMacro"

0 commit comments

Comments
 (0)