From 121a9209a20d5789f693c77e4fbe74522506f74d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 1 Dec 2015 05:19:55 -0800 Subject: 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. --- struct.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'struct.c') 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); + } } } -- cgit v1.2.3