Files
swift-mirror/test/Constraints/availability.swift
Pavel Yaskevich 4c600843d6 [ConstraintSystem] Check availability as part of resolving overload choice
This is a follow up to changes related to contextual availability
(https://github.com/apple/swift/pull/29921) which increased score
for unavailable declarations only if they were overloaded but
overlooked a case of a single unavailable choice.

Resolve: rdar://problem/60047439
2020-03-05 00:35:47 -08:00

37 lines
691 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 4
// Ensure that we do not select the unavailable failable init as the
// only solution and then fail to typecheck.
protocol P {}
class C : P {
@available(swift, obsoleted: 4)
public init?(_ c: C) {
}
public init<T : P>(_ c: T) {}
}
func f(c: C) {
let _: C? = C(c)
}
// rdar://problem/60047439 - unable to disambiguite expression based on availablity
func test_contextual_member_with_availability() {
struct A {
static var foo: A = A()
}
struct B {
@available(*, unavailable, renamed: "bar")
static var foo: B = B()
}
struct Test {
init(_: A) {}
init(_: B) {}
}
_ = Test(.foo) // Ok
}