diff --git a/engine/src/conversion/analysis/type_converter.rs b/engine/src/conversion/analysis/type_converter.rs index 99cd61de0..40bd081a5 100644 --- a/engine/src/conversion/analysis/type_converter.rs +++ b/engine/src/conversion/analysis/type_converter.rs @@ -372,7 +372,10 @@ impl<'a> TypeConverter<'a> { } let (new_tn, api) = self.get_templated_typename(&Type::Path(typ))?; extra_apis.extend(api.into_iter()); - deps.remove(&tn); + // Although it's tempting to remove the dep on the original type, + // this means we wouldn't spot cases where the original type can't + // be represented in C++, e.g. because it has an unused template parameter. + // So we keep the original dep too. typ = new_tn.to_type_path(); deps.insert(new_tn); } diff --git a/engine/src/conversion/mod.rs b/engine/src/conversion/mod.rs index fa24d4db5..57f8d9fef 100644 --- a/engine/src/conversion/mod.rs +++ b/engine/src/conversion/mod.rs @@ -120,7 +120,7 @@ impl<'a> BridgeConverter<'a> { Self::dump_apis("parsing", &apis); // Inside parse_results, we now have a list of APIs. // We now enter various analysis phases. - // Next, convert any typedefs. + // First, convert any typedefs. // "Convert" means replacing bindgen-style type targets // (e.g. root::std::unique_ptr) with cxx-style targets (e.g. UniquePtr). let apis = convert_typedef_targets(self.config, apis); diff --git a/integration-tests/tests/integration_test.rs b/integration-tests/tests/integration_test.rs index 853e17b1b..2bf32aad7 100644 --- a/integration-tests/tests/integration_test.rs +++ b/integration-tests/tests/integration_test.rs @@ -12403,6 +12403,33 @@ fn test_override_typedef_fn() { run_test("", hdr, quote! {}, &["Foo"], &[]); } +#[test] +fn test_double_template_w_default() { + let hdr = indoc! {" + class Widget {}; + + template + class RefPtr { + private: + T* m_ptr; + }; + + class FakeAlloc {}; + + template + class Holder { + A alloc; + }; + + typedef Holder> WidgetRefHolder; + class Problem { + public: + WidgetRefHolder& getWidgets(); + }; + "}; + run_test("", hdr, quote! {}, &["Problem"], &[]); +} + // Yet to test: // - Ifdef // - Out param pointers