Skip to content

Commit f97d68f

Browse files
authored
Merge pull request swiftlang#33290 from apple/revert-33245-index-key-paths
Revert "[Sema/Index] Resolve #keyPath components so they get handled by indexing, semantic highlighting, etc."
2 parents 78f0259 + 00e4a76 commit f97d68f

16 files changed

+25
-160
lines changed

include/swift/AST/Expr.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5259,7 +5259,6 @@ class KeyPathExpr : public Expr {
52595259
OptionalWrap,
52605260
Identity,
52615261
TupleElement,
5262-
DictionaryKey,
52635262
};
52645263

52655264
private:
@@ -5368,16 +5367,6 @@ class KeyPathExpr : public Expr {
53685367
propertyType,
53695368
loc);
53705369
}
5371-
5372-
/// Create a component for a dictionary key (#keyPath only).
5373-
static Component forDictionaryKey(DeclNameRef UnresolvedName,
5374-
Type valueType,
5375-
SourceLoc loc) {
5376-
return Component(nullptr, UnresolvedName, nullptr, {}, {},
5377-
Kind::DictionaryKey,
5378-
valueType,
5379-
loc);
5380-
}
53815370

53825371
/// Create a component for a subscript.
53835372
static Component forSubscript(ASTContext &ctx,
@@ -5468,7 +5457,6 @@ class KeyPathExpr : public Expr {
54685457
case Kind::Property:
54695458
case Kind::Identity:
54705459
case Kind::TupleElement:
5471-
case Kind::DictionaryKey:
54725460
return true;
54735461

54745462
case Kind::UnresolvedSubscript:
@@ -5493,7 +5481,6 @@ class KeyPathExpr : public Expr {
54935481
case Kind::Property:
54945482
case Kind::Identity:
54955483
case Kind::TupleElement:
5496-
case Kind::DictionaryKey:
54975484
return nullptr;
54985485
}
54995486
llvm_unreachable("unhandled kind");
@@ -5513,7 +5500,6 @@ class KeyPathExpr : public Expr {
55135500
case Kind::Property:
55145501
case Kind::Identity:
55155502
case Kind::TupleElement:
5516-
case Kind::DictionaryKey:
55175503
llvm_unreachable("no subscript labels for this kind");
55185504
}
55195505
llvm_unreachable("unhandled kind");
@@ -5536,7 +5522,6 @@ class KeyPathExpr : public Expr {
55365522
case Kind::Property:
55375523
case Kind::Identity:
55385524
case Kind::TupleElement:
5539-
case Kind::DictionaryKey:
55405525
return {};
55415526
}
55425527
llvm_unreachable("unhandled kind");
@@ -5548,7 +5533,6 @@ class KeyPathExpr : public Expr {
55485533
DeclNameRef getUnresolvedDeclName() const {
55495534
switch (getKind()) {
55505535
case Kind::UnresolvedProperty:
5551-
case Kind::DictionaryKey:
55525536
return Decl.UnresolvedName;
55535537

55545538
case Kind::Invalid:
@@ -5579,7 +5563,6 @@ class KeyPathExpr : public Expr {
55795563
case Kind::OptionalForce:
55805564
case Kind::Identity:
55815565
case Kind::TupleElement:
5582-
case Kind::DictionaryKey:
55835566
llvm_unreachable("no decl ref for this kind");
55845567
}
55855568
llvm_unreachable("unhandled kind");
@@ -5599,7 +5582,6 @@ class KeyPathExpr : public Expr {
55995582
case Kind::Identity:
56005583
case Kind::Property:
56015584
case Kind::Subscript:
5602-
case Kind::DictionaryKey:
56035585
llvm_unreachable("no field number for this kind");
56045586
}
56055587
llvm_unreachable("unhandled kind");

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,11 +2829,6 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
28292829
PrintWithColorRAII(OS, DiscriminatorColor)
28302830
<< "#" << component.getTupleIndex();
28312831
break;
2832-
case KeyPathExpr::Component::Kind::DictionaryKey:
2833-
PrintWithColorRAII(OS, ASTNodeColor) << "dict_key";
2834-
PrintWithColorRAII(OS, IdentifierColor)
2835-
<< " key='" << component.getUnresolvedDeclName() << "'";
2836-
break;
28372832
}
28382833
PrintWithColorRAII(OS, TypeColor)
28392834
<< " type='" << GetTypeOfKeyPathComponent(E, i) << "'";

lib/AST/ASTWalker.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
11331133
case KeyPathExpr::Component::Kind::Invalid:
11341134
case KeyPathExpr::Component::Kind::Identity:
11351135
case KeyPathExpr::Component::Kind::TupleElement:
1136-
case KeyPathExpr::Component::Kind::DictionaryKey:
11371136
// No subexpr to visit.
11381137
break;
11391138
}

lib/AST/Expr.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2383,7 +2383,6 @@ void KeyPathExpr::Component::setSubscriptIndexHashableConformances(
23832383
case Kind::Property:
23842384
case Kind::Identity:
23852385
case Kind::TupleElement:
2386-
case Kind::DictionaryKey:
23872386
llvm_unreachable("no hashable conformances for this kind");
23882387
}
23892388
}

lib/IDE/SourceEntityWalker.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ std::pair<bool, Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
412412
case KeyPathExpr::Component::Kind::OptionalWrap:
413413
case KeyPathExpr::Component::Kind::OptionalForce:
414414
case KeyPathExpr::Component::Kind::Identity:
415-
case KeyPathExpr::Component::Kind::DictionaryKey:
416415
break;
417416
}
418417
}

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,11 +3734,6 @@ RValue RValueEmitter::visitKeyPathExpr(KeyPathExpr *E, SGFContext C) {
37343734
case KeyPathExpr::Component::Kind::UnresolvedProperty:
37353735
case KeyPathExpr::Component::Kind::UnresolvedSubscript:
37363736
llvm_unreachable("not resolved");
3737-
break;
3738-
3739-
case KeyPathExpr::Component::Kind::DictionaryKey:
3740-
llvm_unreachable("DictionaryKey only valid in #keyPath");
3741-
break;
37423737
}
37433738
}
37443739

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,6 @@ static bool buildObjCKeyPathString(KeyPathExpr *E,
237237
// Don't bother building the key path string if the key path didn't even
238238
// resolve.
239239
return false;
240-
case KeyPathExpr::Component::Kind::DictionaryKey:
241-
llvm_unreachable("DictionaryKey only valid in #keyPath expressions.");
242-
return false;
243240
}
244241
}
245242

