Skip to content

Commit 9482e2a

Browse files
committed
[test] Update the tests
Some diagnostics got very bad due to the changes...
1 parent 4f5a5f5 commit 9482e2a

21 files changed

+280
-244
lines changed

test/1_stdlib/Renames.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ func _HashedCollection<K, V>(x: Dictionary<K, V>, i: Dictionary<K, V>.Index, k:
219219

220220
func _ImplicitlyUnwrappedOptional<T>(x: ImplicitlyUnwrappedOptional<T>) {
221221
_ = ImplicitlyUnwrappedOptional<T>() // expected-error {{'init()' is unavailable: Please use nil literal instead.}} {{none}}
222-
try! _ = ImplicitlyUnwrappedOptional<T>.map(x)() { _ in true } // expected-error {{'map' is unavailable: Has been removed in Swift 3.}}
223-
try! _ = ImplicitlyUnwrappedOptional<T>.flatMap(x)() { _ in true } // expected-error {{'flatMap' is unavailable: Has been removed in Swift 3.}}
222+
try! _ = ImplicitlyUnwrappedOptional<T>.map(x) { _ in true } // expected-error {{'map' is unavailable: Has been removed in Swift 3.}}
223+
try! _ = ImplicitlyUnwrappedOptional<T>.flatMap(x) { _ in true } // expected-error {{'flatMap' is unavailable: Has been removed in Swift 3.}}
224224
// FIXME: No way to call map and flatMap as method?
225225
// _ = (x as ImplicitlyUnwrappedOptional).map { _ in true } // xpected-error {{}} {{none}}
226226
// _ = (x as ImplicitlyUnwrappedOptional).flatMap { _ in true } // xpected-error {{}} {{none}}

test/1_stdlib/UnsafePointer.swift.gyb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ class Missile {
246246

247247
func checkPointerCorrectness(_ check: Check,
248248
_ withMissiles: Bool = false,
249-
_ f: (UnsafeMutablePointer<Missile>) ->
250-
(UnsafeMutablePointer<Missile>, count: Int) -> Void) {
249+
_ f: (UnsafeMutablePointer<Missile>,
250+
UnsafeMutablePointer<Missile>, count: Int) -> Void) {
251251
let ptr = UnsafeMutablePointer<Missile>.allocate(capacity: 4)
252252
switch check {
253253
case .RightOverlap:
@@ -256,7 +256,7 @@ func checkPointerCorrectness(_ check: Check,
256256
if withMissiles {
257257
(ptr + 2).initialize(to: Missile(3))
258258
}
259-
f(ptr + 1)(ptr, count: 2)
259+
f(ptr + 1, ptr, count: 2)
260260
expectEqual(1, ptr[1].number)
261261
expectEqual(2, ptr[2].number)
262262
case .LeftOverlap:
@@ -265,7 +265,7 @@ func checkPointerCorrectness(_ check: Check,
265265
}
266266
(ptr + 1).initialize(to: Missile(2))
267267
(ptr + 2).initialize(to: Missile(3))
268-
f(ptr)(ptr + 1, count: 2)
268+
f(ptr, ptr + 1, count: 2)
269269
expectEqual(2, ptr[0].number)
270270
expectEqual(3, ptr[1].number)
271271
case .Disjoint:
@@ -275,7 +275,7 @@ func checkPointerCorrectness(_ check: Check,
275275
}
276276
(ptr + 2).initialize(to: Missile(2))
277277
(ptr + 3).initialize(to: Missile(3))
278-
f(ptr)(ptr + 2, count: 2)
278+
f(ptr, ptr + 2, count: 2)
279279
expectEqual(2, ptr[0].number)
280280
expectEqual(3, ptr[1].number)
281281
// backwards
@@ -286,26 +286,28 @@ func checkPointerCorrectness(_ check: Check,
286286
(ptr2 + 2).initialize(to: Missile(2))
287287
(ptr2 + 3).initialize(to: Missile(3))
288288
}
289-
f(ptr2 + 2)(ptr2, count: 2)
289+
f(ptr2 + 2, ptr2, count: 2)
290290
expectEqual(0, ptr2[2].number)
291291
expectEqual(1, ptr2[3].number)
292292
}
293293
}
294294

295295
func checkPtr(
296-
_ f: ((UnsafeMutablePointer<Missile>) -> (UnsafeMutablePointer<Missile>, count: Int) -> Void),
296+
_ f: ((UnsafeMutablePointer<Missile>,
297+
UnsafeMutablePointer<Missile>, count: Int) -> Void),
297298
_ m: Bool
298299
) -> (Check) -> Void {
299300
return { checkPointerCorrectness($0, m, f) }
300301
}
301302

302303
func checkPtr(
303-
_ f: ((UnsafeMutablePointer<Missile>) -> (UnsafePointer<Missile>, count: Int) -> Void),
304+
_ f: ((UnsafeMutablePointer<Missile>,
305+
UnsafePointer<Missile>, count: Int) -> Void),
304306
_ m: Bool
305307
) -> (Check) -> Void {
306308
return {
307-
checkPointerCorrectness($0, m) { destPtr in
308-
return { f(destPtr)(UnsafeMutablePointer($0), count: $1) }
309+
checkPointerCorrectness($0, m) { destPtr, srcPtr, count in
310+
f(destPtr, UnsafeMutablePointer(srcPtr), count: count)
309311
}
310312
}
311313
}

test/1_stdlib/UnsafeRawPointer.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,53 +148,55 @@ enum Check {
148148
}
149149

150150
func checkRawPointerCorrectness(_ check: Check,
151-
_ f: (UnsafeMutableRawPointer) -> (as: Int.Type, from: UnsafeMutablePointer<Int>, count: Int) -> UnsafeMutablePointer<Int>) {
151+
_ f: (UnsafeMutableRawPointer,
152+
as: Int.Type, from: UnsafeMutablePointer<Int>, count: Int)
153+
-> UnsafeMutablePointer<Int>) {
152154
let ptr = UnsafeMutablePointer<Int>.allocate(capacity: 4)
153155
switch check {
154156
case .RightOverlap:
155157
ptr.initialize(to: 1)
156158
(ptr + 1).initialize(to: 2)
157-
_ = f(UnsafeMutableRawPointer(ptr + 1))(as: Int.self, from: ptr, count: 2)
159+
_ = f(UnsafeMutableRawPointer(ptr + 1), as: Int.self, from: ptr, count: 2)
158160
expectEqual(1, ptr[1])
159161
expectEqual(2, ptr[2])
160162
case .LeftOverlap:
161163
(ptr + 1).initialize(to: 2)
162164
(ptr + 2).initialize(to: 3)
163-
_ = f(UnsafeMutableRawPointer(ptr))(as: Int.self, from: ptr + 1, count: 2)
165+
_ = f(UnsafeMutableRawPointer(ptr), as: Int.self, from: ptr + 1, count: 2)
164166
expectEqual(2, ptr[0])
165167
expectEqual(3, ptr[1])
166168
case .Disjoint:
167169
(ptr + 2).initialize(to: 2)
168170
(ptr + 3).initialize(to: 3)
169-
_ = f(UnsafeMutableRawPointer(ptr))(as: Int.self, from: ptr + 2, count: 2)
171+
_ = f(UnsafeMutableRawPointer(ptr), as: Int.self, from: ptr + 2, count: 2)
170172
expectEqual(2, ptr[0])
171173
expectEqual(3, ptr[1])
172174
// backwards
173175
let ptr2 = UnsafeMutablePointer<Int>.allocate(capacity: 4)
174176
ptr2.initialize(to: 0)
175177
(ptr2 + 1).initialize(to: 1)
176-
_ = f(UnsafeMutableRawPointer(ptr2 + 2))(as: Int.self, from: ptr2, count: 2)
178+
_ = f(UnsafeMutableRawPointer(ptr2 + 2), as: Int.self, from: ptr2, count: 2)
177179
expectEqual(0, ptr2[2])
178180
expectEqual(1, ptr2[3])
179181
}
180182
}
181183

182184
func checkPtr(
183-
_ f: ((UnsafeMutableRawPointer)
184-
-> (as: Int.Type, from: UnsafeMutablePointer<Int>, count: Int)
185+
_ f: ((UnsafeMutableRawPointer,
186+
as: Int.Type, from: UnsafeMutablePointer<Int>, count: Int)
185187
-> UnsafeMutablePointer<Int>)
186188
) -> (Check) -> Void {
187189
return { checkRawPointerCorrectness($0, f) }
188190
}
189191

190192
func checkPtr(
191-
_ f: ((UnsafeMutableRawPointer)
192-
-> (as: Int.Type, from: UnsafePointer<Int>, count: Int)
193+
_ f: ((UnsafeMutableRawPointer,
194+
as: Int.Type, from: UnsafePointer<Int>, count: Int)
193195
-> UnsafeMutablePointer<Int>)
194196
) -> (Check) -> Void {
195197
return {
196-
checkRawPointerCorrectness($0) { destPtr in
197-
return { f(destPtr)(as: $0, from: UnsafeMutablePointer($1), count: $2) }
198+
checkRawPointerCorrectness($0) { destPtr, type, srcPtr, count in
199+
f(destPtr, as: type, from: UnsafeMutablePointer(srcPtr), count: count)
198200
}
199201
}
200202
}

test/ClangModules/objc_parse.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ func testPreferClassMethodToCurriedInstanceMethod(_ obj: NSObject) {
373373
// FIXME: We shouldn't need the ": Bool" type annotation here.
374374
// <rdar://problem/18006008>
375375
let _: Bool = NSObject.isEqual(obj)
376-
_ = NSObject.isEqual(obj) as (NSObject!) -> Bool // no-warning
376+
_ = NSObject.isEqual as (NSObject, NSObject) -> Bool // no-warning
377+
_ = obj.isEqual as (NSObject!) -> Bool
377378
}
378379

379380

@@ -598,4 +599,3 @@ func testNSUInteger(_ obj: NSUIntegerTests, uint: UInt, int: Int) {
598599
let num = NSNumber(value: uint)
599600
let _: String = num.uintValue // expected-error {{cannot convert value of type 'UInt' to specified type 'String'}}
600601
}
601-

test/Constraints/diagnostics.swift

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ func validateSaveButton(_ text: String) {
205205
// <rdar://problem/20201968> QoI: poor diagnostic when calling a class method via a metatype
206206
class r20201968C {
207207
func blah() {
208-
r20201968C.blah() // expected-error {{use of instance member 'blah' on type 'r20201968C'; did you mean to use a value of type 'r20201968C' instead?}}
208+
r20201968C.blah() // FIXME-error {{use of instance member 'blah' on type 'r20201968C'; did you mean to use a value of type 'r20201968C' instead?}}
209+
// expected-error @-1 {{missing argument for parameter #1 in call}}
209210
}
210211
}
211212

@@ -363,8 +364,8 @@ f8(b: 1.0) // expected-error {{cannot convert value of type 'Double' to
363364

364365
class CurriedClass {
365366
func method1() {}
366-
func method2(_ a: Int) -> (b : Int) -> () { return { b in () } }
367-
func method3(_ a: Int, b : Int) {}
367+
func method2(_ a: Int) -> (b: Int) -> () { return { b in () } }
368+
func method3(_ a: Int, b: Int) {}
368369
}
369370

370371
let c = CurriedClass()
@@ -379,29 +380,28 @@ c.method2(1)(b: 2.0) // expected-error {{cannot convert value of type 'Double' t
379380
c.method2(1.0)(b: 2) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
380381
c.method2(1.0)(b: 2.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
381382

382-
CurriedClass.method1(c)()
383-
_ = CurriedClass.method1(c)
384-
CurriedClass.method1(c)(1) // expected-error {{argument passed to call that takes no arguments}}
385-
CurriedClass.method1(2.0)(1) // expected-error {{use of instance member 'method1' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
386-
387-
CurriedClass.method2(c)(32)(b: 1)
388-
_ = CurriedClass.method2(c)
389-
_ = CurriedClass.method2(c)(32)
390-
_ = CurriedClass.method2(1,2) // expected-error {{use of instance member 'method2' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
391-
CurriedClass.method2(c)(1.0)(b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
392-
CurriedClass.method2(c)(1)(b: 1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
393-
CurriedClass.method2(c)(2)(c: 1.0) // expected-error {{incorrect argument label in call (have 'c:', expected 'b:')}}
394-
395-
CurriedClass.method3(c)(32, b: 1)
396-
_ = CurriedClass.method3(c)
397-
_ = CurriedClass.method3(c)(1, 2) // expected-error {{missing argument label 'b:' in call}} {{32-32=b: }}
398-
_ = CurriedClass.method3(c)(1, b: 2)(32) // expected-error {{cannot call value of non-function type '()'}}
399-
_ = CurriedClass.method3(1, 2) // expected-error {{use of instance member 'method3' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
400-
CurriedClass.method3(c)(1.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
401-
CurriedClass.method3(c)(1) // expected-error {{missing argument for parameter 'b' in call}}
402-
403-
CurriedClass.method3(c)(c: 1.0) // expected-error {{missing argument for parameter 'b' in call}}
404-
383+
CurriedClass.method1(c)
384+
CurriedClass.method1(c, 1) // expected-error {{extra argument in call}}
385+
CurriedClass.method1(2.0)(1) // FIXME-error {{use of instance member 'method1' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
386+
// expected-error @-1 {{cannot convert value of type 'Double' to expected argument type 'CurriedClass'}}
387+
388+
CurriedClass.method2(c, 32)(b: 1)
389+
_ = CurriedClass.method2(c, 32)
390+
_ = CurriedClass.method2(1,2) // FIXME-error {{use of instance member 'method2' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
391+
// expected-error @-1 {{cannot convert value of type 'Int' to expected argument type 'CurriedClass'}}
392+
CurriedClass.method2(c, 1.0)(b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
393+
CurriedClass.method2(c, 1)(b: 1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
394+
CurriedClass.method2(c, 2)(c: 1.0) // expected-error {{incorrect argument label in call (have 'c:', expected 'b:')}}
395+
396+
CurriedClass.method3(c, 32, b: 1)
397+
_ = CurriedClass.method3(c, 1, 2) // expected-error {{missing argument label 'b:' in call}} {{32-32=b: }}
398+
_ = CurriedClass.method3(c, 1, b: 2)(32) // expected-error {{cannot call value of non-function type '()'}}
399+
_ = CurriedClass.method3(1, 2) // FIXME-error {{use of instance member 'method3' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
400+
// expected-error @-1 {{missing argument for parameter 'b' in call}}
401+
CurriedClass.method3(c, 1.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
402+
CurriedClass.method3(c, 1) // expected-error {{missing argument for parameter 'b' in call}}
403+
404+
CurriedClass.method3(c, c: 1.0) // expected-error {{missing argument for parameter 'b' in call}}
405405

406406
extension CurriedClass {
407407
func f() {
@@ -419,15 +419,12 @@ extension CurriedClass {
419419
}
420420

421421
// <rdar://problem/23718816> QoI: "Extra argument" error when accidentally currying a method
422-
CurriedClass.m1(2, b: 42) // expected-error {{use of instance member 'm1' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
423-
422+
CurriedClass.m1(2, b: 42) // FIXME-error {{use of instance member 'm1' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
423+
// expected-error @-1 {{missing argument for parameter #2 in call}}
424424

425425
// <rdar://problem/22108559> QoI: Confusing error message when calling an instance method as a class method
426-
CurriedClass.m2(12) // expected-error {{use of instance member 'm2' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
427-
428-
429-
430-
426+
CurriedClass.m2(12) // FIXME-error {{use of instance member 'm2' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
427+
// expected-error @-1 {{missing argument for parameter #2 in call}}
431428

432429
// <rdar://problem/19870975> Incorrect diagnostic for failed member lookups within closures passed as arguments ("(_) -> _")
433430
func ident<T>(_ t: T) -> T {}

test/Constraints/existential_metatypes.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ class Something {
8383

8484

8585
func testP3(_ p: P3, something: Something) {
86-
p.withP3(Something.takeP3(something))
86+
p.withP3(something.takeP3)
87+
p.withP3 { Something.takeP3(something, $0) }
8788
}

test/Constraints/lvalues.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct FooStruct {
148148
}
149149

150150
func testFooStruct() {
151-
FooStruct.instanceFunc0(FooStruct())()
151+
FooStruct.instanceFunc0(FooStruct())
152152
}
153153

154154
// Don't load from explicit lvalues.
@@ -232,4 +232,3 @@ func r23331567(_ fn: (x: inout Int) -> Void) {
232232
fn(x: &a)
233233
}
234234
r23331567 { $0 += 1 }
235-

test/Constraints/members.swift

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var i : Int
2525
var x : X
2626
var yf : Y<Float>
2727

28-
func g0(_: (inout X) -> (Float) -> ()) {}
28+
func g0(_: (inout X, Float) -> ()) {}
2929

3030
_ = x.f0(i)
3131
x.f0(i).f1(i)
@@ -193,30 +193,27 @@ func generic<T: P>(_ t: T) {
193193
let _: () -> () = id(T.tum)
194194

195195
// Instance member of archetype metatype
196-
let _: (T) -> (Int) -> () = id(T.bar)
197-
let _: (Int) -> () = id(T.bar(t))
196+
let _: (T, Int) -> () = id(T.bar)
197+
let _: () = id(T.bar(t, 0))
198198

199199
_ = t.mut // expected-error{{partial application of 'mutating' method is not allowed}}
200200
_ = t.tum // expected-error{{static member 'tum' cannot be used on instance of type 'T'}}
201201

202202
// Instance member of extension returning Self)
203-
let _: (T) -> () -> T = id(T.returnSelfInstance)
204-
let _: () -> T = id(T.returnSelfInstance(t))
205-
let _: T = id(T.returnSelfInstance(t)())
203+
let _: (T) -> T = id(T.returnSelfInstance)
204+
let _: T = id(T.returnSelfInstance(t))
206205

207206
let _: () -> T = id(t.returnSelfInstance)
208207
let _: T = id(t.returnSelfInstance())
209208

210-
let _: (T) -> (Bool) -> T? = id(T.returnSelfOptionalInstance)
211-
let _: (Bool) -> T? = id(T.returnSelfOptionalInstance(t))
212-
let _: T? = id(T.returnSelfOptionalInstance(t)(false))
209+
let _: (T, Bool) -> T? = id(T.returnSelfOptionalInstance)
210+
let _: T? = id(T.returnSelfOptionalInstance(t, false))
213211

214212
let _: (Bool) -> T? = id(t.returnSelfOptionalInstance)
215213
let _: T? = id(t.returnSelfOptionalInstance(true))
216214

217-
let _: (T) -> (Bool) -> T! = id(T.returnSelfIUOInstance)
218-
let _: (Bool) -> T! = id(T.returnSelfIUOInstance(t))
219-
let _: T! = id(T.returnSelfIUOInstance(t)(true))
215+
let _: (T, Bool) -> T! = id(T.returnSelfIUOInstance)
216+
let _: T! = id(T.returnSelfIUOInstance(t, true))
220217

221218
let _: (Bool) -> T! = id(t.returnSelfIUOInstance)
222219
let _: T! = id(t.returnSelfIUOInstance(true))
@@ -238,9 +235,8 @@ func genericClassP<T: ClassP>(_ t: T) {
238235
let _: () = id(t.bas(0))
239236

240237
// Instance member of archetype metatype)
241-
let _: (T) -> (Int) -> () = id(T.bas)
242-
let _: (Int) -> () = id(T.bas(t))
243-
let _: () = id(T.bas(t)(1))
238+
let _: (T, Int) -> () = id(T.bas)
239+
let _: () = id(T.bas(t, 1))
244240
}
245241

246242
////
@@ -273,14 +269,12 @@ func staticExistential(_ p: P.Type, pp: P.Protocol) {
273269
_ = P() // expected-error{{protocol type 'P' cannot be instantiated}}
274270

275271
// Instance member of metatype
276-
let _: (P) -> (Int) -> () = P.bar
277-
let _: (Int) -> () = P.bar(ppp)
278-
P.bar(ppp)(5)
272+
let _: (P, Int) -> () = P.bar
273+
P.bar(ppp, 5)
279274

280275
// Instance member of metatype value
281-
let _: (P) -> (Int) -> () = pp.bar
282-
let _: (Int) -> () = pp.bar(ppp)
283-
pp.bar(ppp)(5)
276+
let _: (P, Int) -> () = pp.bar
277+
pp.bar(ppp, 5)
284278

285279
// Static member of existential metatype value
286280
let _: () -> () = p.tum
@@ -319,9 +313,10 @@ func existentialClassP(_ p: ClassP) {
319313
let _: () = id(p.bas(0))
320314

321315
// Instance member of existential metatype)
322-
let _: (ClassP) -> (Int) -> () = id(ClassP.bas)
323-
let _: (Int) -> () = id(ClassP.bas(p))
324-
let _: () = id(ClassP.bas(p)(1))
316+
let _: (ClassP, Int) -> () = id(ClassP.bas)
317+
let _: (Int) -> () = id(p.bas)
318+
let _: (Int) -> () = id({ ClassP.bas(p, $0) })
319+
let _: () = id(ClassP.bas(p, 1))
325320
}
326321

327322
// Partial application of curried protocol methods
@@ -377,7 +372,7 @@ class InstanceOrClassMethod {
377372
func testPreferClassMethodToCurriedInstanceMethod(_ obj: InstanceOrClassMethod) {
378373
let result = InstanceOrClassMethod.method(obj)
379374
let _: Bool = result // no-warning
380-
let _: () -> Bool = InstanceOrClassMethod.method(obj)
375+
let _: Bool = InstanceOrClassMethod.method(obj)
381376
}
382377

383378
protocol Numeric {
@@ -557,4 +552,3 @@ enum SomeErrorType {
557552
return nil
558553
}
559554
}
560-

0 commit comments

Comments
 (0)