@@ -221,42 +221,31 @@ OLD: KE1
221
221
}
222
222
*/
223
223
224
- private fun isFunctionMatchingNames (
225
- symbol : KaFunctionSymbol ,
224
+ private fun KaFunctionSymbol.hasMatchingNames (
226
225
name : CallableId ,
227
- isExtension : Boolean = false ,
226
+ extensionReceiverClassName : ClassId ? = null ,
228
227
nullability : KaTypeNullability = KaTypeNullability .UNKNOWN ,
229
- extensionReceiverClassName : ClassId ? = null
230
228
): Boolean {
231
229
232
- if (symbol .callableId != name)
230
+ if (this .callableId != name)
233
231
return false
234
232
235
- if (! isExtension)
236
- return true
237
-
238
- val receiverType = symbol.receiverParameter?.type
239
- if (receiverType == null )
240
- return false
241
-
242
- if (receiverType.nullability != nullability)
243
- return false
244
-
245
- if (receiverType.symbol?.classId != extensionReceiverClassName)
246
- return false
233
+ val receiverType = this .receiverParameter?.type
234
+ if (receiverType != null && extensionReceiverClassName != null ) {
235
+ return receiverType.nullability == nullability &&
236
+ receiverType.symbol?.classId == extensionReceiverClassName
237
+ }
247
238
248
- return true
239
+ return receiverType == null && extensionReceiverClassName == null
249
240
}
250
241
251
- private fun isFunctionMatchingName (
252
- symbol : KaFunctionSymbol ,
242
+ private fun KaFunctionSymbol.hasName (
253
243
packageName : String ,
254
244
className : String? ,
255
245
functionName : String
256
246
): Boolean {
257
247
258
- return isFunctionMatchingNames(
259
- symbol,
248
+ return this .hasMatchingNames(
260
249
CallableId (
261
250
FqName (packageName),
262
251
if (className == null ) null else FqName (className),
@@ -265,13 +254,13 @@ private fun isFunctionMatchingName(
265
254
)
266
255
}
267
256
268
- private fun isNumericFunction ( target : KaFunctionSymbol , functionName : String ): Boolean {
269
- return isFunctionMatchingName(target, " kotlin" , " Int" , functionName) ||
270
- isFunctionMatchingName(target, " kotlin" , " Byte" , functionName) ||
271
- isFunctionMatchingName(target, " kotlin" , " Short" , functionName) ||
272
- isFunctionMatchingName(target, " kotlin" , " Long" , functionName) ||
273
- isFunctionMatchingName(target, " kotlin" , " Float" , functionName) ||
274
- isFunctionMatchingName(target, " kotlin" , " Double" , functionName)
257
+ private fun KaFunctionSymbol. isNumericWithName ( functionName : String ): Boolean {
258
+ return this .hasName( " kotlin" , " Int" , functionName) ||
259
+ this .hasName( " kotlin" , " Byte" , functionName) ||
260
+ this .hasName( " kotlin" , " Short" , functionName) ||
261
+ this .hasName( " kotlin" , " Long" , functionName) ||
262
+ this .hasName( " kotlin" , " Float" , functionName) ||
263
+ this .hasName( " kotlin" , " Double" , functionName)
275
264
}
276
265
277
266
/* *
@@ -305,14 +294,12 @@ private fun KotlinFileExtractor.extractBinaryExpression(
305
294
TODO ()
306
295
}
307
296
308
- if (isNumericFunction(target, " plus" ) ||
309
- isFunctionMatchingName(target, " kotlin" , " String" , " plus" ) ||
310
- isFunctionMatchingNames(
311
- target,
297
+ if (target.isNumericWithName(" plus" ) ||
298
+ target.hasName(" kotlin" , " String" , " plus" ) ||
299
+ target.hasMatchingNames(
312
300
CallableId (FqName (" kotlin" ), null , Name .identifier(" plus" )),
313
- isExtension = true ,
301
+ ClassId ( FqName ( " kotlin " ), Name .identifier( " String " )) ,
314
302
nullability = KaTypeNullability .NULLABLE ,
315
- ClassId (FqName (" kotlin" ), Name .identifier(" String" ))
316
303
)
317
304
) {
318
305
val id = tw.getFreshIdLabel<DbAddexpr >()
0 commit comments