Support dependent name lookup through smart pointers
varungandhi-src opened this issue · comments
clangd's HeuristicResolver has some code for this. Right now, we don't handle this case.
diff --git a/test/index/functions/templates.cc b/test/index/functions/templates.cc
index 20ea11a..a1282ca 100644
--- a/test/index/functions/templates.cc
+++ b/test/index/functions/templates.cc
@@ -60,2 +60,17 @@ struct Q2: Q1<T> {
void h() { f(); }
-};
\ No newline at end of file
+};
+
+template <typename T>
+class SmartPtr {
+ T *t;
+public:
+ T *operator->() {
+ return this->t;
+ }
+};
+
+template <typename T>
+void use_smurt_ptr(SmartPtr<Q1<T>> p) {
+ p->f();
+ p->g();
+}
\ No newline at end of file
diff --git a/test/index/functions/templates.snapshot.cc b/test/index/functions/templates.snapshot.cc
index c3fddb3..ad77484 100644
--- a/test/index/functions/templates.snapshot.cc
+++ b/test/index/functions/templates.snapshot.cc
@@ -138 +138,31 @@
};
+
+ template <typename T>
+// ^ definition local 14
+ class SmartPtr {
+// ^^^^^^^^ definition [..] SmartPtr#
+ T *t;
+// ^ reference local 14
+// ^ definition [..] SmartPtr#t.
+ public:
+ T *operator->() {
+// ^ reference local 14
+// ^^^^^^^^ definition [..] SmartPtr#`operator->`(155dc7f103cdb9db).
+ return this->t;
+// ^ reference [..] SmartPtr#t.
+ }
+ };
+
+ template <typename T>
+// ^ definition local 15
+ void use_smurt_ptr(SmartPtr<Q1<T>> p) {
+// ^^^^^^^^^^^^^ definition [..] use_smurt_ptr(cde7596607162187).
+// ^^^^^^^^ reference [..] SmartPtr#
+// ^^ reference [..] Q1#
+// ^ reference local 15
+// ^ definition local 16
+ p->f();
+// ^ reference local 16
+ p->g();
+// ^ reference local 16
+ }