///////////////////////////////////////////////////////////////////////////////// public static MethodOrPropertySymbol FindMostDerivedMethod( SymbolLoader symbolLoader, MethodOrPropertySymbol pMethProp, CType pType) { MethodSymbol method; bool bIsIndexer = false; if (pMethProp.IsMethodSymbol()) { method = pMethProp.AsMethodSymbol(); } else { PropertySymbol prop = pMethProp.AsPropertySymbol(); method = prop.methGet != null ? prop.methGet : prop.methSet; if (method == null) { return null; } bIsIndexer = prop.isIndexer(); } if (!method.isVirtual) { return method; } if (pType == null) { // This must be a static call. return method; } // Now get the slot method. if (method.swtSlot != null && method.swtSlot.Meth() != null) { method = method.swtSlot.Meth(); } if (!pType.IsAggregateType()) { // Not something that can have overrides anyway. return method; } for (AggregateSymbol pAggregate = pType.AsAggregateType().GetOwningAggregate(); pAggregate != null && pAggregate.GetBaseAgg() != null; pAggregate = pAggregate.GetBaseAgg()) { for (MethodOrPropertySymbol meth = symbolLoader.LookupAggMember(method.name, pAggregate, symbmask_t.MASK_MethodSymbol | symbmask_t.MASK_PropertySymbol).AsMethodOrPropertySymbol(); meth != null; meth = symbolLoader.LookupNextSym(meth, pAggregate, symbmask_t.MASK_MethodSymbol | symbmask_t.MASK_PropertySymbol).AsMethodOrPropertySymbol()) { if (!meth.isOverride) { continue; } if (meth.swtSlot.Sym != null && meth.swtSlot.Sym == method) { if (bIsIndexer) { Debug.Assert(meth.IsMethodSymbol()); return meth.AsMethodSymbol().getProperty(); } else { return meth; } } } } // If we get here, it means we can have two cases: one is that we have // a delegate. This is because the delegate invoke method is virtual and is // an override, but we wont have the slots set up correctly, and will // not find the base type in the inheritance hierarchy. The second is that // we're calling off of the base itself. Debug.Assert(method.parent.IsAggregateSymbol()); return method; }