summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-01 05:19:55 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-01 05:19:55 -0800
commit121a9209a20d5789f693c77e4fbe74522506f74d (patch)
tree9123f95ea1ed8fa9c237f6c551b9aaaef5cea856
parent61f01a3021229b3674f0dafcab74282a9945f45e (diff)
downloadtxr-121a9209a20d5789f693c77e4fbe74522506f74d.tar.gz
txr-121a9209a20d5789f693c77e4fbe74522506f74d.tar.bz2
txr-121a9209a20d5789f693c77e4fbe74522506f74d.zip
Resolve method name to supertype.
* struct.c (method_name): Don't return first match. Resolve to most ancestral superclass which has that function in the same slot.
-rw-r--r--struct.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/struct.c b/struct.c
index 05a1a372..bbe8584f 100644
--- a/struct.c
+++ b/struct.c
@@ -1060,8 +1060,24 @@ val method_name(val fun)
val slot = car(sl_iter);
loc ptr = lookup_static_slot(stype, st, slot);
- if (!nullocp(ptr) && deref(ptr) == fun)
+ if (!nullocp(ptr) && deref(ptr) == fun) {
+ val sstype;
+
+ while ((sstype = super(stype)) != nil) {
+ struct struct_type *sst = coerce(struct struct_type *,
+ sstype->co.handle);
+ loc sptr = lookup_static_slot(sstype, sst, slot);
+ if (!nullocp(sptr) && deref(sptr) == fun) {
+ stype = sstype;
+ sym = sst->name;
+ continue;
+ }
+
+ break;
+ }
+
return list(meth_s, sym, slot, nao);
+ }
}
}