Skip to content

Commit 286b6cb

Browse files
committed
Visit base first
1 parent cd83896 commit 286b6cb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/IDE/SourceEntityWalker.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,16 @@ std::pair<bool, Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
512512
return doSkipChildren();
513513
}
514514
} else if (auto DMRE = dyn_cast<DynamicMemberRefExpr>(E)) {
515+
// Visit in source order.
516+
if (!DMRE->getBase()->walk(*this))
517+
return stopTraversal;
515518
if (!passReference(DMRE->getMember().getDecl(), DMRE->getType(),
516519
DMRE->getNameLoc(),
517520
ReferenceMetaData(SemaReferenceKind::DynamicMemberRef,
518521
OpAccess)))
519522
return stopTraversal;
523+
// We already visited the children.
524+
return doSkipChildren();
520525
}
521526

522527
return { true, E };

test/Index/index_objc_dynamic_refs.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class AClass {
1717

1818
func doSomething() {
1919
objcDelegate?.dynamicMethod?()
20-
// CHECK: [[@LINE-1]]:23 | instance-method/Swift | dynamicMethod() | [[DynamicMethod_USR]] | Ref
21-
// CHECK: [[@LINE-2]]:9 | instance-property/Swift | objcDelegate | [[Delegate_USR]] | Ref
20+
// CHECK: [[@LINE-1]]:9 | instance-property/Swift | objcDelegate | [[Delegate_USR]] | Ref
21+
// CHECK: [[@LINE-2]]:23 | instance-method/Swift | dynamicMethod() | [[DynamicMethod_USR]] | Ref
2222
_ = objcDelegate?.property
23-
// CHECK: [[@LINE-1]]:27 | instance-property/Swift | property | [[DynamicProperty_USR]] | Ref
24-
// CHECK: [[@LINE-2]]:13 | instance-property/Swift | objcDelegate | [[Delegate_USR]] | Ref
23+
// CHECK: [[@LINE-1]]:13 | instance-property/Swift | objcDelegate | [[Delegate_USR]] | Ref
24+
// CHECK: [[@LINE-2]]:27 | instance-property/Swift | property | [[DynamicProperty_USR]] | Ref
2525
}
2626
}

0 commit comments

Comments
 (0)