public bool IsBoundGeneric(BaseDeclaration context, TypeMapper mapper)
        {
            switch (this.Kind)
            {
            case TypeSpecKind.Named:
                NamedTypeSpec ns = (NamedTypeSpec)this;
                Entity        en = mapper.TryGetEntityForSwiftClassName(ns.Name);
                if (en == null)
                {
                    if (context.IsTypeSpecGeneric(ns))
                    {
                        return(false);                        // unbound
                    }
                }
                foreach (TypeSpec genParm in GenericParameters)
                {
                    if (genParm.IsUnboundGeneric(context, mapper))
                    {
                        return(false);                        // unbound
                    }
                }
                return(true);

            case TypeSpecKind.Closure:
                ClosureTypeSpec cs = (ClosureTypeSpec)this;
                return(cs.Arguments.IsBoundGeneric(context, mapper) && cs.ReturnType.IsBoundGeneric(context, mapper));

            case TypeSpecKind.Tuple:
                TupleTypeSpec ts = (TupleTypeSpec)this;
                foreach (TypeSpec elem in ts.Elements)
                {
                    if (elem.IsUnboundGeneric(context, mapper))
                    {
                        return(false);
                    }
                }
                return(true);

            default:
                throw new NotSupportedException("unknown TypeSpecKind " + this.Kind.ToString());
            }
        }
        public bool IsUnboundGeneric(BaseDeclaration context, TypeMapper mapper)
        {
            switch (Kind)
            {
            case TypeSpecKind.Named:
                NamedTypeSpec ns = (NamedTypeSpec)this;
                if (context.IsTypeSpecGeneric(ns.ToString()))
                {
                    return(true);
                }
                foreach (TypeSpec genparm in GenericParameters)
                {
                    if (genparm.IsUnboundGeneric(context, mapper))
                    {
                        return(true);
                    }
                }
                return(false);

            case TypeSpecKind.Closure:
                ClosureTypeSpec cs = (ClosureTypeSpec)this;
                return(cs.Arguments.IsUnboundGeneric(context, mapper) && cs.ReturnType.IsUnboundGeneric(context, mapper));

            case TypeSpecKind.Tuple:
                TupleTypeSpec ts = (TupleTypeSpec)this;
                foreach (TypeSpec elem in ts.Elements)
                {
                    if (elem.IsUnboundGeneric(context, mapper))
                    {
                        return(true);
                    }
                }
                return(false);

            case TypeSpecKind.ProtocolList:
                return(false);

            default:
                throw new NotSupportedException("unknown TypeSpecKind " + this.Kind.ToString());
            }
        }