Black Lives Matter. Support the Equal Justice Initiative.

Source file src/go/types/api_typeparams.go

Documentation: go/types

     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 typeparams
     6  // +build typeparams
     7  
     8  package types
     9  
    10  import (
    11  	"go/ast"
    12  )
    13  
    14  type (
    15  	Inferred  = _Inferred
    16  	Sum       = _Sum
    17  	TypeParam = _TypeParam
    18  )
    19  
    20  func NewSum(types []Type) Type { return _NewSum(types) }
    21  
    22  func (s *Signature) TParams() []*TypeName           { return s._TParams() }
    23  func (s *Signature) SetTParams(tparams []*TypeName) { s._SetTParams(tparams) }
    24  
    25  func (t *Interface) HasTypeList() bool  { return t._HasTypeList() }
    26  func (t *Interface) IsComparable() bool { return t._IsComparable() }
    27  func (t *Interface) IsConstraint() bool { return t._IsConstraint() }
    28  
    29  func (t *Named) TParams() []*TypeName { return t._TParams() }
    30  func (t *Named) TArgs() []Type        { return t._TArgs() }
    31  func (t *Named) SetTArgs(args []Type) { t._SetTArgs(args) }
    32  
    33  // Info is documented in api_notypeparams.go.
    34  type Info struct {
    35  	Types map[ast.Expr]TypeAndValue
    36  
    37  	// Inferred maps calls of parameterized functions that use type inference to
    38  	// the Inferred type arguments and signature of the function called. The
    39  	// recorded "call" expression may be an *ast.CallExpr (as in f(x)), or an
    40  	// *ast.IndexExpr (s in f[T]).
    41  	Inferred map[ast.Expr]_Inferred
    42  
    43  	Defs       map[*ast.Ident]Object
    44  	Uses       map[*ast.Ident]Object
    45  	Implicits  map[ast.Node]Object
    46  	Selections map[*ast.SelectorExpr]*Selection
    47  	Scopes     map[ast.Node]*Scope
    48  	InitOrder  []*Initializer
    49  }
    50  
    51  func getInferred(info *Info) map[ast.Expr]_Inferred {
    52  	return info.Inferred
    53  }
    54  

View as plain text