$22 GRAYBYTE WORDPRESS FILE MANAGER $29

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/lib/golang/src/go/types/

HOME
Current File : /lib/golang/src/go/types//typeparam.go
// Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
// Source: ../../cmd/compile/internal/types2/typeparam.go

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package types

import "sync/atomic"

// Note: This is a uint32 rather than a uint64 because the
// respective 64 bit atomic instructions are not available
// on all platforms.
var lastID atomic.Uint32

// nextID returns a value increasing monotonically by 1 with
// each call, starting with 1. It may be called concurrently.
func nextID() uint64 { return uint64(lastID.Add(1)) }

// A TypeParam represents the type of a type parameter in a generic declaration.
//
// A TypeParam has a name; use the [TypeParam.Obj] method to access
// its [TypeName] object.
type TypeParam struct {
	check *Checker  // for lazy type bound completion
	id    uint64    // unique id, for debugging only
	obj   *TypeName // corresponding type name
	index int       // type parameter index in source order, starting at 0
	bound Type      // any type, but underlying is eventually *Interface for correct programs (see TypeParam.iface)
}

// NewTypeParam returns a new TypeParam. Type parameters may be set on a Named
// type by calling SetTypeParams. Setting a type parameter on more than one type
// will result in a panic.
//
// The constraint argument can be nil, and set later via SetConstraint. If the
// constraint is non-nil, it must be fully defined.
func NewTypeParam(obj *TypeName, constraint Type) *TypeParam {
	return (*Checker)(nil).newTypeParam(obj, constraint)
}

// check may be nil
func (check *Checker) newTypeParam(obj *TypeName, constraint Type) *TypeParam {
	// Always increment lastID, even if it is not used.
	id := nextID()
	if check != nil {
		check.nextID++
		id = check.nextID
	}
	typ := &TypeParam{check: check, id: id, obj: obj, index: -1, bound: constraint}
	if obj.typ == nil {
		obj.typ = typ
	}
	// iface may mutate typ.bound, so we must ensure that iface() is called
	// at least once before the resulting TypeParam escapes.
	if check != nil {
		check.needsCleanup(typ)
	} else if constraint != nil {
		typ.iface()
	}
	return typ
}

// Obj returns the type name for the type parameter t.
func (t *TypeParam) Obj() *TypeName { return t.obj }

// Index returns the index of the type param within its param list, or -1 if
// the type parameter has not yet been bound to a type.
func (t *TypeParam) Index() int {
	return t.index
}

// Constraint returns the type constraint specified for t.
func (t *TypeParam) Constraint() Type {
	return t.bound
}

// SetConstraint sets the type constraint for t.
//
// It must be called by users of NewTypeParam after the bound's underlying is
// fully defined, and before using the type parameter in any way other than to
// form other types. Once SetConstraint returns the receiver, t is safe for
// concurrent use.
func (t *TypeParam) SetConstraint(bound Type) {
	if bound == nil {
		panic("nil constraint")
	}
	t.bound = bound
	// iface may mutate t.bound (if bound is not an interface), so ensure that
	// this is done before returning.
	t.iface()
}

// Underlying returns the [underlying type] of the type parameter t, which is
// the underlying type of its constraint. This type is always an interface.
//
// [underlying type]: https://go.dev/ref/spec#Underlying_types.
func (t *TypeParam) Underlying() Type {
	return t.iface()
}

func (t *TypeParam) String() string { return TypeString(t, nil) }

// ----------------------------------------------------------------------------
// Implementation

func (t *TypeParam) cleanup() {
	t.iface()
	t.check = nil
}

