// contain all base interface members, so the Lookup code
// can use simple inheritance rules.
//
+ // Does not work recursively because of generic interfaces
+ //
public void AddInterface (TypeSpec iface)
{
var cache = iface.MemberCache;
}
foreach (var ce in entry.Value) {
+ //
+ // When two or more different base interfaces implemenent common
+ // interface
+ //
+ // I : IA, IFoo
+ // IA : IFoo
+ //
if (list.Contains (ce))
continue;
member_hash[entry.Key] = list;
}
}
-
- // Add also all base interfaces
- if (iface.Interfaces != null) {
- foreach (var base_iface in iface.Interfaces)
- AddInterface (base_iface);
- }
}
public void AddMember (InterfaceMemberBase imb, string exlicitName, MemberSpec ms)
if (member.Kind == MemberKind.Operator) {
var dt = member.DeclaringType;
+
//
// Some core types have user operators but they cannot be used like normal
// user operators as they are predefined and therefore having different
// rules (e.g. binary operators) by not setting the flag we hide them for
// user conversions
//
- if (!BuiltinTypeSpec.IsPrimitiveType (dt)) {
+ if (!BuiltinTypeSpec.IsPrimitiveType (dt) || dt.BuiltinType == BuiltinTypeSpec.Type.Char) {
switch (dt.BuiltinType) {
case BuiltinTypeSpec.Type.String:
case BuiltinTypeSpec.Type.Delegate:
public static IList<MemberSpec> GetUserOperator (TypeSpec container, Operator.OpType op, bool declaredOnly)
{
IList<MemberSpec> found = null;
-
+ bool shared_list = true;
IList<MemberSpec> applicable;
do {
var mc = container.MemberCache;
found = new List<MemberSpec> ();
found.Add (applicable[i]);
} else {
- var prev = found as List<MemberSpec>;
- if (prev == null) {
+ List<MemberSpec> prev;
+ if (shared_list) {
+ shared_list = false;
prev = new List<MemberSpec> (found.Count + 1);
prev.AddRange (found);
+ } else {
+ prev = (List<MemberSpec>) found;
}
prev.Add (applicable[i]);
} else {
if (found == null) {
found = applicable;
+ shared_list = true;
} else {
- var merged = found as List<MemberSpec>;
- if (merged == null) {
+ List<MemberSpec> merged;
+ if (shared_list) {
+ shared_list = false;
merged = new List<MemberSpec> (found.Count + applicable.Count);
merged.AddRange (found);
found = merged;
+ } else {
+ merged = (List<MemberSpec>) found;
}
merged.AddRange (applicable);
"A partial method declaration and partial method implementation must be both `static' or neither");
}
- Report.SymbolRelatedToPreviousError (ce);
- Report.Error (764, member.Location,
- "A partial method declaration and partial method implementation must be both `unsafe' or neither");
+ if ((method_a.ModFlags & Modifiers.UNSAFE) != (method_b.ModFlags & Modifiers.UNSAFE)) {
+ Report.SymbolRelatedToPreviousError (ce);
+ Report.Error (764, member.Location,
+ "A partial method declaration and partial method implementation must be both `unsafe' or neither");
+ }
+
return false;
}