Exemplo n.º 1
0
        public override void FixupExplicitImplementation()
        {
            if (fill_explicit_implementation_started)
            {
                return;                 // already done.
            }
            fill_explicit_implementation_started = true;
            if (BaseGen != null && BaseGen.explicitly_implemented_iface_methods == null)
            {
                BaseGen.FixupExplicitImplementation();
            }

            foreach (InterfaceGen iface in GetAllDerivedInterfaces())
            {
                if (iface.IsGeneric)
                {
                    bool skip = false;
                    foreach (ISymbol isym in Interfaces)
                    {
                        var gs = isym as GenericSymbol;
                        if (gs != null && gs.IsConcrete && gs.Gen == iface)
                        {
                            skip = true;
                        }
                    }
                    if (skip)
                    {
                        continue;                         // we don't handle it here; generic interface methods are generated in different manner.
                    }
                }
                if (BaseGen != null && BaseGen.GetAllDerivedInterfaces().Contains(iface))
                {
                    continue;                     // no need to fill members for already-implemented-in-base-class iface.
                }
                foreach (var m in iface.Methods.Where(m => !ContainsMethod(m, false, false)))
                {
                    string sig          = m.GetSignature();
                    bool   doExplicitly = false;
                    if (IsCovariantMethod(m))
                    {
                        doExplicitly = true;
                    }
                    else if (m.IsGeneric)
                    {
                        doExplicitly = true;
                    }
                    if (doExplicitly)
                    {
                        explicitly_implemented_iface_methods.Add(sig);
                    }
                }
            }

            // Keep in sync with Generate() that generates explicit iface method impl.
            foreach (ISymbol isym in Interfaces)
            {
                if (isym is GenericSymbol)
                {
                    GenericSymbol gs = isym as GenericSymbol;
                    if (gs.IsConcrete)
                    {
                        foreach (Method m in gs.Gen.Methods)
                        {
                            if (m.IsGeneric)
                            {
                                explicitly_implemented_iface_methods.Add(m.GetSignature());
                            }
                        }
                    }
                }
            }

            foreach (var nt in NestedTypes)
            {
                nt.FixupExplicitImplementation();
            }
        }