Files
swift-mirror/test/Constraints/availability.swift
Mark Lacey 65e338ea4a [Constraint solver] Do not allow unavailable decls to be favored.
There is a short-circuiting hack in the constraint solver that speeds up
solving, but isn't generally sound. If we allow unavailable decls to be
considered "favored", this can fire and result in our choosing a
solution that involves the unavailable decl where other solutions exist.

Fixes rdar://problem/32570734.
2017-06-06 13:38:36 -07:00

18 lines
335 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)
}