File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -8181,8 +8181,8 @@ void Parser::parseExpandedMemberList(SmallVectorImpl<ASTNode> &items) {
8181
8181
8182
8182
bool previousHadSemi = true ;
8183
8183
8184
- SourceLoc startingLoc = Tok.getLoc ();
8185
8184
while (!Tok.is (tok::eof)) {
8185
+ SourceLoc startingLoc = Tok.getLoc ();
8186
8186
parseDeclItem (previousHadSemi, [&](Decl *d) { items.push_back (d); });
8187
8187
8188
8188
if (Tok.getLoc () == startingLoc)
Original file line number Diff line number Diff line change @@ -2704,3 +2704,30 @@ public struct AddGetterMacro: AccessorMacro {
2704
2704
return [ " get { 0 } " ]
2705
2705
}
2706
2706
}
2707
+
2708
+ public struct HangingMacro : PeerMacro {
2709
+ public static func expansion(
2710
+ of node: AttributeSyntax ,
2711
+ providingPeersOf declaration: some DeclSyntaxProtocol ,
2712
+ in context: some MacroExpansionContext
2713
+ ) throws -> [ DeclSyntax ] {
2714
+ guard let variableDecl = declaration. as ( VariableDeclSyntax . self) else {
2715
+ return [ ]
2716
+ }
2717
+
2718
+ guard let binding: PatternBindingSyntax = variableDecl. bindings. first else {
2719
+ return [ ]
2720
+ }
2721
+
2722
+ guard let typeAnnotation = binding. typeAnnotation else {
2723
+ return [ ]
2724
+ }
2725
+
2726
+ let mockProperty = try VariableDeclSyntax ( " var BadThing: \( typeAnnotation. type) " ) {
2727
+ }
2728
+
2729
+ return [
2730
+ DeclSyntax ( mockProperty)
2731
+ ]
2732
+ }
2733
+ }
Original file line number Diff line number Diff line change
1
+ // REQUIRES: swift_swift_parser, executable_test
2
+
3
+ // RUN: %empty-directory(%t)
4
+ // RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -parse-as-library -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
5
+ // RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library -disable-availability-checking
6
+
7
+ @attached ( peer, names: named ( BadThing) )
8
+ macro HangingMacro( ) = #externalMacro( module: " MacroDefinition " , type: " HangingMacro " )
9
+
10
+ // expected-note@+1{{in declaration of 'Foo'}}
11
+ class Foo {
12
+ init ( ) { }
13
+
14
+ // expected-note@+1 2{{in expansion of macro 'HangingMacro' on property 'result' here}}
15
+ @HangingMacro var result : Int // This comment makes it hang.
16
+ }
You can’t perform that action at this time.
0 commit comments