Skip to content

Commit

Permalink
Implement diamond role composition
Browse files Browse the repository at this point in the history
This is actually slightly wrong, as it allows different instantiations of
a parametrized role to not conflict.  Also, attribute diamonding is still
considered an error.
  • Loading branch information
sorear committed Jan 5, 2012
1 parent 50e7f15 commit cd7e924
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Kernel.cs
Expand Up @@ -5490,7 +5490,7 @@ internal class MMDCandidate : MultiCandidate {

// now methods, these are a lot harder
var class_methods = new HashSet<Prod<int,string>>();
var role_methods = new Dictionary<Prod<int,string>,string>();
var role_methods = new Dictionary<Prod<int,string>,Prod<string,object>>();
var requirements = new Dictionary<Prod<int,string>,string>();

foreach (P6how.MethodInfo mi in cls.mo.lmethods) {
Expand All @@ -5512,10 +5512,10 @@ internal class MMDCandidate : MultiCandidate {
requirements[name] = r.name;
continue;
}
if (role_methods.ContainsKey(name)) {
throw new NieczaException(MethodSlot(name) + " must be resolved by class '" + cls.name + "' because it exists in roles '" + role_methods[name] + "' and '" + r.name + "'");
if (role_methods.ContainsKey(name) && role_methods[name].v2 != mi.impl.GetSlot("info")) {
throw new NieczaException(MethodSlot(name) + " must be resolved by class '" + cls.name + "' because it exists in roles '" + role_methods[name].v1 + "' and '" + r.name + "'");
}
role_methods[name] = r.name;
role_methods[name] = Prod.C(r.name, mi.impl.GetSlot("info"));
}
cls.mo.lmethods.Add(mi);
}
Expand Down

0 comments on commit cd7e924

Please sign in to comment.