Skip to content

Commit 4132aa0

Browse files
committed
[Tests] NFC: Update all of the test-cases improved by changes to generic argument mismatch handling
1 parent 7305275 commit 4132aa0

25 files changed

+120
-49
lines changed

test/ClangImporter/MixedSource/mixed-target-using-header.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ func testProtocolNamingConflict() {
6666
let a: ConflictingName1?
6767
var b: ConflictingName1Protocol?
6868
b = a // expected-error {{cannot assign value of type 'ConflictingName1?' to type '(any ConflictingName1Protocol)?'}}
69+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('ConflictingName1' and 'any ConflictingName1Protocol') are expected to be equal}}
6970
_ = b
7071

7172
let c: ConflictingName2?
7273
var d: ConflictingName2Protocol?
7374
d = c // expected-error {{cannot assign value of type 'ConflictingName2?' to type '(any ConflictingName2Protocol)?'}}
75+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('ConflictingName2' and 'any ConflictingName2Protocol') are expected to be equal}}
7476
_ = d
7577
}
7678

test/ClangImporter/cf.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func testOutParametersGood() {
118118
func testOutParametersBad() {
119119
let fridge: CCRefrigerator?
120120
CCRefrigeratorCreateIndirect(fridge) // expected-error {{cannot convert value of type 'CCRefrigerator?' to expected argument type 'UnsafeMutablePointer<CCRefrigerator?>?'}}
121+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('CCRefrigerator' and 'UnsafeMutablePointer<CCRefrigerator?>') are expected to be equal}}
121122

122123
let power: CCPowerSupply?
123124
CCRefrigeratorGetPowerSupplyIndirect(0, power)
@@ -128,21 +129,26 @@ func testOutParametersBad() {
128129
CCRefrigeratorGetItemUnaudited(0, 0, item)
129130
// expected-error@-1:34 {{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator'}}
130131
// expected-error@-2:40 {{cannot convert value of type 'CCItem?' to expected argument type 'UnsafeMutablePointer<Unmanaged<CCItem>?>?'}}
132+
// expected-note@-3 {{arguments to generic parameter 'Wrapped' ('CCItem' and 'UnsafeMutablePointer<Unmanaged<CCItem>?>') are expected to be equal}}
131133
}
132134

133135
func nameCollisions() {
134136
var objc: MyProblematicObject?
135137
var cf: MyProblematicObjectRef?
136138
cf = objc // expected-error {{cannot assign value of type 'MyProblematicObject?' to type 'MyProblematicObjectRef?'}}
139+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicObject' and 'MyProblematicObjectRef') are expected to be equal}}
137140
objc = cf // expected-error {{cannot assign value of type 'MyProblematicObjectRef?' to type 'MyProblematicObject?'}}
141+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicObjectRef' and 'MyProblematicObject') are expected to be equal}}
138142

139143
var cfAlias: MyProblematicAliasRef?
140144
cfAlias = cf // okay
141145
cf = cfAlias // okay
142146

143147
var otherAlias: MyProblematicAlias?
144148
otherAlias = cfAlias // expected-error {{cannot assign value of type 'MyProblematicAliasRef?' (aka 'Optional<MyProblematicObjectRef>') to type 'MyProblematicAlias?' (aka 'Optional<Float>')}}
149+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicAliasRef' (aka 'MyProblematicObjectRef') and 'MyProblematicAlias' (aka 'Float')) are expected to be equal}}
145150
cfAlias = otherAlias // expected-error {{cannot assign value of type 'MyProblematicAlias?' (aka 'Optional<Float>') to type 'MyProblematicAliasRef?' (aka 'Optional<MyProblematicObjectRef>')}}
151+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicAlias' (aka 'Float') and 'MyProblematicAliasRef' (aka 'MyProblematicObjectRef')) are expected to be equal}}
146152

147153
func isOptionalFloat(_: inout Optional<Float>) {}
148154
isOptionalFloat(&otherAlias) // okay

test/ClangImporter/ctypes_parse.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ func testFunctionPointers() {
214214

215215
useFunctionPointer2(anotherFP)
216216
sizedFP = fp // expected-error {{cannot assign value of type 'fptr?' (aka 'Optional<@convention(c) (Int32) -> Int32>') to type '(@convention(c) (CInt, CInt, UnsafeMutableRawPointer?) -> Void)?'}}
217+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('fptr' (aka '@convention(c) (Int32) -> Int32') and '@convention(c) (CInt, CInt, UnsafeMutableRawPointer?) -> Void'}}
217218
}
218219

