Files
swift-mirror/test/Constraints/rdar158063151.swift
Pavel Yaskevich df962a83c6 [CSOptimizer] Don't match nil to _OptionalNilComparisonType
This type is only intended for pattern matching against `nil`
and the solver shouldn't early attempt to infer this type for
`nil` for arguments of `==` and `!=` operators it should instead
be inferred from other argument or result.

Resolves: rdar://158063151
2025-09-01 20:47:56 -07:00

17 lines
624 B
Swift

// RUN: %target-swift-emit-silgen %s | %FileCheck %s
// Make sure that the type-checker selects an `Equatable.==` instead of one from stdlib that takes _OptionalNilComparisonType
struct Value: Equatable, ExpressibleByNilLiteral {
init(nilLiteral: ()) {
}
}
// CHECK-LABEL: sil hidden [ossa] @$s13rdar1580631514test1vyAA5ValueV_tF : $@convention(thin) (Value) -> ()
// function_ref static Value.__derived_struct_equals(_:_:)
// CHECK: [[EQUALS_REF:%.*]] = function_ref @$s13rdar1580631515ValueV23__derived_struct_equalsySbAC_ACtFZ
// CHECK-NEXT: apply [[EQUALS_REF]](%0, {{.*}})
func test(v: Value) {
_ = v == nil
}