@@ -243,7 +243,7 @@ function initSearch(rawSearchIndex) {
243243 * Map from normalized type names to integers. Used to make type search
244244 * more efficient.
245245 *
246- * @type {Map<string, integer> }
246+ * @type {Map<string, {id: integer, assocOnly: boolean} > }
247247 */
248248 let typeNameIdMap ;
249249 const ALIASES = new Map ( ) ;
@@ -270,19 +270,22 @@ function initSearch(rawSearchIndex) {
270270 * get the same ID.
271271 *
272272 * @param {string } name
273+ * @param {boolean } isAssocType - True if this is an assoc type
273274 *
274275 * @returns {integer }
275276 */
276- function buildTypeMapIndex ( name ) {
277+ function buildTypeMapIndex ( name , isAssocType ) {
277278 if ( name === "" || name === null ) {
278279 return null ;
279280 }
280281
281282 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 ;
283286 } else {
284287 const id = typeNameIdMap . size ;
285- typeNameIdMap . set ( name , id ) ;
288+ typeNameIdMap . set ( name , { id , assocOnly : isAssocType } ) ;
286289 return id ;
287290 }
288291 }
@@ -1430,7 +1433,7 @@ function initSearch(rawSearchIndex) {
14301433 return true ;
14311434 }
14321435 } else if ( unifyFunctionTypes (
1433- fnType . generics ,
1436+ [ ... fnType . generics , ... Array . from ( fnType . bindings . values ( ) ) . flat ( ) ] ,
14341437 queryElems ,
14351438 whereClause ,
14361439 mgens ? new Map ( mgens ) : null ,
@@ -2129,17 +2132,20 @@ function initSearch(rawSearchIndex) {
21292132 * See `buildTypeMapIndex` for more information.
21302133 *
21312134 * @param {QueryElement } elem
2135+ * @param {boolean } isAssocType
21322136 */
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 ;
21362141 } else if ( ! parsedQuery . literalSearch ) {
21372142 let match = null ;
21382143 let matchDist = maxEditDistance + 1 ;
21392144 let matchName = "" ;
2140- for ( const [ name , id ] of typeNameIdMap ) {
2145+ for ( const [ name , { id , assocOnly } ] of typeNameIdMap ) {
21412146 const dist = editDistance ( name , elem . pathLast , maxEditDistance ) ;
2142- if ( dist <= matchDist && dist <= maxEditDistance ) {
2147+ if ( dist <= matchDist && dist <= maxEditDistance &&
2148+ ( isAssocType || ! assocOnly ) ) {
21432149 if ( dist === matchDist && matchName > name ) {
21442150 continue ;
21452151 }
@@ -2206,12 +2212,13 @@ function initSearch(rawSearchIndex) {
22062212 name ,
22072213 " does not exist" ,
22082214 ] ;
2215+ return [ null , [ ] ] ;
22092216 }
22102217 for ( const elem2 of constraints ) {
22112218 convertNameToId ( elem2 ) ;
22122219 }
22132220
2214- return [ typeNameIdMap . get ( name ) , constraints ] ;
2221+ return [ typeNameIdMap . get ( name ) . id , constraints ] ;
22152222 } )
22162223 ) ;
22172224 }
@@ -2720,7 +2727,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
27202727 *
27212728 * @param {RawFunctionType } type
27222729 */
2723- function buildItemSearchType ( type , lowercasePaths ) {
2730+ function buildItemSearchType ( type , lowercasePaths , isAssocType ) {
27242731 const PATH_INDEX_DATA = 0 ;
27252732 const GENERICS_DATA = 1 ;
27262733 const BINDINGS_DATA = 2 ;
@@ -2749,7 +2756,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
27492756 //
27502757 // As a result, the key should never have generics on it.
27512758 return [
2752- buildItemSearchType ( assocType , lowercasePaths ) . id ,
2759+ buildItemSearchType ( assocType , lowercasePaths , true ) . id ,
27532760 buildItemSearchTypeAll ( constraints , lowercasePaths ) ,
27542761 ] ;
27552762 } ) ) ;
@@ -2780,7 +2787,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
27802787 }
27812788 const item = lowercasePaths [ pathIndex - 1 ] ;
27822789 return {
2783- id : buildTypeMapIndex ( item . name ) ,
2790+ id : buildTypeMapIndex ( item . name , isAssocType ) ,
27842791 ty : item . ty ,
27852792 path : item . path ,
27862793 generics,
0 commit comments