219220
func testStructDefaultInit() {

test/Constraints/bridging-nsnumber-and-nsvalue.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func bridgeNSNumberBackToSpecificType(object: ${ObjectType},
6262
_ = object as? ${Type}
6363
_ = object as! ${Type}
6464

65-
_ = optional as ${Type}? // expected-error{{is not convertible to}} expected-note {{use 'as!'}}
65+
_ = optional as ${Type}? // expected-error{{cannot convert value of type '${ObjectType}?' to type '${Type}?' in coercion}} expected-note {{arguments to generic parameter 'Wrapped' ('${ObjectType}' and '${Type}') are expected to be equal}}
6666
_ = optional is ${Type}?
6767
_ = optional as? ${Type}?
6868
_ = optional as! ${Type}?

test/Constraints/bridging.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,17 @@ func rdar19831698() {
283283
// <rdar://problem/19836341> Incorrect fixit for NSString? to String? conversions
284284
func rdar19836341(_ ns: NSString?, vns: NSString?) {
285285
var vns = vns
286-
let _: String? = ns // expected-error{{cannot convert value of type 'NSString?' to specified type 'String?'}}{{22-22= as String?}}
287-
var _: String? = ns // expected-error{{cannot convert value of type 'NSString?' to specified type 'String?'}}{{22-22= as String?}}
286+
let _: String? = ns // expected-error{{cannot assign value of type 'NSString?' to type 'String?'}}{{22-22= as String?}}
287+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('NSString' and 'String') are expected to be equal}}
288+
var _: String? = ns // expected-error{{cannot assign value of type 'NSString?' to type 'String?'}}{{22-22= as String?}}
289+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('NSString' and 'String') are expected to be equal}}
288290

289291
// Important part about below diagnostic is that from-type is described as
290292
// 'NSString?' and not '@lvalue NSString?':
291-
let _: String? = vns // expected-error{{cannot convert value of type 'NSString?' to specified type 'String?'}}{{23-23= as String?}}
292-
var _: String? = vns // expected-error{{cannot convert value of type 'NSString?' to specified type 'String?'}}{{23-23= as String?}}
293+
let _: String? = vns // expected-error{{cannot assign value of type 'NSString?' to type 'String?'}}{{23-23= as String?}}
294+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('NSString' and 'String') are expected to be equal}}
295+
var _: String? = vns // expected-error{{cannot assign value of type 'NSString?' to type 'String?'}}{{23-23= as String?}}
296+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('NSString' and 'String') are expected to be equal}}
293297

294298
vns = ns
295299
}
@@ -300,15 +304,17 @@ func rdar20029786(_ ns: NSString?) {
300304
// expected-error@-1 {{cannot convert value of type 'NSString?' to expected argument type 'String?'}} {{21-21= as String?}}
301305
var s2 = ns ?? "str" as String as String // expected-error {{binary operator '??' cannot be applied to operands of type 'NSString?' and 'String'}}
302306

303-
let s3: NSString? = "str" as String? // expected-error {{cannot convert value of type 'String?' to specified type 'NSString?'}}{{39-39= as NSString?}}
307+
let s3: NSString? = "str" as String? // expected-error {{cannot assign value of type 'String?' to type 'NSString?'}}{{39-39= as NSString?}}
308+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('String' and 'NSString') are expected to be equal}}
304309

305310
var s4: String = ns ?? "str" // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{20-20=(}} {{31-31=) as String}}
306311
var s5: String = (ns ?? "str") as String // fixed version
307312
}
308313

309314
// Make sure more complicated cast has correct parenthesization
310315
func castMoreComplicated(anInt: Int?) {
311-
let _: (NSObject & NSCopying)? = anInt // expected-error{{cannot convert value of type 'Int?' to specified type '(any NSObject & NSCopying)?'}}{{41-41= as (any NSObject & NSCopying)?}}
316+
let _: (NSObject & NSCopying)? = anInt // expected-error{{cannot assign value of type 'Int?' to type '(any NSObject & NSCopying)?'}}{{41-41= as (any NSObject & NSCopying)?}}
317+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('Int' and 'any NSObject & NSCopying') are expected to be equal}}
312318
}
313319

314320

