(typ Type)
| 632 | } |
| 633 | |
| 634 | func (c *Context) Nullable(typ Type) *TypeUnion { |
| 635 | var types []Type |
| 636 | if union, ok := TypeUnder(typ).(*TypeUnion); ok { |
| 637 | for _, t := range union.Types { |
| 638 | if t == TypeNull { |
| 639 | return union |
| 640 | } |
| 641 | } |
| 642 | types = slices.Clone(union.Types) |
| 643 | } else { |
| 644 | types = []Type{typ} |
| 645 | } |
| 646 | return c.LookupTypeUnion(append(types, TypeNull)) |
| 647 | } |
| 648 | |
| 649 | func NullableUnion(typ Type) (*TypeUnion, int) { |
| 650 | if union, ok := typ.(*TypeUnion); ok { |
no test coverage detected