Skip to content

Commit 68f6d0c

Browse files
author
Kanchalai Tanglertsampan
committed
Address PR feedback
1 parent 6dfe29e commit 68f6d0c

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎src/services/services.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5983,7 +5983,7 @@ namespace ts {
59835983

59845984
// Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions
59855985
if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
5986-
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, undefined);
5986+
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, {});
59875987
}
59885988
});
59895989

@@ -5995,10 +5995,11 @@ namespace ts {
59955995
* @param symbol a symbol to start searching for the given propertyName
59965996
* @param propertyName a name of property to serach for
59975997
* @param result an array of symbol of found property symbols
5998-
* @param previousIterationSymbol a symbol from previous iteration of calling this function to prevent infinite revisitng of the same symbol.
5998+
* @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisitng of the same symbol.
59995999
* The value of previousIterationSymbol is undefined when the function is first called.
60006000
*/
6001-
function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[], previousIterationSymbol: Symbol): void {
6001+
function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[],
6002+
previousIterationSymbolsCache: SymbolTable): void {
60026003
// If the current symbol is the smae as the previous-iteration symbol, we can just return as the symbol has already been visited
60036004
// This is particularly important for the following cases, so that we do not inifinitely visit the same symbol.
60046005
// For example:
@@ -6010,7 +6011,7 @@ namespace ts {
60106011
// the function will add any found symbol of the property-name, then its sub-routine will call
60116012
// getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already
60126013
// visited symbol, interface "C", the sub- routine will pass the current symbol as previousIterationSymbol.
6013-
if (symbol === previousIterationSymbol) {
6014+
if (previousIterationSymbolsCache && previousIterationSymbolsCache[symbol.name] === symbol) {
60146015
return;
60156016
}
60166017

@@ -6037,7 +6038,8 @@ namespace ts {
60376038
}
60386039

60396040
// Visit the typeReference as well to see if it directly or indirectly use that property
6040-
getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, symbol);
6041+
previousIterationSymbolsCache[symbol.name] = symbol;
6042+
getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache);
60416043
}
60426044
}
60436045
}
@@ -6078,7 +6080,7 @@ namespace ts {
60786080
// see if any is in the list
60796081
if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
60806082
const result: Symbol[] = [];
6081-
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, undefined);
6083+
getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, {});
60826084
return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined);
60836085
}
60846086

0 commit comments

Comments
 (0)