private static bool DerivesOrImplements(INamedTypeSymbol type, ITypeSymbol[] possibleTypes)
        {
            var allInterfaces = type.AllInterfaces;
            if (allInterfaces.Intersect(possibleTypes).Any())
            {
                return true;
            }

            var baseType = type;
            while (baseType != null &&
                !(baseType is IErrorTypeSymbol))
            {
                if (possibleTypes.Contains(baseType))
                {
                    return true;
                }
                baseType = baseType.BaseType;
            }
            return false;
        }