Skip to content

Commit 94fdce7

Browse files
authored
Merge pull request #30658 from xedin/rdar-60901494
[ConstraintSystem] Don't check `-disable-availability-checking`
2 parents 9b75217 + c99c9b9 commit 94fdce7

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4369,9 +4369,6 @@ bool ConstraintSystem::isDeclUnavailable(const Decl *D,
43694369
ConstraintLocator *locator) const {
43704370
auto &ctx = getASTContext();
43714371

4372-
if (ctx.LangOpts.DisableAvailabilityChecking)
4373-
return false;
4374-
43754372
// First check whether this declaration is universally unavailable.
43764373
if (D->getAttrs().isUnavailable(ctx))
43774374
return true;
@@ -4384,8 +4381,8 @@ bool ConstraintSystem::isDeclUnavailable(const Decl *D,
43844381
}
43854382

43864383
// If not, let's check contextual unavailability.
4387-
AvailabilityContext result = AvailabilityContext::alwaysAvailable();
4388-
return !TypeChecker::isDeclAvailable(D, loc, DC, result);
4384+
auto result = TypeChecker::checkDeclarationAvailability(D, loc, DC);
4385+
return result.hasValue();
43894386
}
43904387

43914388
/// If we aren't certain that we've emitted a diagnostic, emit a fallback

test/Constraints/rdar60898369.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking -swift-version 5
2+
3+
struct S {
4+
@available(swift, obsoleted: 4.2)
5+
init(foo: Int) throws {}
6+
7+
@available(swift, introduced: 4.2)
8+
init?(foo: Int) throws {}
9+
}
10+
11+
_ = try S(foo: 42)

0 commit comments

Comments
 (0)