test/Constraints/casts_objc.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ func optionalityMismatchingCasts(f: CGFloat, n: NSNumber, fooo: CGFloat???,
8282
nooo: NSNumber???) {
8383
_ = f as NSNumber?
8484
_ = f as NSNumber??
85-
let _ = fooo as NSNumber?? // expected-error{{'CGFloat???' is not convertible to 'NSNumber??'}}
86-
//expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{16-18=as!}}
85+
let _ = fooo as NSNumber?? // expected-error{{cannot convert value of type 'CGFloat???' to type 'NSNumber??' in coercion}}
86+
//expected-note@-1 {{arguments to generic parameter 'Wrapped' ('CGFloat?' and 'NSNumber') are expected to be equal}}
8787
let _ = fooo as NSNumber???? // okay: injects extra optionals
8888
}
8989

test/Constraints/fixes.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,14 @@ struct Q {
158158
let s: String?
159159
}
160160
let q = Q(s: nil)
161-
let a: Int? = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
162-
// expected-error@-1 {{cannot convert value of type 'String.UTF8View?' to specified type 'Int?'}}
163-
// expected-note@-2{{chain the optional using '?'}}{{18-18=?}}
164-
let b: Int = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
161+
let a: Int? = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}} expected-note {{chain the optional using '?'}}{{18-18=?}}
162+
// expected-error@-1 {{cannot assign value of type 'String.UTF8View?' to type 'Int?'}}
163+
// expected-note@-2 {{arguments to generic parameter 'Wrapped' ('String.UTF8View' and 'Int') are expected to be equal}}
164+
let b: Int = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}} expected-note {{chain the optional using '?'}}{{17-17=?}} expected-note {{force-unwrap using '!'}}{{17-17=!}}
165165
// expected-error@-1 {{cannot convert value of type 'String.UTF8View' to specified type 'Int'}}
166-
// expected-note@-2{{chain the optional using '?'}}{{17-17=?}}
167-
// expected-note@-3{{force-unwrap using '!'}}{{17-17=!}}
168-
let d: Int! = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
169-
// expected-error@-1 {{cannot convert value of type 'String.UTF8View?' to specified type 'Int?'}}
170-
// expected-note@-2{{chain the optional using '?'}}{{18-18=?}}
166+
let d: Int! = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}} expected-note {{chain the optional using '?'}}{{18-18=?}}
167+
// expected-error@-1 {{cannot assign value of type 'String.UTF8View?' to type 'Int?'}}
168+
// expected-note@-2 {{arguments to generic parameter 'Wrapped' ('String.UTF8View' and 'Int') are expected to be equal}}
171169
let c = q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
172170
// expected-note@-1{{chain the optional using '?' to access member 'utf8' only for non-'nil' base values}}{{12-12=?}}
173171
// expected-note@-2{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}{{12-12=!}}

test/Constraints/invalid_implicit_conversions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func test(
2929

3030
takesAutoclosure(rawPtr, a) // expected-error {{cannot perform pointer conversion of value of type '[Int]' to autoclosure result type 'UnsafeRawPointer'}}
3131
takesAutoclosure(ptr, a) // expected-error {{cannot perform pointer conversion of value of type '[Int]' to autoclosure result type 'UnsafePointer<Int>'}}
32-
takesAutoclosure(optPtr, b) // expected-error {{cannot perform pointer conversion of value of type '[Int]?' to autoclosure result type 'UnsafePointer<Int>?'}}
32+
takesAutoclosure(optPtr, b) // expected-error {{conflicting arguments to generic parameter 'T' ('UnsafePointer<Int>?' vs. '[Int]?')}}
3333

3434
takesAutoclosure(rawPtr, s) // expected-error {{cannot perform pointer conversion of value of type 'String' to autoclosure result type 'UnsafeRawPointer'}}
3535
takesAutoclosure(ptrI8, s) // expected-error {{cannot perform pointer conversion of value of type 'String' to autoclosure result type 'UnsafePointer<Int8>'}}

test/Constraints/issue-81023.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// https://github.com/swiftlang/swift/issues/81023
4+
5+
protocol MyPublisher {
6+
associatedtype Output
7+
associatedtype Failure: Error
8+
func eraseToAnyPublisher() -> MyAnyPublisher<Output, Failure>
9+
}
10+
11+
extension MyPublisher {
12+
func eraseToAnyPublisher() -> MyAnyPublisher<Output, Failure> {
13+
fatalError()
14+
}
15+
}
16+
17+
struct MyAnyPublisher<Output, Failure: Error>: MyPublisher {}
18+
struct MyJust<Output>: MyPublisher {
19+
typealias Failure = Never
20+
init(_ value: Output) {}
21+
}
22+
23+
extension MyPublisher where Output == (any Collection)? { // expected-note {{where 'Self.Output' = '[Int]?'}}
24+
func mapCount() -> MyAnyPublisher<Int, Failure> { fatalError() }
25+
}
26+
27+
func test(myPub: MyAnyPublisher<[Int]?, Never>) {
28+
myPub.mapCount()
29+
// expected-error@-1 {{referencing instance method 'mapCount()' on 'MyPublisher' requires the types '[Int]?' and '(any Collection)?' be equivalent}}
30+
}

test/Constraints/iuo.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ let _ = (returnsIUO as () -> Int)() // expected-error {{cannot convert value of
216216
// Make sure we only permit an IUO unwrap on the first application.
217217
func returnsIUOFn() -> (() -> Int?)! { nil }
218218
let _: (() -> Int?)? = returnsIUOFn()
219-
let _: (() -> Int)? = returnsIUOFn() // expected-error {{cannot convert value of type '(() -> Int?)?' to specified type '(() -> Int)?'}}
219+
let _: (() -> Int)? = returnsIUOFn() // expected-error {{cannot assign value of type '(() -> Int?)?' to type '(() -> Int)?'}}
220+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('() -> Int?' and '() -> Int') are expected to be equal}}
220221
let _: () -> Int? = returnsIUOFn()
221222
let _: () -> Int = returnsIUOFn() // expected-error {{cannot convert value of type '(() -> Int?)?' to specified type '() -> Int'}}
222223
let _: Int? = returnsIUOFn()()

