Skip to content

ConstraintSystem: Revert #61243 #61859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6540,7 +6540,7 @@ void ConstraintSystem::diagnoseFailureFor(SolutionApplicationTarget target) {
bool ConstraintSystem::isDeclUnavailable(const Decl *D,
ConstraintLocator *locator) const {
// First check whether this declaration is universally unavailable.
if (AvailableAttr::isUnavailable(D))
if (D->getAttrs().isUnavailable(getASTContext()))
return true;

return TypeChecker::isDeclarationUnavailable(D, DC, [&] {
Expand Down
37 changes: 18 additions & 19 deletions test/Constraints/availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,23 @@ func f_55700(_ arr: [Int]) {
for x in arr where unavailableFunction(x) {} // expected-error {{'unavailableFunction' is unavailable}}
}

// rdar://92364955 - ambiguity with member declared in unavailable extension
struct WithUnavailableExt {
}

@available(*, unavailable)
extension WithUnavailableExt {
static var foo: WithUnavailableExt = WithUnavailableExt()
}

func test_no_ambiguity_with_unavailable_ext() {
struct A {
static var foo: A = A()
}
// rdar://101814209
public struct Box<T> {
@usableFromInline
let value: T
}

struct Test {
init(_: A) {}
init(_: WithUnavailableExt) {}
}
@available(macOS, unavailable)
extension Box where T == Int {
@usableFromInline
init(value: T) {
self.value = value
}
}

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