// iface returns the constraint interface of t.
func (t *TypeParam) iface() *Interface {
	bound := t.bound

	// determine constraint interface
	var ityp *Interface
	switch u := under(bound).(type) {
	case *Basic:
		if !isValid(u) {
			// error is reported elsewhere
			return &emptyInterface
		}
	case *Interface:
		if isTypeParam(bound) {
			// error is reported in Checker.collectTypeParams
			return &emptyInterface
		}
		ityp = u
	}

	// If we don't have an interface, wrap constraint into an implicit interface.
	if ityp == nil {
		ityp = NewInterfaceType(nil, []Type{bound})
		ityp.implicit = true
		t.bound = ityp // update t.bound for next time (optimization)
	}

	// compute type set if necessary
	if ityp.tset == nil {
		// pos is used for tracing output; start with the type parameter position.
		pos := t.obj.pos
		// use the (original or possibly instantiated) type bound position if we have one
		if n := asNamed(bound); n != nil {
			pos = n.obj.pos
		}
		computeInterfaceTypeSet(t.check, pos, ityp)
	}

	return ityp
}

// is calls f with the specific type terms of t's constraint and reports whether
// all calls to f returned true. If there are no specific terms, is
// returns the result of f(nil).
func (t *TypeParam) is(f func(*term) bool) bool {
	return t.iface().typeSet().is(f)
}