test/Constraints/keypath.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Demo {
3434

3535
let some = Some(keyPath: \Demo.here)
3636
// expected-error@-1 {{cannot convert value of type 'KeyPath<Demo, (() -> Void)?>' to expected argument type 'KeyPath<Demo, ((V) -> Void)?>'}}
37-
// expected-note@-2 {{arguments to generic parameter 'Value' ('(() -> Void)?' and '((V) -> Void)?') are expected to be equal}}
37+
// expected-note@-2 {{arguments to generic parameter 'Wrapped' ('() -> Void' and '(V) -> Void') are expected to be equal}}
3838
// expected-error@-3 {{generic parameter 'V' could not be inferred}}
3939
// expected-note@-4 {{explicitly specify the generic arguments to fix this issue}}
4040

test/Constraints/operator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ func rdar60727310() {
278278
func myAssertion<T>(_ a: T, _ op: ((T,T)->Bool), _ b: T) {}
279279
var e: Error? = nil
280280
myAssertion(e, ==, nil) // expected-error {{cannot convert value of type '(any Error)?' to expected argument type '(any (~Copyable & ~Escapable).Type)?'}}
281+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('any Error' and 'any (~Copyable & ~Escapable).Type') are expected to be equal}}
281282
}
282283

283284
// https://github.com/apple/swift/issues/54877

test/Constraints/subscript.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ let squares = [ 1, 2, 3 ].reduce([:]) { (dict, n) in
113113
func r23670252(_ dictionary: [String : AnyObject], someObject: AnyObject) {
114114
let color : String?
115115
color = dictionary["color"] // expected-error {{cannot assign value of type 'AnyObject?' to type 'String?'}}
116+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('AnyObject' and 'String') are expected to be equal}}
116117
_ = color
117118
}
118119

