Merge pull request #81346 from rintaro/macros-definition-typecheck-ifconfig

[Macros] Don't include attr range when checking macro definition
This commit is contained in:
Rintaro Ishizaki
2025-05-07 09:29:34 -07:00
committed by GitHub
2 changed files with 8 additions and 1 deletions

View File

@@ -136,7 +136,7 @@ MacroDefinition MacroDefinitionRequest::evaluate(
SM.getEntireTextForBuffer(sourceFile->getBufferID());
StringRef macroDeclText =
SM.extractText(Lexer::getCharSourceRangeFromSourceRange(
SM, macro->getSourceRangeIncludingAttrs()));
SM, macro->getSourceRange()));
auto checkResult = swift_Macros_checkMacroDefinition(
&ctx.Diags, sourceFileText, macroDeclText, &externalMacroName,

View File

@@ -234,3 +234,10 @@ func someGlobalNext(
) async throws {
fatalError()
}
// This is testing if the definition is actually checked. The error means the '#externalMacro' was correctly parsed and checked.
#if true
@available(*, unavailable)
#endif
@freestanding(expression) public macro MacroWithIfConfigAttr() = #externalMacro(module: "ThisMacroModuleDoesNotExist", type: "ThisMacroTypeDoesNotExist")
// expected-warning@-1{{external macro implementation type 'ThisMacroModuleDoesNotExist.ThisMacroTypeDoesNotExist'}}