Skip to content

Commit 27373ec

Browse files
committed
AST: Relax containment for Swift, PackageDescription, and Embedded domains.
Now that `AvailabilityContext` supports multiple unavailable domains, it's no longer necessary to have a total ordering amongst the Swift, PackageDescription, and Embedded availability domains.
1 parent 9455a0f commit 27373ec

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

lib/AST/AvailabilityDomain.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -147,26 +147,19 @@ ModuleDecl *AvailabilityDomain::getModule() const {
147147
}
148148

149149
bool AvailabilityDomain::contains(const AvailabilityDomain &other) const {
150-
// FIXME: [availability] This currently implements something closer to a
151-
// total ordering instead of the more flexible partial ordering that it
152-
// would ideally represent. Until AvailabilityContext supports tracking
153-
// multiple unavailable domains simultaneously, a stricter ordering is
154-
// necessary to support source compatibility.
155150
switch (getKind()) {
156151
case Kind::Universal:
157152
return true;
158153
case Kind::SwiftLanguage:
159-
return !other.isUniversal();
160154
case Kind::PackageDescription:
161155
case Kind::Embedded:
162-
return !other.isUniversal() && !other.isSwiftLanguage();
156+
case Kind::Custom:
157+
return other == *this;
163158
case Kind::Platform:
164159
if (getPlatformKind() == other.getPlatformKind())
165160
return true;
166161
return inheritsAvailabilityFromPlatform(other.getPlatformKind(),
167162
getPlatformKind());
168-
case Kind::Custom:
169-
return getCustomDomain() == other.getCustomDomain();
170163
}
171164
}
172165

unittests/AST/AvailabilityDomainTests.cpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,10 @@ TEST_F(AvailabilityDomainLattice, Contains) {
5252
// The universal domain is the bottom domain and contains all others.
5353
EXPECT_TRUE(Universal.contains(domain));
5454

55-
// FIXME: [availability] The following assertions should change when
56-
// AvailabilityContext can support multiple simultaneous unavailable
57-
// domains.
58-
59-
// The Swift domain is second from the bottom.
60-
EXPECT_EQ(Swift.contains(domain), !domain.isUniversal());
61-
62-
// Package and Embedded are both third from the bottom.
63-
EXPECT_EQ(Package.contains(domain), !domain.isUniversal() && !domain.isSwiftLanguage());
64-
EXPECT_EQ(Embedded.contains(domain), !domain.isUniversal() && !domain.isSwiftLanguage());
55+
// These domains only contain themselves.
56+
EXPECT_EQ(Swift.contains(domain), domain.isSwiftLanguage());
57+
EXPECT_EQ(Package.contains(domain), domain.isPackageDescription());
58+
EXPECT_EQ(Embedded.contains(domain), domain.isEmbedded());
6559
}
6660

6761
// Platform kind domains form their own lattice in which app extension domains

0 commit comments

Comments
 (0)