mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When matching candidate like `[Int]` against `Array<Element>` we need to conservatively assume that if the nominals match the argument is a viable exact match because otherwise it's possible to skip some of the valid matches when other overload choice have generic parameters at the same parameter position.
40 lines
813 B
Swift
40 lines
813 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
protocol ScalarOrArray {
|
|
}
|
|
|
|
protocol SpecialValue: ScalarOrArray {
|
|
}
|
|
|
|
extension Array: ScalarOrArray where Element: SpecialValue {
|
|
}
|
|
|
|
struct CustomArray : ScalarOrArray {
|
|
}
|
|
|
|
extension CustomArray : ExpressibleByArrayLiteral {
|
|
public init(arrayLiteral elements: Int32...) {
|
|
self.init()
|
|
}
|
|
}
|
|
|
|
extension Int32: SpecialValue {
|
|
}
|
|
|
|
func +<T: ScalarOrArray>(_: T, _: CustomArray) -> CustomArray {}
|
|
func +<T: ScalarOrArray>(_: CustomArray, _: T) -> CustomArray {}
|
|
func +(_: CustomArray, _: CustomArray) -> CustomArray {}
|
|
|
|
extension Sequence where Element == Int {
|
|
var asInt32: [Int32] { [] }
|
|
}
|
|
|
|
extension Array where Element == Int {
|
|
var asInt32: [Int32] { [] }
|
|
}
|
|
|
|
func test(v: Int32, b: [Int]) -> [Int32] {
|
|
let result = [1, v - v] + b.asInt32
|
|
return result // Ok
|
|
}
|