Skip to content

Commit 5da4e2d

Browse files
committed
Sema: Allow unavailable decls to witness requirements in more conformances.
In #63898 conformance requirement typechecking was relaxed to allow unavailable decls to witness conformance requirements as long as the conforming nominal was also unavailable. However, only nominals that were directly marked unavailable were accepted. Nominals that are declared in unavailable scopes should also be allowed to have unavailable wintesses. Resolves rdar://107052715
1 parent fd0f148 commit 5da4e2d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ RequirementCheck WitnessChecker::checkWitness(ValueDecl *requirement,
17011701
}
17021702

17031703
if (auto adoptingNominal = DC->getSelfNominalTypeDecl()) {
1704-
if (adoptingNominal->getAttrs().isUnavailable(getASTContext()))
1704+
if (adoptingNominal->getSemanticUnavailableAttr())
17051705
return true;
17061706
}
17071707

test/ModuleInterface/actor_availability.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
// REQUIRES: VENDOR=apple
99

10-
// FIXME: rdar://107052715 temporarily disabled the test; fails on ios simulator
11-
// REQUIRES: rdar107052715
12-
1310
// CHECK: #if compiler(>=5.3) && $Actors
1411
// CHECK-NEXT: public actor ActorWithImplicitAvailability {
1512
public actor ActorWithImplicitAvailability {

test/decl/protocol/req/unavailable.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ extension ConformsToP5: P {
6464
func foo(bar: Foo) { }
6565
}
6666

67+
@available(*, unavailable)
68+
enum UnavailableEnum {
69+
struct ConformsToP6: P {
70+
@available(*, unavailable)
71+
func foo(bar: Foo) { }
72+
}
73+
}
74+
6775
// Include message string from @available attribute if provided
6876
protocol Unavail {
6977
associatedtype T

0 commit comments

Comments
 (0)