path: root/parse/export.c
diff options
authorMichael Forney <>2017-07-01 14:43:22 -0700
committerOri Bernstein <>2017-07-03 23:27:02 -0700
commit871ef281aaf3c2e8bdff5d92355461bedfa5d933 (patch)
tree76db674822cd67fb1cd1772a8d52f40910735d00 /parse/export.c
parentca10a1ec838b7d468a2b43894af659c111a0e9b1 (diff)
Specialize impl declarations on impl type in addition to decl type
This allows multiple specializations of a declarations with a concrete type, which can be selected with the new impl expression if it can't be deduced by its type alone. For example trait hasname @t = Name: byte[:] ;; impl hasname void = Name = "somename" ;; impl hasname bool = Name = "othername" ;; const boolname = impl(Name, void) To do this, pass the param type through to genericname and specializedcl. Since we now need the type parameter to look up trait decls, make sure n->expr.param gets the necessary treatment in typesub, specializenode, pickle, and unpickle. We also need to tag the param types for export.
Diffstat (limited to 'parse/export.c')
1 files changed, 2 insertions, 0 deletions
diff --git a/parse/export.c b/parse/export.c
index 0c9be87..4f67019 100644
--- a/parse/export.c
+++ b/parse/export.c
@@ -150,6 +150,8 @@ static void tagnode(Stab *st, Node *n, int ingeneric, int hidelocal)
case Nexpr:
tagnode(st, n->expr.idx, ingeneric, hidelocal);
tagtype(st, n->expr.type, ingeneric, hidelocal);
+ if (n->expr.param)
+ tagtype(st, n->expr.param, ingeneric, hidelocal);
for (i = 0; i < n->expr.nargs; i++)
tagnode(st, n->expr.args[i], ingeneric, hidelocal);
/* generics need to have the decls they refer to exported. */