Skip to content

Commit ffb8baf

Browse files
committed
[Sema] Remove checks preventing metatype keypaths in Sema.
1 parent 4e3f665 commit ffb8baf

File tree

3 files changed

+0
-17
lines changed

3 files changed

+0
-17
lines changed

include/swift/Sema/CSFix.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,8 +2026,6 @@ class TreatKeyPathSubscriptIndexAsHashable final : public ConstraintFix {
20262026

20272027
class AllowInvalidRefInKeyPath final : public ConstraintFix {
20282028
enum RefKind {
2029-
// Allow a reference to a static member as a key path component.
2030-
StaticMember,
20312029
// Allow a reference to a declaration with mutating getter as
20322030
// a key path component.
20332031
MutatingGetter,
@@ -2051,8 +2049,6 @@ class AllowInvalidRefInKeyPath final : public ConstraintFix {
20512049
public:
20522050
std::string getName() const override {
20532051
switch (Kind) {
2054-
case RefKind::StaticMember:
2055-
return "allow reference to a static member as a key path component";
20562052
case RefKind::MutatingGetter:
20572053
return "allow reference to a member with mutating getter as a key "
20582054
"path component";

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5384,9 +5384,6 @@ namespace {
53845384
auto varDecl = cast<VarDecl>(property);
53855385
// Key paths don't work with mutating-get properties.
53865386
assert(!varDecl->isGetterMutating());
5387-
// Key paths don't currently support static members.
5388-
// There is a fix which diagnoses such situation already.
5389-
assert(!varDecl->isStatic());
53905387

53915388
// Compute the concrete reference to the member.
53925389
auto ref = resolveConcreteDeclRef(property, locator);

lib/Sema/CSFix.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,11 +1230,6 @@ TreatKeyPathSubscriptIndexAsHashable::create(ConstraintSystem &cs, Type type,
12301230
bool AllowInvalidRefInKeyPath::diagnose(const Solution &solution,
12311231
bool asNote) const {
12321232
switch (Kind) {
1233-
case RefKind::StaticMember: {
1234-
InvalidStaticMemberRefInKeyPath failure(solution, Member, getLocator());
1235-
return failure.diagnose(asNote);
1236-
}
1237-
12381233
case RefKind::EnumCase: {
12391234
InvalidEnumCaseRefInKeyPath failure(solution, Member, getLocator());
12401235
return failure.diagnose(asNote);
@@ -1298,11 +1293,6 @@ AllowInvalidRefInKeyPath::forRef(ConstraintSystem &cs, ValueDecl *member,
12981293
return AllowInvalidRefInKeyPath::create(cs, RefKind::Initializer,
12991294
member, locator);
13001295

1301-
// Referencing static members in key path is not currently allowed.
1302-
if (member->isStatic())
1303-
return AllowInvalidRefInKeyPath::create(cs, RefKind::StaticMember, member,
1304-
locator);
1305-
13061296
if (auto *storage = dyn_cast<AbstractStorageDecl>(member)) {
13071297
// Referencing members with mutating getters in key path is not
13081298
// currently allowed.

0 commit comments

Comments
 (0)