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 || !go1.17 6// +build !typeparams !go1.17 7 8package typeparams 9 10import ( 11 "go/ast" 12 "go/types" 13) 14 15// NOTE: doc comments must be kept in sync with typeparams.go. 16 17// Enabled reports whether type parameters are enabled in the current build 18// environment. 19const Enabled = false 20 21// UnpackIndex extracts all index expressions from e. For non-generic code this 22// is always one expression: e.Index, but may be more than one expression for 23// generic type instantiation. 24func UnpackIndex(e *ast.IndexExpr) []ast.Expr { 25 return []ast.Expr{e.Index} 26} 27 28// IsListExpr reports whether n is an *ast.ListExpr, which is a new node type 29// introduced to hold type arguments for generic type instantiation. 30func IsListExpr(n ast.Node) bool { 31 return false 32} 33 34// ForTypeDecl extracts the (possibly nil) type parameter node list from n. 35func ForTypeDecl(*ast.TypeSpec) *ast.FieldList { 36 return nil 37} 38 39// ForFuncDecl extracts the (possibly nil) type parameter node list from n. 40func ForFuncDecl(*ast.FuncDecl) *ast.FieldList { 41 return nil 42} 43 44// ForSignature extracts the (possibly empty) type parameter object list from 45// sig. 46func ForSignature(*types.Signature) []*types.TypeName { 47 return nil 48} 49 50// HasTypeSet reports if iface has a type set. 51func HasTypeSet(*types.Interface) bool { 52 return false 53} 54 55// IsComparable reports if iface is the comparable interface. 56func IsComparable(*types.Interface) bool { 57 return false 58} 59 60// IsConstraint reports whether iface may only be used as a type parameter 61// constraint (i.e. has a type set or is the comparable interface). 62func IsConstraint(*types.Interface) bool { 63 return false 64} 65 66// ForNamed extracts the (possibly empty) type parameter object list from 67// named. 68func ForNamed(*types.Named) []*types.TypeName { 69 return nil 70} 71 72// NamedTArgs extracts the (possibly empty) type argument list from named. 73func NamedTArgs(*types.Named) []types.Type { 74 return nil 75} 76 77// InitInferred initializes info to record inferred type information. 78func InitInferred(*types.Info) { 79} 80 81// GetInferred extracts inferred type information from info for e. 82// 83// The expression e may have an inferred type if it is an *ast.IndexExpr 84// representing partial instantiation of a generic function type for which type 85// arguments have been inferred using constraint type inference, or if it is an 86// *ast.CallExpr for which type type arguments have be inferred using both 87// constraint type inference and function argument inference. 88func GetInferred(*types.Info, ast.Expr) ([]types.Type, *types.Signature) { 89 return nil, nil 90} 91