(e ast.Expr)
| 132 | } |
| 133 | |
| 134 | func (c *checker) checkSelect(e ast.Expr) { |
| 135 | sel := e.AsSelect() |
| 136 | // Before traversing down the tree, try to interpret as qualified name. |
| 137 | qualifiers, found := c.computeQualifiers(e) |
| 138 | if found { |
| 139 | ident := c.env.resolveQualifiedIdent(qualifiers...) |
| 140 | if ident != nil { |
| 141 | // We don't check for a TestOnly expression here since the `found` result is |
| 142 | // always going to be false for TestOnly expressions. |
| 143 | |
| 144 | // Rewrite the node to be a variable reference to the resolved fully-qualified |
| 145 | // variable name. |
| 146 | name := ident.Name() |
| 147 | if ident.requiresDisambiguation { |
| 148 | name = "." + name |
| 149 | } |
| 150 | c.setType(e, ident.Type()) |
| 151 | c.setReference(e, ast.NewIdentReference(name, ident.Value())) |
| 152 | e.SetKindCase(c.NewIdent(e.ID(), name)) |
| 153 | return |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | resultType := c.checkSelectField(e, sel.Operand(), sel.FieldName(), false) |
| 158 | if sel.IsTestOnly() { |
| 159 | resultType = types.BoolType |
| 160 | } |
| 161 | c.setType(e, substitute(c.mappings, resultType, false)) |
| 162 | } |
| 163 | |
| 164 | // computeQualifiers computes the qualified names parts of a select expression. |
| 165 | func (c *checker) computeQualifiers(e ast.Expr) ([]string, bool) { |
no test coverage detected