Skip to content

Commit 940ffdf

Browse files
[tests] Add tests for SR-12689
1 parent 69d0642 commit 940ffdf

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/Sema/diag_ambiguous_overloads.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,28 @@ func getCounts(_ scheduler: sr5154_Scheduler, _ handler: @escaping ([Count]) ->
126126
})
127127
}
128128

129+
// SR-12689
130+
func SR12689(_ u: UnsafeBufferPointer<UInt16>) {}
131+
132+
let array : [UInt16] = [1, 2]
133+
134+
array.withUnsafeBufferPointer {
135+
SR12689(UnsafeRawPointer($0).bindMemory(to: UInt16.self, capacity: 1)) // expected-error {{no exact matches in call to initializer}}
136+
// expected-note@-1 {{found candidate with type '(Builtin.RawPointer) -> UnsafeRawPointer'}}
137+
// expected-note@-2 {{found candidate with type '(UnsafeMutableRawPointer) -> UnsafeRawPointer'}}
138+
// expected-note@-3 {{found candidate with type '(OpaquePointer) -> UnsafeRawPointer'}}
139+
// expected-note@-4 {{found candidate with type '(UnsafeRawPointer) -> UnsafeRawPointer'}}
140+
UnsafeRawPointer($0) as UnsafeBufferPointer<UInt16> // expected-error {{no exact matches in call to initializer}}
141+
// expected-note@-1 {{found candidate with type '(Builtin.RawPointer) -> UnsafeRawPointer'}}
142+
// expected-note@-2 {{found candidate with type '(UnsafeMutableRawPointer) -> UnsafeRawPointer'}}
143+
// expected-note@-3 {{found candidate with type '(OpaquePointer) -> UnsafeRawPointer'}}
144+
// expected-note@-4 {{found candidate with type '(UnsafeRawPointer) -> UnsafeRawPointer'}}
145+
}
146+
147+
func SR12689_1(_ u: Int) -> String { "" } // expected-note 2 {{found this candidate}}
148+
func SR12689_1(_ u: String) -> Double { 0 } // expected-note 2 {{found this candidate}}
149+
150+
func SR12689_2(_ u: Int) {}
151+
152+
SR12689_2(SR12689_1(1 as Double)) // expected-error {{no exact matches in call to global function 'SR12689_1'}}
153+
SR12689_1(1 as Double) as Int // expected-error {{no exact matches in call to global function 'SR12689_1'}}

0 commit comments

Comments
 (0)