@@ -243,7 +243,7 @@ function initSearch(rawSearchIndex) {
243
243
* Map from normalized type names to integers. Used to make type search
244
244
* more efficient.
245
245
*
246
- * @type {Map<string, integer> }
246
+ * @type {Map<string, {id: integer, assocOnly: boolean} > }
247
247
*/
248
248
let typeNameIdMap ;
249
249
const ALIASES = new Map ( ) ;
@@ -270,19 +270,22 @@ function initSearch(rawSearchIndex) {
270
270
* get the same ID.
271
271
*
272
272
* @param {string } name
273
+ * @param {boolean } isAssocType - True if this is an assoc type
273
274
*
274
275
* @returns {integer }
275
276
*/
276
- function buildTypeMapIndex ( name ) {
277
+ function buildTypeMapIndex ( name , isAssocType ) {
277
278
if ( name === "" || name === null ) {
278
279
return null ;
279
280
}
280
281
281
282
if ( typeNameIdMap . has ( name ) ) {
282
- return typeNameIdMap . get ( name ) ;
283
+ const obj = typeNameIdMap . get ( name ) ;
284
+ obj . assocOnly = isAssocType && obj . assocOnly ;
285
+ return obj . id ;
283
286
} else {
284
287
const id = typeNameIdMap . size ;
285
- typeNameIdMap . set ( name , id ) ;
288
+ typeNameIdMap . set ( name , { id , assocOnly : isAssocType } ) ;
286
289
return id ;
287
290
}
288
291
}
@@ -1430,7 +1433,7 @@ function initSearch(rawSearchIndex) {
1430
1433
return true ;
1431
1434
}
1432
1435
} else if ( unifyFunctionTypes (
1433
- fnType . generics ,
1436
+ [ ... fnType . generics , ... Array . from ( fnType . bindings . values ( ) ) . flat ( ) ] ,
1434
1437
queryElems ,
1435
1438
whereClause ,
1436
1439
mgens ? new Map ( mgens ) : null ,
@@ -2129,17 +2132,20 @@ function initSearch(rawSearchIndex) {
2129
2132
* See `buildTypeMapIndex` for more information.
2130
2133
*
2131
2134
* @param {QueryElement } elem
2135
+ * @param {boolean } isAssocType
2132
2136
*/
2133
- function convertNameToId ( elem ) {
2134
- if ( typeNameIdMap . has ( elem . pathLast ) ) {
2135
- elem . id = typeNameIdMap . get ( elem . pathLast ) ;
2137
+ function convertNameToId ( elem , isAssocType ) {
2138
+ if ( typeNameIdMap . has ( elem . pathLast ) &&
2139
+ ( isAssocType || ! typeNameIdMap . get ( elem . pathLast ) . assocOnly ) ) {
2140
+ elem . id = typeNameIdMap . get ( elem . pathLast ) . id ;
2136
2141
} else if ( ! parsedQuery . literalSearch ) {
2137
2142
let match = null ;
2138
2143
let matchDist = maxEditDistance + 1 ;
2139
2144
let matchName = "" ;
2140
- for ( const [ name , id ] of typeNameIdMap ) {
2145
+ for ( const [ name , { id , assocOnly } ] of typeNameIdMap ) {
2141
2146
const dist = editDistance ( name , elem . pathLast , maxEditDistance ) ;
2142
- if ( dist <= matchDist && dist <= maxEditDistance ) {
2147
+ if ( dist <= matchDist && dist <= maxEditDistance &&
2148
+ ( isAssocType || ! assocOnly ) ) {
2143
2149
if ( dist === matchDist && matchName > name ) {
2144
2150
continue ;
2145
2151
}
@@ -2206,12 +2212,13 @@ function initSearch(rawSearchIndex) {
2206
2212
name ,
2207
2213
" does not exist" ,
2208
2214
] ;
2215
+ return [ null , [ ] ] ;
2209
2216
}
2210
2217
for ( const elem2 of constraints ) {
2211
2218
convertNameToId ( elem2 ) ;
2212
2219
}
2213
2220
2214
- return [ typeNameIdMap . get ( name ) , constraints ] ;
2221
+ return [ typeNameIdMap . get ( name ) . id , constraints ] ;
2215
2222
} )
2216
2223
) ;
2217
2224
}
@@ -2720,7 +2727,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
2720
2727
*
2721
2728
* @param {RawFunctionType } type
2722
2729
*/
2723
- function buildItemSearchType ( type , lowercasePaths ) {
2730
+ function buildItemSearchType ( type , lowercasePaths , isAssocType ) {
2724
2731
const PATH_INDEX_DATA = 0 ;
2725
2732
const GENERICS_DATA = 1 ;
2726
2733
const BINDINGS_DATA = 2 ;
@@ -2749,7 +2756,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
2749
2756
//
2750
2757
// As a result, the key should never have generics on it.
2751
2758
return [
2752
- buildItemSearchType ( assocType , lowercasePaths ) . id ,
2759
+ buildItemSearchType ( assocType , lowercasePaths , true ) . id ,
2753
2760
buildItemSearchTypeAll ( constraints , lowercasePaths ) ,
2754
2761
] ;
2755
2762
} ) ) ;
@@ -2780,7 +2787,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
2780
2787
}
2781
2788
const item = lowercasePaths [ pathIndex - 1 ] ;
2782
2789
return {
2783
- id : buildTypeMapIndex ( item . name ) ,
2790
+ id : buildTypeMapIndex ( item . name , isAssocType ) ,
2784
2791
ty : item . ty ,
2785
2792
path : item . path ,
2786
2793
generics,
0 commit comments