@@ -107,24 +107,26 @@ DSymbol*[] getSymbolsForUFCS(Scope* completionScope, const(DSymbol)* beforeDotSy
107
107
}
108
108
109
109
/**
110
- Params:
111
- symbol = the symbol to check
112
- incomingSymbol = symbols we check on
113
- Returns:
114
- true if incomingSymbols first parameter matches beforeDotSymbol
115
- false otherwise
116
- */
117
- bool isCallableWithArg (const (DSymbol)* incomingSymbol, const (DSymbol)* beforeDotSymbol, bool isGlobalScope = false )
110
+ * Params:
111
+ * incomingSymbol = the function symbol to check if it is valid for UFCS with `beforeDotType`.
112
+ * beforeDotType = the type of the expression that's used before the dot.
113
+ * isGlobalScope = the symbol to check
114
+ * Returns:
115
+ * `true` if `incomingSymbols`' first parameter matches `beforeDotType`
116
+ * `false` otherwise
117
+ */
118
+ bool isCallableWithArg (const (DSymbol)* incomingSymbol, const (DSymbol)* beforeDotType, bool isGlobalScope = false )
118
119
{
119
- if (isGlobalScope && incomingSymbol.protection == tok! " private" )
120
+ if (! incomingSymbol || ! beforeDotType
121
+ || (isGlobalScope && incomingSymbol.protection == tok! " private" ))
120
122
{
121
123
return false ;
122
124
}
123
125
124
126
if (incomingSymbol.kind == CompletionKind.functionName && ! incomingSymbol
125
127
.functionParameters.empty)
126
128
{
127
- return incomingSymbol.functionParameters.front.type is beforeDotSymbol ;
129
+ return incomingSymbol.functionParameters.front.type is beforeDotType ;
128
130
}
129
131
130
132
return false ;
@@ -181,11 +183,11 @@ void getUFCSParenCompletion(ref DSymbol*[] symbols, Scope* completionScope, istr
181
183
foreach (nextSymbol; possibleUFCSSymbol){
182
184
if (nextSymbol && nextSymbol.functionParameters)
183
185
{
184
- if (firstSymbol.type is nextSymbol.functionParameters.front. type)
186
+ if (nextSymbol.isCallableWithArg(firstSymbol. type) )
185
187
{
186
188
nextSymbol.kind = CompletionKind.ufcsName;
187
189
symbols ~= nextSymbol;
188
190
}
189
191
}
190
192
}
191
- }
193
+ }
0 commit comments