(sig *Signature, skipUnionExpanding bool)
| 1904 | } |
| 1905 | |
| 1906 | func (c *Checker) getExpandedParameters(sig *Signature, skipUnionExpanding bool) [][]*ast.Symbol { |
| 1907 | if signatureHasRestParameter(sig) { |
| 1908 | restIndex := len(sig.parameters) - 1 |
| 1909 | restSymbol := sig.parameters[restIndex] |
| 1910 | restType := c.getTypeOfSymbol(restSymbol) |
| 1911 | getUniqAssociatedNamesFromTupleType := func(t *Type, restSymbol *ast.Symbol) []string { |
| 1912 | names := core.MapIndex(t.Target().AsTupleType().elementInfos, func(info TupleElementInfo, i int) string { |
| 1913 | return c.getTupleElementLabel(info, restSymbol, i) |
| 1914 | }) |
| 1915 | if len(names) > 0 { |
| 1916 | duplicates := []int{} |
| 1917 | uniqueNames := make(map[string]bool) |
| 1918 | for i, name := range names { |
| 1919 | _, ok := uniqueNames[name] |
| 1920 | if ok { |
| 1921 | duplicates = append(duplicates, i) |
| 1922 | } else { |
| 1923 | uniqueNames[name] = true |
| 1924 | } |
| 1925 | } |
| 1926 | counters := make(map[string]int) |
| 1927 | for _, i := range duplicates { |
| 1928 | counter, ok := counters[names[i]] |
| 1929 | if !ok { |
| 1930 | counter = 1 |
| 1931 | } |
| 1932 | var name string |
| 1933 | for true { |
| 1934 | name = fmt.Sprintf("%s_%d", names[i], counter) |
| 1935 | _, ok := uniqueNames[name] |
| 1936 | if ok { |
| 1937 | counter++ |
| 1938 | continue |
| 1939 | } else { |
| 1940 | uniqueNames[name] = true |
| 1941 | break |
| 1942 | } |
| 1943 | } |
| 1944 | names[i] = name |
| 1945 | counters[names[i]] = counter + 1 |
| 1946 | } |
| 1947 | } |
| 1948 | return names |
| 1949 | } |
| 1950 | expandSignatureParametersWithTupleMembers := func(restType *Type, restIndex int, restSymbol *ast.Symbol) []*ast.Symbol { |
| 1951 | elementTypes := c.getTypeArguments(restType) |
| 1952 | associatedNames := getUniqAssociatedNamesFromTupleType(restType, restSymbol) |
| 1953 | restParams := core.MapIndex(elementTypes, func(t *Type, i int) *ast.Symbol { |
| 1954 | // Lookup the label from the individual tuple passed in before falling back to the signature `rest` parameter name |
| 1955 | // TODO: getTupleElementLabel can no longer fail, investigate if this lack of falliability meaningfully changes output |
| 1956 | // var name *string |
| 1957 | // if associatedNames != nil && associatedNames[i] != nil { |
| 1958 | // name = associatedNames[i] |
| 1959 | // } else { |
| 1960 | // name = c.getParameterNameAtPosition(sig, restIndex+i, restType) |
| 1961 | // } |
| 1962 | name := associatedNames[i] |
| 1963 | flags := restType.Target().AsTupleType().elementInfos[i].flags |
no test coverage detected