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: overload.go
    path of file: ./repos/cockroach/pkg/sql/sem/eval
    
    the code of the file until where you have to start completion: // Copyright 2022 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package eval

import (
	"context"

	"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
	"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
	"github.com/cockroachdb/cockroach/pkg/sql/types"
	"github.com/cockroachdb/errors"
)

// AggregateOverload is the concrete type for the tree.Overload.Aggregate field.
type AggregateOverload func([]*types.T, *Context, tree.Datums) AggregateFunc

// Aggregate is a marker to indicate that this is a tree.AggregateOverload.
func (ao AggregateOverload) Aggregate() {}

// AggregateFunc accumulates the result of a function of a Datum.
type AggregateFunc interface {
	// Add accumulates the passed datums into the AggregateFunc.
	// Most implementations require one and only one firstArg argument.
	// If an aggregate function requires more than one
    
func init() {
	builtinsregistry.AddSubscription(func(name string, _ *tree.FunctionProperties, overloads []tree.Overload) {
		for i := range overloads {
			fn := &overloads[i]
			// Set the routine type for each overload.
			fn.Type = tree.BuiltinRoutine
			var numSet int
			if fn.AggregateFunc != nil {
				numSet++
			}
			if fn.WindowFunc != nil {
				numSet++
			}
			if fn.Fn != nil {
				numSet++
				// Verify that Fn has the correct signature. All other functions
				// are checked via the marker interfaces, but Fn isn't checked
				// at compile time.
				if _, ok := fn.Fn.(FnOverload); !ok {
					panic(errors.AssertionFailedf("%s: Fn is not FnOverload: %v", name, fn))
				}
			}
			if fn.FnWithExprs != nil {
				numSet++
			}
			if fn.Generator != nil {
				numSet++
			}
			if fn.GeneratorWithExprs != nil {
				numSet++
			}
			if fn.SQLFn != nil {
				numSet++
			}
			if fn.Body != "" {
				numSet++
			}
			var numSetExpected int
			switch fn.Class {
			case tree.NormalClass:
				if fn.Fn == nil && fn.FnWithExprs == nil && fn.Body == "" {
					panic(errors.AssertionFailedf(
						"%s: normal builtins should have Fn, FnWithExprs, or Body set: %v", name, fn,
					))
				}
				numSetExpected = 1

			case tree.AggregateClass:
				if fn.AggregateFunc == nil || fn.WindowFunc == nil {
					panic(errors.AssertionFailedf(
						"%s: aggregate builtins should have AggregateFunc "+
							"and WindowFunc set: %v", name, fn,
					))
				}
				numSetExpected = 2

			case tree.WindowClass:
				if fn.WindowFunc == nil {
					panic(errors.AssertionFailedf(
						"%s: window builtins should have WindowFunc set: %v", name, fn,
					))
				}
				numSetExpected = 1

			case tree.GeneratorClass:
				if fn.Generator == nil && fn.GeneratorWithExprs == nil {
					panic(errors.AssertionFailedf(
						"%s: generator builtins should have Generator or "+
							"GeneratorWithExprs set: %v", name, fn,
					))
				}
				// Generator builtins have Fn and FnWithExprs set to
				// implementations that return assertion errors.
				numSetExpected = 3

			case tree.SQLClass:
				if fn.Fn == nil || fn.SQLFn == nil {
					panic(errors.AssertionFailedf(
						"%s: SQL builtins should have Fn and SQLFn set: %v", name, fn,
					))
				}
				numSetExpected = 2

			default:
				panic(errors.AssertionFailedf("%s: unexpected class %d: %v", name, fn.Class, fn))
			}

			if numSet != numSetExpected {
				panic(errors.AssertionFailedf(
					"%s: overload specified %d functions, %d expected: %v", name, numSet, numSetExpected, fn,
				))
			}
		}
	})
}