test/Constraints/swift_to_c_pointer_conversions.swift.gyb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func test_${TestPtrSize}_bit_ptrs(sptr: UnsafePointer<Int${TestPtrSize}>,
5959
% end
6060

6161
% for pointer in ['osptr', 'ouptr']:
62-
opt_char_ptr_func(${pointer}) // expected-error {{}}
62+
opt_char_ptr_func(${pointer}) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
6363
const_opt_char_ptr_func(${pointer}) // Ok
6464
unsigned_opt_char_ptr_func(${pointer}) // expected-error {{}}
6565
const_opt_unsigned_char_ptr_func(${pointer}) // Ok
@@ -96,13 +96,13 @@ func test_${TestPtrSize}_bit_ptrs(sptr: UnsafePointer<Int${TestPtrSize}>,
9696
% for pointer in ['osptr', 'ouptr']:
9797
% for Size in ['16', '32', '64']:
9898
% if Size == TestPtrSize:
99-
opt_int_${TestPtrSize}_ptr_func(${pointer}) // expected-error {{}}
100-
opt_uint_${TestPtrSize}_ptr_func(${pointer}) // expected-error {{}}
99+
opt_int_${TestPtrSize}_ptr_func(${pointer}) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
100+
opt_uint_${TestPtrSize}_ptr_func(${pointer}) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
101101
const_opt_int_${TestPtrSize}_ptr_func(${pointer}) // Ok
102102
const_opt_uint_${TestPtrSize}_ptr_func(${pointer}) // Ok
103103
% else:
104-
opt_int_${Size}_ptr_func(${pointer}) // expected-error {{}}
105-
opt_uint_${Size}_ptr_func(${pointer}) // expected-error {{}}
104+
opt_int_${Size}_ptr_func(${pointer}) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
105+
opt_uint_${Size}_ptr_func(${pointer}) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
106106
const_opt_int_${Size}_ptr_func(${pointer}) // expected-error {{}} expected-note {{}}
107107
const_opt_uint_${Size}_ptr_func(${pointer}) // expected-error {{}} expected-note {{}}
108108
% end
@@ -215,7 +215,7 @@ func test_raw_ptr_value_to_optional_promotion(
215215
func test_raw_ptr_optional_to_optional_conversion(
216216
riptr: UnsafeRawPointer?,
217217
rmptr: UnsafeMutableRawPointer?) {
218-
opt_char_ptr_func(riptr) // expected-error {{}}
218+
opt_char_ptr_func(riptr) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
219219
const_opt_char_ptr_func(riptr) // Ok
220220

221221
opt_char_ptr_func(rmptr) // Ok
@@ -226,11 +226,11 @@ func test_raw_ptr_optional_to_optional_conversion(
226226

227227
% for Ptr in ['riptr', 'rmptr']:
228228
% for Size in ['16', '32', '64']:
229-
opt_int_${Size}_ptr_func(${Ptr}) // expected-error {{}}
230-
opt_uint_${Size}_ptr_func(${Ptr}) // expected-error {{}}
229+
opt_int_${Size}_ptr_func(${Ptr}) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
230+
opt_uint_${Size}_ptr_func(${Ptr}) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
231231

232-
const_opt_int_${Size}_ptr_func(${Ptr}) // expected-error {{}}
233-
const_opt_uint_${Size}_ptr_func(${Ptr}) // expected-error {{}}
232+
const_opt_int_${Size}_ptr_func(${Ptr}) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
233+
const_opt_uint_${Size}_ptr_func(${Ptr}) // expected-error {{}} expected-note {{arguments to generic parameter 'Wrapped'}}
234234
% end
235235
% end
236236
}

test/Constraints/tuple.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ var optionalTuple3: (UInt64, Int)? = (bignum, 1) // expected-error {{cannot conv
340340
optionalTuple = (bignum, 1) // expected-error {{cannot assign value of type '(Int64, Int)' to type '(Int, Int)'}}
341341
// Optional to Optional
342342
optionalTuple = optionalTuple2 // expected-error {{cannot assign value of type '(Int64, Int)?' to type '(Int, Int)?'}}
343+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('(Int64, Int)' and '(Int, Int)') are expected to be equal}}
343344

344345
func testTupleLabelMismatchFuncConversion(fn1: @escaping ((x: Int, y: Int)) -> Void,
345346
fn2: @escaping () -> (x: Int, Int)) {

test/Constraints/tuple_arguments.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,7 @@ do {
16601660
func foo(_: (() -> Void)?) {}
16611661
func bar() -> ((()) -> Void)? { return nil }
16621662
foo(bar()) // expected-error {{cannot convert value of type '((()) -> Void)?' to expected argument type '(() -> Void)?'}}
1663+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('(()) -> Void' and '() -> Void') are expected to be equal}}
16631664
}
16641665

16651666
// https://github.com/apple/swift/issues/49059
@@ -1699,6 +1700,7 @@ do {
16991700
func log<T>() -> ((T) -> Void)? { return nil }
17001701

17011702
f(a: log() as ((()) -> Void)?) // expected-error {{cannot convert value of type '((()) -> Void)?' to expected argument type '(() -> Void)?'}}
1703+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('(()) -> Void' and '() -> Void') are expected to be equal}}
17021704

17031705
func logNoOptional<T>() -> (T) -> Void { }
17041706
f(a: logNoOptional() as ((()) -> Void)) // expected-error {{cannot convert value of type '(()) -> Void' to expected argument type '() -> Void'}}

0 commit comments

Comments
 (0)