SignatureWithDefaults is the same as Signature but also allows specifying whether DEFAULT expressions should be included.
(simplify bool, includeDefaults bool)
| 378 | // SignatureWithDefaults is the same as Signature but also allows specifying |
| 379 | // whether DEFAULT expressions should be included. |
| 380 | func (b Overload) SignatureWithDefaults(simplify bool, includeDefaults bool) string { |
| 381 | retType := b.FixedReturnType() |
| 382 | if simplify { |
| 383 | if retType.Family() == types.TupleFamily && len(retType.TupleContents()) == 1 { |
| 384 | retType = retType.TupleContents()[0] |
| 385 | } |
| 386 | } |
| 387 | t, ok := b.Types.(ParamTypes) |
| 388 | if !includeDefaults || len(b.DefaultExprs) == 0 || !ok { |
| 389 | return fmt.Sprintf("(%s) -> %s", b.Types.String(), retType) |
| 390 | } |
| 391 | return fmt.Sprintf("(%s) -> %s", t.StringWithDefaultExprs(b.DefaultExprs), retType) |
| 392 | |
| 393 | } |
| 394 | |
| 395 | // overloadImpl is an implementation of an overloaded function. It provides |
| 396 | // access to the parameter type list and the return type of the implementation. |
no test coverage detected