@@ -4693,10 +4690,6 @@ namespace {
46934690
case KeyPathExpr::Component::Kind::OptionalWrap:
46944691
case KeyPathExpr::Component::Kind::TupleElement:
46954692
llvm_unreachable("already resolved");
4696-
break;
4697-
case KeyPathExpr::Component::Kind::DictionaryKey:
4698-
llvm_unreachable("DictionaryKey only valid in #keyPath");
4699-
break;
47004693
}
47014694

47024695
// Update "componentTy" with the result type of the last component.
@@ -7752,8 +7745,9 @@ namespace {
77527745
componentType = solution.simplifyType(cs.getType(kp, i));
77537746
assert(!componentType->hasTypeVariable() &&
77547747
"Should not write type variable into key-path component");
7755-
kp->getMutableComponents()[i].setComponentType(componentType);
77567748
}
7749+
7750+
kp->getMutableComponents()[i].setComponentType(componentType);
77577751
}
77587752
}
77597753

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3485,9 +3485,6 @@ namespace {
34853485
}
34863486
case KeyPathExpr::Component::Kind::Identity:
34873487
continue;
3488-
case KeyPathExpr::Component::Kind::DictionaryKey:
3489-
llvm_unreachable("DictionaryKey only valid in #keyPath");
3490-
break;
34913488
}
34923489

34933490
// By now, `base` is the result type of this component. Set it in the

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8236,9 +8236,6 @@ ConstraintSystem::simplifyKeyPathConstraint(
82368236
case KeyPathExpr::Component::Kind::TupleElement:
82378237
llvm_unreachable("not implemented");
82388238
break;
8239-
case KeyPathExpr::Component::Kind::DictionaryKey:
8240-
llvm_unreachable("DictionaryKey only valid in #keyPath");
8241-
break;
82428239
}
82438240
}
82448241

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,6 @@ ConstraintLocator *ConstraintSystem::getCalleeLocator(
493493
case ComponentKind::OptionalChain:
494494
case ComponentKind::OptionalWrap:
495495
case ComponentKind::Identity:
496-
case ComponentKind::DictionaryKey:
497496
// These components don't have any callee associated, so just continue.
498497
break;
499498
}

0 commit comments

Comments
 (0)