Skip to content

Commit 9a7d28a

Browse files
committed
[ast-printer] Don't emit 'infix' attribute for decls
Textual SIL containing something like: `infix static func ==(a: T, b: T) -> Bool` cannot be parsed and results in an error like: ``` error: 'infix' modifier is not required or allowed on func declarations ``` Interestingly enough, `prefix` and `postfix` attributes do not result in the same kind of errors.
1 parent e5d5d7d commit 9a7d28a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/AST/Attr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
322322
case DAK_SynthesizedProtocol:
323323
case DAK_ShowInInterface:
324324
case DAK_Rethrows:
325+
case DAK_Infix:
325326
return false;
326327
default:
327328
break;

test/IDE/print_ast_tc_decls.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ struct d0200_EscapedIdentifiers {
585585
}
586586
// PASS_COMMON-NEXT: {{^}} enum `enum` {{{$}}
587587
// PASS_COMMON-NEXT: {{^}} case `case`{{$}}
588-
// PASS_COMMON-NEXT: {{^}} infix static func ==(a: d0200_EscapedIdentifiers.`enum`, b: d0200_EscapedIdentifiers.`enum`) -> Bool
588+
// PASS_COMMON-NEXT: {{^}} static func ==(a: d0200_EscapedIdentifiers.`enum`, b: d0200_EscapedIdentifiers.`enum`) -> Bool
589589
// PASS_COMMON-NEXT: {{^}} var hashValue: Int { get }{{$}}
590590
// PASS_COMMON-NEXT: {{^}} }{{$}}
591591

@@ -1007,7 +1007,7 @@ enum d2000_EnumDecl1 {
10071007
// PASS_COMMON: {{^}}enum d2000_EnumDecl1 {{{$}}
10081008
// PASS_COMMON-NEXT: {{^}} case ED1_First{{$}}
10091009
// PASS_COMMON-NEXT: {{^}} case ED1_Second{{$}}
1010-
// PASS_COMMON-NEXT: {{^}} infix static func ==(a: d2000_EnumDecl1, b: d2000_EnumDecl1) -> Bool
1010+
// PASS_COMMON-NEXT: {{^}} static func ==(a: d2000_EnumDecl1, b: d2000_EnumDecl1) -> Bool
10111011
// PASS_COMMON-NEXT: {{^}} var hashValue: Int { get }{{$}}
10121012
// PASS_COMMON-NEXT: {{^}}}{{$}}
10131013

0 commit comments

Comments
 (0)