Skip to content

Commit 066f285

Browse files
committed
tweak a few testcases that still fail with the @discardableResult attribute being auto-applied by the clang importer.
1 parent d698e4f commit 066f285

File tree

7 files changed

+39
-13
lines changed

7 files changed

+39
-13
lines changed

test/IDE/Inputs/mock-sdk/Foo.FooSub.printed.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@_exported import FooHelper
22

3+
@discardableResult
34
func fooSubFunc1(_ a: Int32) -> Int32
45
struct FooSubEnum1 : RawRepresentable, Equatable {
56
init(_ rawValue: UInt32)

test/IDE/Inputs/mock-sdk/Foo.annotated.txt

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ typealias <loc>FooTypedef1</loc> = <ref:Struct>Int32</ref></decl>
6969
var <loc>fooIntVar</loc>: <ref:Struct>Int32</ref></decl>
7070

7171
<decl:Func>/// Aaa. fooFunc1. Bbb.
72+
@discardableResult
7273
func <loc>fooFunc1(<decl:Param>_ a: <ref:Struct>Int32</ref></decl>)</loc> -> <ref:Struct>Int32</ref></decl>
73-
<decl:Func>func <loc>fooFunc1AnonymousParam(<decl:Param>_: <ref:Struct>Int32</ref></decl>)</loc> -> <ref:Struct>Int32</ref></decl>
74-
<decl:Func>func <loc>fooFunc3(<decl:Param>_ a: <ref:Struct>Int32</ref></decl>, <decl:Param>_ b: <ref:Struct>Float</ref></decl>, <decl:Param>_ c: <ref:Struct>Double</ref></decl>, <decl:Param>_ d: <ref:Struct>UnsafeMutablePointer</ref><<ref:Struct>Int32</ref>>!</decl>)</loc> -> <ref:Struct>Int32</ref></decl>
74+
<decl:Func>@discardableResult
75+
func <loc>fooFunc1AnonymousParam(<decl:Param>_: <ref:Struct>Int32</ref></decl>)</loc> -> <ref:Struct>Int32</ref></decl>
76+
<decl:Func>@discardableResult
77+
func <loc>fooFunc3(<decl:Param>_ a: <ref:Struct>Int32</ref></decl>, <decl:Param>_ b: <ref:Struct>Float</ref></decl>, <decl:Param>_ c: <ref:Struct>Double</ref></decl>, <decl:Param>_ d: <ref:Struct>UnsafeMutablePointer</ref><<ref:Struct>Int32</ref>>!</decl>)</loc> -> <ref:Struct>Int32</ref></decl>
7578
<decl:Func>func <loc>fooFuncWithBlock(<decl:Param>_ blk: ((<ref:Struct>Float</ref>) -> <ref:Struct>Int32</ref>)!</decl>)</loc></decl>
7679
<decl:Func>func <loc>fooFuncWithFunctionPointer(<decl:Param>_ fptr: (@convention(c) (<ref:Struct>Float</ref>) -> <ref:Struct>Int32</ref>)!</decl>)</loc></decl>
7780
<decl:Func>@noreturn func <loc>fooFuncNoreturn1()</loc></decl>
@@ -111,8 +114,10 @@ func <loc>fooFuncWithComment4()</loc></decl>
111114
func <loc>fooFuncWithComment5()</loc></decl>
112115

113116
<decl:Func>/// Aaa. redeclaredInMultipleModulesFunc1. Bbb.
117+
@discardableResult
114118
func <loc>redeclaredInMultipleModulesFunc1(<decl:Param>_ a: <ref:Struct>Int32</ref></decl>)</loc> -> <ref:Struct>Int32</ref></decl>
115119
<decl:Func>@available(*, unavailable, message: "Variadic function is unavailable")
120+
@discardableResult
116121
func <loc>fooFuncUsingVararg(<decl:Param>_ a: <ref:Struct>Int32</ref></decl>, <decl:Param>_ varargs: <ref:TypeAlias>Any</ref>...</decl>)</loc> -> <ref:Struct>Int32</ref></decl>
117122

118123
<decl:Protocol>/// Aaa. FooProtocolBase. Bbb.
@@ -141,15 +146,18 @@ protocol <loc>FooProtocolBase</loc> {
141146
<decl:Class>class <loc>FooClassBase</loc> {
142147
<decl:Func>class func <loc>fooBaseInstanceFunc0()</loc></decl>
143148
<decl:Func>func <loc>fooBaseInstanceFunc0()</loc></decl>
144-
<decl:Func>class func <loc>fooBaseInstanceFunc1(<decl:Param>_ anObject: <ref:Protocol>AnyObject</ref>!</decl>)</loc> -> <ref:Class>FooClassBase</ref>!</decl>
145-
<decl:Func>func <loc>fooBaseInstanceFunc1(<decl:Param>_ anObject: <ref:Protocol>AnyObject</ref>!</decl>)</loc> -> <ref:Class>FooClassBase</ref>!</decl>
149+
<decl:Func>@discardableResult
150+
class func <loc>fooBaseInstanceFunc1(<decl:Param>_ anObject: <ref:Protocol>AnyObject</ref>!</decl>)</loc> -> <ref:Class>FooClassBase</ref>!</decl>
151+
<decl:Func>@discardableResult
152+
func <loc>fooBaseInstanceFunc1(<decl:Param>_ anObject: <ref:Protocol>AnyObject</ref>!</decl>)</loc> -> <ref:Class>FooClassBase</ref>!</decl>
146153
<decl:Constructor><loc>init!()</loc></decl>
147154
<decl:Constructor>convenience <loc>init!(<decl:Param>float f: <ref:Struct>Float</ref></decl>)</loc></decl>
148155
<decl:Func>class func <loc>fooBaseInstanceFuncOverridden()</loc></decl>
149156
<decl:Func>func <loc>fooBaseInstanceFuncOverridden()</loc></decl>
150157
<decl:Func>class func <loc>fooBaseClassFunc0()</loc></decl>
151158
<decl:Constructor>/*not inherited*/ <loc>init!(<decl:Param>_ x: <ref:Struct>Int32</ref></decl>)</loc></decl>
152159
<decl:Func>@available(*, unavailable, message: "use object construction 'FooClassBase(_:)'")
160+
@discardableResult
153161
class func <loc>fooClassBase(<decl:Param>_ x: <ref:Struct>Int32</ref></decl>)</loc> -> <ref:Class>FooClassBase</ref>!</decl>
154162
}</decl>
155163

@@ -196,18 +204,26 @@ class <loc>FooClassDerived</loc> : <ref:Class>FooClassBase</ref>, <ref:Protocol>
196204
<decl:Constructor><loc>init(<decl:Param>x: <ref:Struct>Int32</ref></decl>)</loc></decl>
197205
}</decl>
198206
<decl:Extension>extension <loc><ref:Class>FooClassBase</ref></loc> {
199-
<decl:Func>class func <loc>_internalMeth1()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
200-
<decl:Func>func <loc>_internalMeth1()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
207+
<decl:Func>@discardableResult
208+
class func <loc>_internalMeth1()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
209+
<decl:Func>@discardableResult
210+
func <loc>_internalMeth1()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
201211
}</decl>
202212
<decl:Extension>extension <loc><ref:Class>FooClassBase</ref></loc> {
203-
<decl:Func>class func <loc>_internalMeth2()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
204-
<decl:Func>func <loc>_internalMeth2()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
205-
<decl:Func>class func <loc>nonInternalMeth()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
206-
<decl:Func>func <loc>nonInternalMeth()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
213+
<decl:Func>@discardableResult
214+
class func <loc>_internalMeth2()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
215+
<decl:Func>@discardableResult
216+
func <loc>_internalMeth2()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
217+
<decl:Func>@discardableResult
218+
class func <loc>nonInternalMeth()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
219+
<decl:Func>@discardableResult
220+
func <loc>nonInternalMeth()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
207221
}</decl>
208222
<decl:Extension>extension <loc><ref:Class>FooClassBase</ref></loc> {
209-
<decl:Func>class func <loc>_internalMeth3()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
210-
<decl:Func>func <loc>_internalMeth3()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
223+
<decl:Func>@discardableResult
224+
class func <loc>_internalMeth3()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
225+
<decl:Func>@discardableResult
226+
func <loc>_internalMeth3()</loc> -> <ref:Protocol>AnyObject</ref>!</decl>
211227
}</decl>
212228
<decl:Protocol>protocol <loc>_InternalProt</loc> {
213229
}</decl>
@@ -238,6 +254,7 @@ class <loc>FooClassDerived</loc> : <ref:Class>FooClassBase</ref>, <ref:Protocol>
238254
<decl:Class>class <loc>FooUnavailableMembers</loc> : <ref:Class>FooClassBase</ref> {
239255
<decl:Constructor>convenience <loc>init!(<decl:Param>int i: <ref:Struct>Int32</ref></decl>)</loc></decl>
240256
<decl:Func>@available(*, unavailable, message: "use object construction 'FooUnavailableMembers(int:)'")
257+
@discardableResult
241258
class func <loc>withInt(<decl:Param>_ i: <ref:Struct>Int32</ref></decl>)</loc> -> <ref:Class>Self</ref>!</decl>
242259
<decl:Func>@available(*, unavailable, message: "x")
243260
func <loc>unavailable()</loc></decl>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11

2+
@discardableResult
23
func fooHelperExplicitFrameworkFunc1(_ a: Int32) -> Int32

test/IDE/Inputs/mock-sdk/FooHelper.FooHelperSub.printed.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
@discardableResult
23
func fooHelperSubFunc1(_ a: Int32) -> Int32
34
struct FooHelperSubEnum1 : RawRepresentable, Equatable {
45
init(_ rawValue: UInt32)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import FooHelper.FooHelperExplicit
22
@_exported import FooHelper.FooHelperSub
33

4+
@discardableResult
45
func fooHelperFunc1(_ a: Int32) -> Int32
56
var FooHelperUnnamedEnumeratorA1: Int { get }
67
var FooHelperUnnamedEnumeratorA2: Int { get }

test/IDE/print_clang_framework.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
// FOUNDATION-NEXT: {{^}} @available(OSX 10.51, *){{$}}
7676
// FOUNDATION-NEXT: {{^}} func doSomething(withIUOClass k: AnnotatedFrameworkClass!){{$}}
7777
// FOUNDATION-NEXT: {{^}} @available(OSX 10.51, *){{$}}
78+
// FOUNDATION-NEXT: {{^}} @discardableResult
7879
// FOUNDATION-NEXT: {{^}} func returnSomething() -> AnnotatedFrameworkClass?{{$}}
7980
// FOUNDATION-NEXT: {{^}} func noUnavailableTypesInSignature(){{$}}
8081
// FOUNDATION-NEXT: {{^}} @available(OSX 10.52, *){{$}}
@@ -87,6 +88,7 @@
8788
// FOUNDATION-LABEL: {{^}}/// Aaa. AnnotatedFrameworkProtocol. Bbb.
8889
// FOUNDATION-NEXT: {{^}}@available(OSX 10.9, *){{$}}
8990
// FOUNDATION-NEXT: {{^}}protocol AnnotatedFrameworkProtocol {{{$}}
91+
// FOUNDATION-NEXT: {{^}} @discardableResult
9092
// FOUNDATION-NEXT: {{^}} func returnSomething() -> AnnotatedFrameworkClass?{{$}}
9193

9294
// FOUNDATION-LABEL: /// Aaa. FrameworkClassConformingToUnannotatedFrameworkProtocol. Bbb.
@@ -99,6 +101,7 @@
99101
// FOUNDATION-NEXT: {{^}} @available(OSX 10.51, *){{$}}
100102
// FOUNDATION-NEXT: {{^}} func doSomething(withIUOClass k: AnnotatedFrameworkClass!){{$}}
101103
// FOUNDATION-NEXT: {{^}} @available(OSX 10.51, *){{$}}
104+
// FOUNDATION-NEXT: {{^}} @discardableResult
102105
// FOUNDATION-NEXT: {{^}} func returnSomething() -> AnnotatedFrameworkClass?{{$}}
103106
// FOUNDATION-NEXT: {{^}} func noUnavailableTypesInSignature(){{$}}
104107
// FOUNDATION-NEXT: {{^}} @available(OSX 10.52, *){{$}}
@@ -119,6 +122,7 @@
119122
// FOUNDATION-NEXT: {{^}} @available(OSX 10.52, *){{$}}
120123
// FOUNDATION-NEXT: {{^}} func doSomething(withIUOClass k: AnnotatedFrameworkClass!){{$}}
121124
// FOUNDATION-NEXT: {{^}} @available(OSX 10.52, *){{$}}
125+
// FOUNDATION-NEXT: {{^}} @discardableResult
122126
// FOUNDATION-NEXT: {{^}} func returnSomething() -> AnnotatedFrameworkClass?{{$}}
123127
// FOUNDATION-NEXT: {{^}} @available(OSX 10.52, *){{$}}
124128
// FOUNDATION-NEXT: {{^}} func noUnavailableTypesInSignature(){{$}}
@@ -134,6 +138,7 @@
134138
// FOUNDATION-NEXT: {{^}}class FrameworkClassConformingToLaterAnnotatedFrameworkProtocol : NSObject, LaterAnnotatedFrameworkProtocol {
135139
// FOUNDATION-NEXT: {{^}} init()
136140
// FOUNDATION-NEXT: {{^}} @available(OSX 10.52, *)
141+
// FOUNDATION-NEXT: {{^}} @discardableResult
137142
// FOUNDATION-NEXT: {{^}} func returnSomething() -> AnnotatedFrameworkClass?
138143
// FOUNDATION-NEXT: {{^}} @available(OSX 10.52, *)
139144
// FOUNDATION-NEXT: {{^}} func doSomething(with k: AnnotatedFrameworkClass, andLaterClass lk: AnnotatedLaterFrameworkClass)

test/SourceKit/DocSupport/doc_clang_module.swift.response

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7683,7 +7683,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
76837683
key.kind: source.lang.swift.decl.function.free,
76847684
key.name: "fooFunc1(_:)",
76857685
key.usr: "c:@F@fooFunc1",
7686-
key.doc.full_as_xml: "<Function file=Foo.h line=\"65\" column=\"5\"><Name>fooFunc1</Name><USR>c:@F@fooFunc1</USR><Declaration>@discardableResult func fooFunc1(_ a: Int32) -> Int32</Declaration><Abstract><Para> Aaa. fooFunc1. Bbb.</Para></Abstract></Function",
7686+
key.doc.full_as_xml: "<Function file=Foo.h line=\"65\" column=\"5\"><Name>fooFunc1</Name><USR>c:@F@fooFunc1</USR><Declaration>@discardableResult func fooFunc1(_ a: Int32) -> Int32</Declaration><Abstract><Para> Aaa. fooFunc1. Bbb.</Para></Abstract></Function>",
76877687
key.offset: 4409,
76887688
key.length: 34,
76897689
key.fully_annotated_decl: "<decl.function.free><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@discardableResult</syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFunc1</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:Vs5Int32\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>) -&gt; <decl.function.returntype><ref.struct usr=\"s:Vs5Int32\">Int32</ref.struct></decl.function.returntype></decl.function.free>",

0 commit comments

Comments
 (0)