// typeset is an iterator over the (type/underlying type) pairs of the
// specific type terms of t's constraint.
// If there are no specific terms, typeset calls yield with (nil, nil).
// In any case, typeset is guaranteed to call yield at least once.
func (t *TypeParam) typeset(yield func(t, u Type) bool) {
	t.iface().typeSet().typeset(yield)
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Dec 2025 6.06 PM
root / root
0755
README.md
0.133 KB
4 Dec 2025 6.06 PM
root / root
0644
alias.go
6.063 KB
4 Dec 2025 6.06 PM
root / root
0644
api.go
17.887 KB
4 Dec 2025 6.06 PM
root / root
0644
api_predicates.go
3.451 KB
4 Dec 2025 6.06 PM
root / root
0644
array.go
0.905 KB
4 Dec 2025 6.06 PM
root / root
0644
assignments.go
16.889 KB
4 Dec 2025 6.06 PM
root / root
0644
badlinkname.go
0.686 KB
4 Dec 2025 6.06 PM
root / root
0644
basic.go
1.605 KB
4 Dec 2025 6.06 PM
root / root
0644
builtins.go
29.413 KB
4 Dec 2025 6.06 PM
root / root
0644
call.go
33.833 KB
4 Dec 2025 6.06 PM
root / root
0644
chan.go
1.009 KB
4 Dec 2025 6.06 PM
root / root
0644
check.go
21.786 KB
4 Dec 2025 6.06 PM
root / root
0644
const.go
7.618 KB
4 Dec 2025 6.06 PM
root / root
0644
context.go
4.429 KB
4 Dec 2025 6.06 PM
root / root
0644
conversions.go
9.082 KB
4 Dec 2025 6.06 PM
root / root
0644
decl.go
31.035 KB
4 Dec 2025 6.06 PM
root / root
0644
errors.go
8.49 KB
4 Dec 2025 6.06 PM
root / root
0644
errsupport.go
4.528 KB
4 Dec 2025 6.06 PM
root / root
0644
eval.go
3.069 KB
4 Dec 2025 6.06 PM
root / root
0644
expr.go
39.407 KB
4 Dec 2025 6.06 PM
root / root
0644
exprstring.go
4.781 KB
4 Dec 2025 6.06 PM
root / root
0644
format.go
4.031 KB
4 Dec 2025 6.06 PM
root / root
0644
gccgosizes.go
1.143 KB
4 Dec 2025 6.06 PM
root / root
0644
gcsizes.go
4.357 KB
4 Dec 2025 6.06 PM
root / root
0644
generate.go
0.263 KB
4 Dec 2025 6.06 PM
root / root
0644
gotype.go
8.33 KB
4 Dec 2025 6.06 PM
root / root
0644
index.go
11.772 KB
4 Dec 2025 6.06 PM
root / root
0644
infer.go
27.142 KB
4 Dec 2025 6.06 PM
root / root
0644
initorder.go
10.131 KB
4 Dec 2025 6.06 PM
root / root
0644
instantiate.go
13.211 KB
4 Dec 2025 6.06 PM
root / root
0644
interface.go
8.155 KB
4 Dec 2025 6.06 PM
root / root
0644
iter.go
3.873 KB
4 Dec 2025 6.06 PM
root / root
0644
labels.go
7.295 KB
4 Dec 2025 6.06 PM
root / root
0644
literals.go
12.77 KB
4 Dec 2025 6.06 PM
root / root
0644
lookup.go
22.653 KB
4 Dec 2025 6.06 PM
root / root
0644
map.go
0.763 KB
4 Dec 2025 6.06 PM
root / root
0644
methodset.go
7.058 KB
4 Dec 2025 6.06 PM
root / root
0644
mono.go
9.194 KB
4 Dec 2025 6.06 PM
root / root
0644
named.go
24.34 KB
4 Dec 2025 6.06 PM
root / root
0644
object.go
22.06 KB
4 Dec 2025 6.06 PM
root / root
0644
objset.go
1.028 KB
4 Dec 2025 6.06 PM
root / root
0644
operand.go
12.16 KB
4 Dec 2025 6.06 PM
root / root
0644
package.go
3.05 KB
4 Dec 2025 6.06 PM
root / root
0644
pointer.go
0.743 KB
4 Dec 2025 6.06 PM
root / root
0644
predicates.go
17.609 KB
4 Dec 2025 6.06 PM
root / root
0644
range.go
9.338 KB
4 Dec 2025 6.06 PM
root / root
0644
recording.go
4.648 KB
4 Dec 2025 6.06 PM
root / root
0644
resolver.go
25.255 KB
4 Dec 2025 6.06 PM
root / root
0644
return.go
4.232 KB
4 Dec 2025 6.06 PM
root / root
0644
scope.go
7.632 KB
4 Dec 2025 6.06 PM
root / root
0644
scope2.go
2.554 KB
4 Dec 2025 6.06 PM
root / root
0644
selection.go
5.906 KB
4 Dec 2025 6.06 PM
root / root
0644
signature.go
17.81 KB
4 Dec 2025 6.06 PM
root / root
0644
sizes.go
8.939 KB
4 Dec 2025 6.06 PM
root / root
0644
slice.go
0.685 KB
4 Dec 2025 6.06 PM
root / root
0644
stmt.go
23.696 KB
4 Dec 2025 6.06 PM
root / root
0644
struct.go
6.149 KB
4 Dec 2025 6.06 PM
root / root
0644
subst.go
10.411 KB
4 Dec 2025 6.06 PM
root / root
0644
termlist.go
3.894 KB
4 Dec 2025 6.06 PM
root / root
0644
tuple.go
1.028 KB
4 Dec 2025 6.06 PM
root / root
0644
type.go
0.528 KB
4 Dec 2025 6.06 PM
root / root
0644
typelists.go
1.967 KB
4 Dec 2025 6.06 PM
root / root
0644
typeparam.go
5.224 KB
4 Dec 2025 6.06 PM
root / root
0644
typeset.go
13.31 KB
4 Dec 2025 6.06 PM
root / root
0644
typestring.go
12.479 KB
4 Dec 2025 6.06 PM
root / root
0644
typeterm.go
3.643 KB
4 Dec 2025 6.06 PM
root / root
0644
typexpr.go
16.179 KB
4 Dec 2025 6.06 PM
root / root
0644
under.go
4.331 KB
4 Dec 2025 6.06 PM
root / root
0644
unify.go
27.898 KB
4 Dec 2025 6.06 PM
root / root
0644
union.go
6.225 KB
4 Dec 2025 6.06 PM
root / root
0644
universe.go
9.354 KB
4 Dec 2025 6.06 PM
root / root
0644
util.go
1.9 KB
4 Dec 2025 6.06 PM
root / root
0644
validtype.go
10.345 KB
4 Dec 2025 6.06 PM
root / root
0644
version.go
2.036 KB
4 Dec 2025 6.06 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF