func (i Uint) ConvertToType(typeVal ref.Type) ref.Val {
	switch typeVal {
	case IntType:
		v, err := uint64ToInt64Checked(uint64(i))
		if err != nil {
			return wrapErr(err)
		}
		return Int(v)
	case UintType:
		return i
	case DoubleType:
		return Double(i)
	case StringType:
		return String(fmt.Sprintf("%d", uint64(i)))
	case TypeType:
		return UintType
	}
	return NewErr("type conversion error from '%s' to '%s'", UintType, typeVal)
}
ConvertToType implements ref.Val.ConvertToType.
package types
import (
	"fmt"
	"reflect"
	"strconv"
	"github.com/google/cel-go/common/types/ref"
	"github.com/google/cel-go/common/types/traits"
	anypb "google.golang.org/protobuf/types/known/anypb"
	structpb "google.golang.org/protobuf/types/known/structpb"
	wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
)
type Uint uint64
var (
	UintType = NewTypeValue("uint",
		traits.AdderType,
		traits.ComparerType,
		traits.DividerType,
		traits.ModderType,
		traits.MultiplierType,
		traits.SubtractorType)
	uint32WrapperType = reflect.TypeOf(&wrapperspb.UInt32Value{})
	uint64WrapperType = reflect.TypeOf(&wrapperspb.UInt64Value{})
)
const (
	uintZero = Uint(0)
)
func (i Uint) Add(other ref.Val) ref.Val {
	otherUint, ok := other.(Uint)
	if !ok {
		return MaybeNoSuchOverloadErr(other)
	}
	val, err := addUint64Checked(uint64(i), uint64(otherUint))
	if err != nil {
		return wrapErr(err)
	}
	return Uint(val)
}
func (i Uint) Compare(other ref.Val) ref.Val {
	otherUint, ok := other.(Uint)
	if !ok {
		return MaybeNoSuchOverloadErr(other)
	}
	if i < otherUint {
		return IntNegOne
	}
	if i > otherUint {
		return IntOne
	}
	return IntZero
}
func (i Uint) ConvertToNative(typeDesc reflect.Type) (interface{}, error) {
	switch typeDesc.Kind() {
	case reflect.Uint, reflect.Uint32:
		v, err := uint64ToUint32Checked(uint64(i))
		if err != nil {
			return 0, err
		}
		return reflect.ValueOf(v).Convert(typeDesc).Interface(), nil
	case reflect.Uint64:
		return reflect.ValueOf(i).Convert(typeDesc).Interface(), nil
	case reflect.Ptr:
		switch typeDesc {
		case anyValueType:
			return anypb.New(wrapperspb.UInt64(uint64(i)))
		case jsonValueType:
			if i.isJSONSafe() {
				return structpb.NewNumberValue(float64(i)), nil
			}
			return structpb.NewStringValue(strconv.FormatUint(uint64(i), 10)), nil
		case uint32WrapperType:
			v, err := uint64ToUint32Checked(uint64(i))
			if err != nil {
				return 0, err
			}
			return wrapperspb.UInt32(v), nil
		case uint64WrapperType:
			return wrapperspb.UInt64(uint64(i)), nil
		}
		switch typeDesc.Elem().Kind() {
		case reflect.Uint32:
			v, err := uint64ToUint32Checked(uint64(i))
			if err != nil {
				return 0, err
			}
			p := reflect.New(typeDesc.Elem())
			p.Elem().Set(reflect.ValueOf(v).Convert(typeDesc.Elem()))
			return p.Interface(), nil
		case reflect.Uint64:
			v := uint64(i)
			p := reflect.New(typeDesc.Elem())
			p.Elem().Set(reflect.ValueOf(v).Convert(typeDesc.Elem()))
			return p.Interface(), nil
		}
	case reflect.Interface:
		iv := i.Value()
		if reflect.TypeOf(iv).Implements(typeDesc) {
			return iv, nil
		}
		if reflect.TypeOf(i).Implements(typeDesc) {
			return i, nil
		}
	}
	return nil, fmt.Errorf("unsupported type conversion from 'uint' to %v", typeDesc)
}