Files
swift-mirror/validation-test/Sema/custom_array_literal_with_operators.swift
Pavel Yaskevich e280569988 [CSOptimizer] Fix scoring while matching against partially resolved parameter types
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.
2025-06-27 23:43:11 -07:00

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
}