Skip to content

Commit 753b906

Browse files
authored
Merge pull request #61859 from tshortli/rdar-101814209
ConstraintSystem: Revert #61243
2 parents dc3978f + cddd86f commit 753b906

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6540,7 +6540,7 @@ void ConstraintSystem::diagnoseFailureFor(SolutionApplicationTarget target) {
65406540
bool ConstraintSystem::isDeclUnavailable(const Decl *D,
65416541
ConstraintLocator *locator) const {
65426542
// First check whether this declaration is universally unavailable.
6543-
if (AvailableAttr::isUnavailable(D))
6543+
if (D->getAttrs().isUnavailable(getASTContext()))
65446544
return true;
65456545

65466546
return TypeChecker::isDeclarationUnavailable(D, DC, [&] {

test/Constraints/availability.swift

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,23 @@ func f_55700(_ arr: [Int]) {
4444
for x in arr where unavailableFunction(x) {} // expected-error {{'unavailableFunction' is unavailable}}
4545
}
4646

47-
// rdar://92364955 - ambiguity with member declared in unavailable extension
48-
struct WithUnavailableExt {
49-
}
50-
51-
@available(*, unavailable)
52-
extension WithUnavailableExt {
53-
static var foo: WithUnavailableExt = WithUnavailableExt()
54-
}
55-
56-
func test_no_ambiguity_with_unavailable_ext() {
57-
struct A {
58-
static var foo: A = A()
59-
}
47+
// rdar://101814209
48+
public struct Box<T> {
49+
@usableFromInline
50+
let value: T
51+
}
6052

61-
struct Test {
62-
init(_: A) {}
63-
init(_: WithUnavailableExt) {}
64-
}
53+
@available(macOS, unavailable)
54+
extension Box where T == Int {
55+
@usableFromInline
56+
init(value: T) {
57+
self.value = value
58+
}
59+
}
6560

66-
_ = Test(.foo) // Ok `A.foo` since `foo` from `WithUnavailableExt` is unavailable
67-
}
61+
@available(macOS, unavailable)
62+
@_alwaysEmitIntoClient public func aeicFunction() {
63+
// Select the unavailable @usableFromInline init over the synthesized internal
64+
// memberwise initializer.
65+
_ = Box(value: 42)
66+
}

0 commit comments

Comments
 (0)