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 "go/ast" 11 12 // Info holds result type information for a type-checked package. 13 // Only the information for which a map is provided is collected. 14 // If the package has type errors, the collected information may 15 // be incomplete. 16 type Info struct { 17 // Types maps expressions to their types, and for constant 18 // expressions, also their values. Invalid expressions are 19 // omitted. 20 // 21 // For (possibly parenthesized) identifiers denoting built-in 22 // functions, the recorded signatures are call-site specific: 23 // if the call result is not a constant, the recorded type is 24 // an argument-specific signature. Otherwise, the recorded type 25 // is invalid. 26 // 27 // The Types map does not record the type of every identifier, 28 // only those that appear where an arbitrary expression is 29 // permitted. For instance, the identifier f in a selector 30 // expression x.f is found only in the Selections map, the 31 // identifier z in a variable declaration 'var z int' is found 32 // only in the Defs map, and identifiers denoting packages in 33 // qualified identifiers are collected in the Uses map. 34 Types map[ast.Expr]TypeAndValue 35 36 // Defs maps identifiers to the objects they define (including 37 // package names, dots "." of dot-imports, and blank "_" identifiers). 38 // For identifiers that do not denote objects (e.g., the package name 39 // in package clauses, or symbolic variables t in t := x.(type) of 40 // type switch headers), the corresponding objects are nil. 41 // 42 // For an embedded field, Defs returns the field *Var it defines. 43 // 44 // Invariant: Defs[id] == nil || Defs[id].Pos() == id.Pos() 45 Defs map[*ast.Ident]Object 46 47 // Uses maps identifiers to the objects they denote. 48 // 49 // For an embedded field, Uses returns the *TypeName it denotes. 50 // 51 // Invariant: Uses[id].Pos() != id.Pos() 52 Uses map[*ast.Ident]Object 53 54 // Implicits maps nodes to their implicitly declared objects, if any. 55 // The following node and object types may appear: 56 // 57 // node declared object 58 // 59 // *ast.ImportSpec *PkgName for imports without renames 60 // *ast.CaseClause type-specific *Var for each type switch case clause (incl. default) 61 // *ast.Field anonymous parameter *Var (incl. unnamed results) 62 // 63 Implicits map[ast.Node]Object 64 65 // Selections maps selector expressions (excluding qualified identifiers) 66 // to their corresponding selections. 67 Selections map[*ast.SelectorExpr]*Selection 68 69 // Scopes maps ast.Nodes to the scopes they define. Package scopes are not 70 // associated with a specific node but with all files belonging to a package. 71 // Thus, the package scope can be found in the type-checked Package object. 72 // Scopes nest, with the Universe scope being the outermost scope, enclosing 73 // the package scope, which contains (one or more) files scopes, which enclose 74 // function scopes which in turn enclose statement and function literal scopes. 75 // Note that even though package-level functions are declared in the package 76 // scope, the function scopes are embedded in the file scope of the file 77 // containing the function declaration. 78 // 79 // The following node types may appear in Scopes: 80 // 81 // *ast.File 82 // *ast.FuncType 83 // *ast.BlockStmt 84 // *ast.IfStmt 85 // *ast.SwitchStmt 86 // *ast.TypeSwitchStmt 87 // *ast.CaseClause 88 // *ast.CommClause 89 // *ast.ForStmt 90 // *ast.RangeStmt 91 // 92 Scopes map[ast.Node]*Scope 93 94 // InitOrder is the list of package-level initializers in the order in which 95 // they must be executed. Initializers referring to variables related by an 96 // initialization dependency appear in topological order, the others appear 97 // in source order. Variables without an initialization expression do not 98 // appear in this list. 99 InitOrder []*Initializer 100 } 101 102 func getInferred(info *Info) map[ast.Expr]_Inferred { 103 return nil 104 } 105