You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: typechecking.go
    path of file: ./repos/kubeedge/vendor/k8s.io/apiserver/pkg/admission/plugin/validatingadmissionpolicy
    
    the code of the file until where you have to start completion: /*
Copyright 2023 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not
    
func buildEnv(hasParams bool, types typeOverwrite) (*cel.Env, error) {
	baseEnv, err := getBaseEnv()
	if err != nil {
		return nil, err
	}
	reg := apiservercel.NewRegistry(baseEnv)
	requestType := plugincel.BuildRequestType()

	var varOpts []cel.EnvOption
	var rts []*apiservercel.RuleTypes

	// request, hand-crafted type
	rt, opts, err := createRuleTypesAndOptions(reg, requestType, plugincel.RequestVarName)
	if err != nil {
		return nil, err
	}
	rts = append(rts, rt)
	varOpts = append(varOpts, opts...)

	// object and oldObject, same type, type(s) resolved from constraints
	rt, opts, err = createRuleTypesAndOptions(reg, types.object, plugincel.ObjectVarName, plugincel.OldObjectVarName)
	if err != nil {
		return nil, err
	}
	rts = append(rts, rt)
	varOpts = append(varOpts, opts...)

	// params, defined by ParamKind
	if hasParams {
		rt, opts, err := createRuleTypesAndOptions(reg, types.params, plugincel.ParamsVarName)
		if err != nil {
			return nil, err
		}
		rts = append(rts, rt)
		varOpts = append(varOpts, opts...)
	}

	opts, err = ruleTypesOpts(rts, baseEnv.TypeProvider())
	if err != nil {
		return nil, err
	}
	opts = append(opts, varOpts...) // add variables after ruleTypes.
	env, err := baseEnv.Extend(opts...)
	if err != nil {
		return nil, err
	}
	return env, nil
}