commonConstantType returns the most constrained type which is mutually resolvable between a set of provided constants. The function takes a slice of Exprs and indexes, but expects all the indexed Exprs to wrap a Constant. The reason it does no take a slice of Constants instead is to avoid forcing c
(vals []Expr, idxs intsets.Fast)
| 437 | // Exprs to wrap a Constant. The reason it does no take a slice of Constants |
| 438 | // instead is to avoid forcing callers to allocate separate slices of Constant. |
| 439 | func commonConstantType(vals []Expr, idxs intsets.Fast) (*types.T, bool) { |
| 440 | var candidates []*types.T |
| 441 | |
| 442 | for i, ok := idxs.Next(0); ok; i, ok = idxs.Next(i + 1) { |
| 443 | availableTypes := vals[i].(Constant).DesirableTypes() |
| 444 | if candidates == nil { |
| 445 | candidates = availableTypes |
| 446 | } else { |
| 447 | candidates = intersectTypeSlices(candidates, availableTypes) |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | if len(candidates) > 0 { |
| 452 | return candidates[0], true |
| 453 | } |
| 454 | return nil, false |
| 455 | } |
| 456 | |
| 457 | // StrVal represents a constant string value. |
| 458 | type StrVal struct { |
no test coverage detected
searching dependent graphs…