File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,13 @@ MacroDefinition MacroDefinitionRequest::evaluate(
193
193
free (replacements);
194
194
};
195
195
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
+
196
203
if (checkResult < 0 )
197
204
return MacroDefinition::forInvalid ();
198
205
Original file line number Diff line number Diff line change 3
3
4
4
let globalVar = 1
5
5
macro expect( file: Int = #^DEFAULT_ARG^#) = #externalMacro( module: " MyModule " , type: " MyMacro " )
6
-
7
6
// DEFAULT_ARG: Decl[GlobalVar]/CurrModule/TypeRelation[Convertible]: globalVar[#Int#]; name=globalVar
7
+
8
+ @freestanding ( expression)
9
+ macro externalMacro( ) = ##^EXTERNAL_MACRO^#externalMacro
10
+ // EXTERNAL_MACRO: Decl[Macro]/OtherModule[Swift]/IsSystem: externalMacro({#module: String#}, {#type: String#})[#T#]; name=externalMacro(module:type:)
11
+
12
+ @freestanding( expression)
13
+ macro externalMacroWithTrailing( ) = ##^EXTERNAL_MACRO_WITH_TRAILING? check= EXTERNAL_MACRO^#externalMacro
14
+
15
+ @freestanding ( expression)
16
+ macro externalMacroCallPattern( ) = #externalMacro( #^EXTERNAL_MACRO_CALL_PATTERN^#)
17
+ // EXTERNAL_MACRO_CALL_PATTERN: Pattern/None/Flair[ArgLabels]/TypeRelation[Convertible]: ['(']{#module: String#}, {#type: String#}[')'][#Void#]; name=module:type:
18
+
19
+ @freestanding ( expression)
20
+ macro externalMacroCallPattern( ) = #externalMacro( module: " MyModule " , #^EXTERNAL_MACRO_TYPE_ARG_LABEL^#)
21
+ // 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