GoPLS Viewer

Home|gopls/internal/typeparams/typeparams_go118.go
1// Copyright 2021 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5//go:build go1.18
6// +build go1.18
7
8package typeparams
9
10import (
11    "go/ast"
12    "go/types"
13)
14
15// IndexListExpr is an alias for ast.IndexListExpr.
16type IndexListExpr = ast.IndexListExpr
17
18// ForTypeSpec returns n.TypeParams.
19func ForTypeSpec(n *ast.TypeSpec) *ast.FieldList {
20    if n == nil {
21        return nil
22    }
23    return n.TypeParams
24}
25
26// ForFuncType returns n.TypeParams.
27func ForFuncType(n *ast.FuncType) *ast.FieldList {
28    if n == nil {
29        return nil
30    }
31    return n.TypeParams
32}
33
34// TypeParam is an alias for types.TypeParam
35type TypeParam = types.TypeParam
36
37// TypeParamList is an alias for types.TypeParamList
38type TypeParamList = types.TypeParamList
39
40// TypeList is an alias for types.TypeList
41type TypeList = types.TypeList
42
43// NewTypeParam calls types.NewTypeParam.
44func NewTypeParam(name *types.TypeNameconstraint types.Type) *TypeParam {
45    return types.NewTypeParam(nameconstraint)
46}
47
48// SetTypeParamConstraint calls tparam.SetConstraint(constraint).
49func SetTypeParamConstraint(tparam *TypeParamconstraint types.Type) {
50    tparam.SetConstraint(constraint)
51}
52
53// NewSignatureType calls types.NewSignatureType.
54func NewSignatureType(recv *types.VarrecvTypeParamstypeParams []*TypeParamparamsresults *types.Tuplevariadic bool) *types.Signature {
55    return types.NewSignatureType(recvrecvTypeParamstypeParamsparamsresultsvariadic)
56}
57
58// ForSignature returns sig.TypeParams()
59func ForSignature(sig *types.Signature) *TypeParamList {
60    return sig.TypeParams()
61}
62
63// RecvTypeParams returns sig.RecvTypeParams().
64func RecvTypeParams(sig *types.Signature) *TypeParamList {
65    return sig.RecvTypeParams()
66}
67
68// IsComparable calls iface.IsComparable().
69func IsComparable(iface *types.Interfacebool {
70    return iface.IsComparable()
71}
72
73// IsMethodSet calls iface.IsMethodSet().
74func IsMethodSet(iface *types.Interfacebool {
75    return iface.IsMethodSet()
76}
77
78// IsImplicit calls iface.IsImplicit().
79func IsImplicit(iface *types.Interfacebool {
80    return iface.IsImplicit()
81}
82
83// MarkImplicit calls iface.MarkImplicit().
84func MarkImplicit(iface *types.Interface) {
85    iface.MarkImplicit()
86}
87
88// ForNamed extracts the (possibly empty) type parameter object list from
89// named.
90func ForNamed(named *types.Named) *TypeParamList {
91    return named.TypeParams()
92}
93
94// SetForNamed sets the type params tparams on n. Each tparam must be of
95// dynamic type *types.TypeParam.
96func SetForNamed(n *types.Namedtparams []*TypeParam) {
97    n.SetTypeParams(tparams)
98}
99
100// NamedTypeArgs returns named.TypeArgs().
101func NamedTypeArgs(named *types.Named) *TypeList {
102    return named.TypeArgs()
103}
104
105// NamedTypeOrigin returns named.Orig().
106func NamedTypeOrigin(named *types.Namedtypes.Type {
107    return named.Origin()
108}
109
110// Term is an alias for types.Term.
111type Term = types.Term
112
113// NewTerm calls types.NewTerm.
114func NewTerm(tilde booltyp types.Type) *Term {
115    return types.NewTerm(tildetyp)
116}
117
118// Union is an alias for types.Union
119type Union = types.Union
120
121// NewUnion calls types.NewUnion.
122func NewUnion(terms []*Term) *Union {
123    return types.NewUnion(terms)
124}
125
126// InitInstanceInfo initializes info to record information about type and
127// function instances.
128func InitInstanceInfo(info *types.Info) {
129    info.Instances = make(map[*ast.Ident]types.Instance)
130}
131
132// Instance is an alias for types.Instance.
133type Instance = types.Instance
134
135// GetInstances returns info.Instances.
136func GetInstances(info *types.Info) map[*ast.Ident]Instance {
137    return info.Instances
138}
139
140// Context is an alias for types.Context.
141type Context = types.Context
142
143// NewContext calls types.NewContext.
144func NewContext() *Context {
145    return types.NewContext()
146}
147
148// Instantiate calls types.Instantiate.
149func Instantiate(ctxt *Contexttyp types.Typetargs []types.Typevalidate bool) (types.Typeerror) {
150    return types.Instantiate(ctxttyptargsvalidate)
151}
152
MembersX
ForTypeSpec.n
ForSignature.sig
IsMethodSet.iface
InitInstanceInfo.info
NamedTypeArgs.named
ForFuncType.n
IsComparable.iface
IsImplicit.iface
MarkImplicit.iface
ForNamed.named
SetForNamed.n
Members
X