File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,13 @@ MacroDefinition MacroDefinitionRequest::evaluate(
193193 free (replacements);
194194 };
195195
196+ if (checkResult < 0 && ctx.CompletionCallback ) {
197+ // If the macro failed to check and we are in code completion mode, pretend
198+ // it's an arbitrary macro. This allows us to get call argument completions
199+ // inside `#externalMacro`.
200+ checkResult = BridgedMacroDefinitionKind::BridgedExpandedMacro;
201+ }
202+
196203 if (checkResult < 0 )
197204 return MacroDefinition::forInvalid ();
198205
Original file line number Diff line number Diff line change 1+ // REQUIRES: swift_swift_parser
12// RUN: %empty-directory(%t)
23// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
34
45let globalVar = 1
56macro expect( file: Int = #^DEFAULT_ARG^#) = #externalMacro( module: " MyModule " , type: " MyMacro " )
6-
77// DEFAULT_ARG: Decl[GlobalVar]/CurrModule/TypeRelation[Convertible]: globalVar[#Int#]; name=globalVar
8+
9+ @freestanding ( expression)
10+ macro externalMacro( ) = ##^EXTERNAL_MACRO^#
11+ // EXTERNAL_MACRO: Decl[Macro]/OtherModule[Swift]/IsSystem: externalMacro({#module: String#}, {#type: String#})[#T#]; name=externalMacro(module:type:)
12+
13+ @freestanding ( expression)
14+ macro externalMacroWithTrailing( ) = ##^EXTERNAL_MACRO_WITH_TRAILING? check= EXTERNAL_MACRO^#externalMacro
15+
16+ @freestanding ( expression)
17+ macro externalMacroCallPattern( ) = #externalMacro( #^EXTERNAL_MACRO_CALL_PATTERN^#)
18+ // EXTERNAL_MACRO_CALL_PATTERN: Pattern/None/Flair[ArgLabels]/TypeRelation[Convertible]: ['(']{#module: String#}, {#type: String#}[')'][#Void#]; name=module:type:
19+
20+ @freestanding ( expression)
21+ macro externalMacroCallPattern( ) = #externalMacro( module: " MyModule " , #^EXTERNAL_MACRO_TYPE_ARG_LABEL^#)
22+ // EXTERNAL_MACRO_TYPE_ARG_LABEL: Pattern/Local/Flair[ArgLabels]: {#type: String#}[#String#]; name=type:
You can’t perform that action at this time.
0 commit comments