diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp index 1558ddd586cff..69316147bfd3d 100644 --- a/lib/Sema/ConstraintSystem.cpp +++ b/lib/Sema/ConstraintSystem.cpp @@ -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, [&] { diff --git a/test/Constraints/availability.swift b/test/Constraints/availability.swift index 633724f168c33..6b134d67a350f 100644 --- a/test/Constraints/availability.swift +++ b/test/Constraints/availability.swift @@ -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 { + @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) +}