Files
swift-mirror/validation-test/Sema/issue78371.swift
Pavel Yaskevich e3987beffb [CSOptimizer] Literal arguments should cause score reset only for operators
Resetting score to `0.1` is intended to make sure that the
solver picks the outermost disjunction in literal chains like
`1 + 2 + 3 ...` because that would provide context to the
inner choices.

Resolves: https://github.com/swiftlang/swift/issues/78371
Resolves: rdar://142105691
2025-01-09 11:28:24 -08:00

23 lines
508 B
Swift

// RUN: %target-typecheck-verify-swift
// https://github.com/swiftlang/swift/issues/78371
// Note that the test has to use a standard operator because
// custom ones are not optimized.
struct Scalar : Equatable {
init(_: UInt8) {}
init?(_: Int) {}
}
func ==(_: Scalar, _: Scalar) -> Bool { }
extension Optional where Wrapped == Scalar {
static func ==(_: Wrapped?, _: Wrapped?) -> Wrapped { }
}
func test(a: Scalar) {
let result = a == Scalar(0x07FD)
let _: Scalar = result // Ok
}