summaryrefslogtreecommitdiff
path: root/parse
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-08-13 18:17:46 -0700
committerOri Bernstein <ori@eigenstate.org>2017-08-13 18:24:50 -0700
commit433606f675efdaa466b7e9ab8adb257999af5ae6 (patch)
tree2708d45d3f391bed7a99da3bd30502993cd5fdde /parse
parent548ce5467e98c95e545be3fd021da014798a942d (diff)
downloadmc-433606f675efdaa466b7e9ab8adb257999af5ae6.tar.gz
If a trait is specialized over a generic, it's generic too.
Diffstat (limited to 'parse')
-rw-r--r--parse/infer.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/parse/infer.c b/parse/infer.c
index 04f7fc6..e29dd80 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1740,6 +1740,7 @@ specializeimpl(Node *n)
Type *ty;
Trait *t;
size_t i, j;
+ int generic;
t = gettrait(curstab(), n->impl.traitname);
if (!t)
@@ -1787,6 +1788,10 @@ specializeimpl(Node *n)
ty = tyspecialize(type(proto), subst, delayed, NULL);
substfree(subst);
+ generic = hasparams(ty);
+ if (generic)
+ ingeneric++;
+
inferdecl(dcl);
unify(n, type(dcl), ty);
@@ -1812,6 +1817,9 @@ specializeimpl(Node *n)
tystr(ty));
dcl->decl.vis = t->vis;
lappend(&impldecl, &nimpldecl, dcl);
+
+ if (generic)
+ ingeneric--;
}
popenv(n->impl.type->env);
}