]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Support concretizing generics in template parameters
authorMatt Corallo <git@bluematt.me>
Thu, 15 Apr 2021 17:11:04 +0000 (13:11 -0400)
committerMatt Corallo <git@bluematt.me>
Thu, 15 Apr 2021 21:59:35 +0000 (17:59 -0400)
c-bindings-gen/src/types.rs

index 16f3ff56663300631a80467f0fade67cd66dd0c6..acfcc1d8a8c26c0b85a3493ae1c82646733fe38b 100644 (file)
@@ -507,11 +507,20 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
        pub fn resolve_imported_refs(&self, mut ty: syn::Type) -> syn::Type {
                match &mut ty {
                        syn::Type::Path(p) => {
-                               if let Some(ident) = p.path.get_ident() {
-                                       if let Some((_, newpath)) = self.imports.get(ident) {
-                                               p.path = newpath.clone();
+eprintln!("rir {:?}", p);
+                               if p.path.segments.len() != 1 { unimplemented!(); }
+                               let mut args = p.path.segments[0].arguments.clone();
+                               if let syn::PathArguments::AngleBracketed(ref mut generics) = &mut args {
+                                       for arg in generics.args.iter_mut() {
+                                               if let syn::GenericArgument::Type(ref mut t) = arg {
+                                                       *t = self.resolve_imported_refs(t.clone());
+                                               }
                                        }
-                               } else { unimplemented!(); }
+                               }
+                               if let Some((_, newpath)) = self.imports.get(single_ident_generic_path_to_ident(&p.path).unwrap()) {
+                                       p.path = newpath.clone();
+                               }
+                               p.path.segments[0].arguments = args;
                        },
                        syn::Type::Reference(r) => {
                                r.elem = Box::new(self.resolve_imported_refs((*r.elem).clone()));