Skip to content

Commit 1c87ea5

Browse files
committed
Properly deprecate default implementation of MacroExpansionContext.lexicalContext
Now that we have, we can change the default implementation of `MacroExpansionContext.lexicalContext` to return an empty array and be deprecated, making not implementing `lexicalContext` a compile-time warning instead of a runtime error. rdar://123410459
1 parent d2adc61 commit 1c87ea5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/SwiftSyntaxMacros/MacroExpansionContext.swift

+7
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,18 @@ extension MacroExpansionContext {
8888
return location(of: node, at: .afterLeadingTrivia, filePathMode: .fileID)
8989
}
9090

91+
#if compiler(>=6.0)
92+
@available(*, deprecated, message: "`MacroExpansionContext` conformance must implement `lexicalContext`")
93+
public var lexicalContext: [Syntax] {
94+
return []
95+
}
96+
#else
9197
public var lexicalContext: [Syntax] {
9298
fatalError(
9399
"`MacroExpansionContext` conformance must implement `lexicalContext`"
94100
)
95101
}
102+
#endif
96103
}
97104

98105
/// Diagnostic message used for thrown errors.

0 commit comments

Comments
 (0)