We normalize combinations of intersection and union types based on the distributive property of the '&' operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection types with union type constituents into equivalent union types with intersection type cons
(types []*Type)
| 25944 | // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution |
| 25945 | // for intersections of types with signatures can be deterministic. |
| 25946 | func (c *Checker) getIntersectionType(types []*Type) *Type { |
| 25947 | return c.getIntersectionTypeEx(types, IntersectionFlagsNone, nil /*alias*/) |
| 25948 | } |
| 25949 | |
| 25950 | func (c *Checker) getIntersectionTypeEx(types []*Type, flags IntersectionFlags, alias *TypeAlias) *Type { |
| 25951 | var orderedTypes orderedSet[*Type] |
no test coverage detected