Skip to content

Commit 7578cca

Browse files
committed
[ASTPrinter] Don't print internal @rethrows attribute
This attribute is an implementation detail of how 'rethrows' works, and you can't actually mark declarations @rethrows directly. So hide it from cursor info, and other places that use the ASTPrinter. rdar://problem/26638597
1 parent fe7daf4 commit 7578cca

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/AST/Attr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options)
306306
case DAK_ObjCBridged:
307307
case DAK_SynthesizedProtocol:
308308
case DAK_ShowInInterface:
309+
case DAK_Rethrows:
309310
return false;
310311
default:
311312
break;

test/SourceKit/CursorInfo/cursor_info.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ func tupleResult1() -> (Int, Int) {}
196196
func tupleResult2(f: () -> Void) {}
197197
typealias MyVoid = ()
198198

199+
func rethrowingFunction1(_: (Int) throws -> Void) rethrows -> Void {}
200+
199201
// RUN: rm -rf %t.tmp
200202
// RUN: mkdir %t.tmp
201203
// RUN: %swiftc_driver -emit-module -o %t.tmp/FooSwiftModule.swiftmodule %S/Inputs/FooSwiftModule.swift
@@ -666,3 +668,10 @@ typealias MyVoid = ()
666668

667669
// RUN: %sourcekitd-test -req=cursor -pos=197:11 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | FileCheck -check-prefix=CHECK84 %s
668670
// CHECK84: <decl.typealias><syntaxtype.keyword>typealias</syntaxtype.keyword> <decl.name>MyVoid</decl.name> = <tuple>()</tuple></decl.typealias>
671+
672+
// RUN: %sourcekitd-test -req=cursor -pos=199:6 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | FileCheck -check-prefix=CHECK85 %s
673+
// CHECK85-NOT: @rethrows
674+
// CHECK85: <Declaration>func rethrowingFunction1({{.*}}) rethrows</Declaration>
675+
// CHECK85-NOT: @rethrows
676+
// CHECK85: <decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>rethrowingFunction1</decl.name>({{.*}}) <syntaxtype.keyword>rethrows</syntaxtype.keyword></decl.function.free>
677+
// CHECK85-NOT: @rethrows

0 commit comments

Comments
 (0)