File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,20 @@ void Parser::parseSourceFileViaASTGen(
330
330
if (!needToParse)
331
331
return ;
332
332
333
+ switch (SF.Kind ) {
334
+ case SourceFileKind::Library:
335
+ case SourceFileKind::Main:
336
+ case SourceFileKind::Interface:
337
+ break ;
338
+ case SourceFileKind::SIL:
339
+ // FIXME: Support SIL.
340
+ return ;
341
+ case SourceFileKind::MacroExpansion:
342
+ case SourceFileKind::DefaultArgument:
343
+ // FIXME: Support macro expanded sources.
344
+ return ;
345
+ }
346
+
333
347
auto *exportedSourceFile = SF.getExportedSourceFile ();
334
348
if (!exportedSourceFile)
335
349
return ;
Original file line number Diff line number Diff line change
1
+ // REQUIRES: swift_swift_parser, asserts
2
+
3
+ // RUN: %empty-directory(%t)
4
+
5
+ // RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/../Macros/Inputs/syntax_macro_definitions.swift
6
+
7
+ // RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -enable-experimental-feature ParserASTGen
8
+
9
+ @freestanding ( declaration) macro anonymousTypes( _: ( ) -> String ) = #externalMacro( module: " MacroDefinition " , type: " DefineAnonymousTypesMacro " )
10
+ @freestanding ( expression) macro stringify< T> ( _ value: T ) -> ( T , String ) = #externalMacro( module: " MacroDefinition " , type: " StringifyMacro " )
11
+
12
+ func foo( a: Int ) {
13
+ _ = #stringify ( a + 1 )
14
+ }
15
+
16
+ struct Outer {
17
+ #anonymousTypes { " test" }
18
+ }
You can’t perform that action at this time.
0 commit comments