@@ -345,6 +345,29 @@ private predicate elementSpec(
345
345
neutralModel ( package , type , name , signature , _, _) and ext = "" and subtypes = false
346
346
}
347
347
348
+ private string getNestedName ( Type t ) {
349
+ not t instanceof RefType and result = t .toString ( )
350
+ or
351
+ not t .( Array ) .getElementType ( ) instanceof NestedType and result = t .( RefType ) .nestedName ( )
352
+ or
353
+ result =
354
+ t .( Array ) .getElementType ( ) .( NestedType ) .getEnclosingType ( ) .nestedName ( ) + "$" + t .getName ( )
355
+ }
356
+
357
+ private string getQualifiedName ( Type t ) {
358
+ not t instanceof RefType and result = t .toString ( )
359
+ or
360
+ result = t .( RefType ) .getQualifiedName ( )
361
+ or
362
+ exists ( Array a , Type c | a = t and c = a .getElementType ( ) |
363
+ not c instanceof RefType and result = t .toString ( )
364
+ or
365
+ exists ( string pkgName | pkgName = c .( RefType ) .getPackage ( ) .getName ( ) |
366
+ if pkgName = "" then result = getNestedName ( a ) else result = pkgName + "." + getNestedName ( a )
367
+ )
368
+ )
369
+ }
370
+
348
371
/**
349
372
* Gets a parenthesized string containing all parameter types of this callable, separated by a comma.
350
373
*
@@ -353,32 +376,86 @@ private predicate elementSpec(
353
376
*/
354
377
cached
355
378
string paramsString ( Callable c ) {
379
+ result =
380
+ "(" + concat ( int i | | getNestedName ( c .getParameterType ( i ) .getErasure ( ) ) , "," order by i ) + ")"
381
+ }
382
+
383
+ pragma [ nomagic]
384
+ private string paramsString_old ( Callable c ) {
356
385
result =
357
386
"(" + concat ( int i | | c .getParameterType ( i ) .getErasure ( ) .toString ( ) , "," order by i ) + ")"
358
387
}
359
388
360
- private Element interpretElement0 (
389
+ private string paramsStringQualified ( Callable c ) {
390
+ result =
391
+ "(" + concat ( int i | | getQualifiedName ( c .getParameterType ( i ) .getErasure ( ) ) , "," order by i ) +
392
+ ")"
393
+ }
394
+
395
+ predicate failMatch (
396
+ string package , string type , boolean subtypes , string name , string signature , string sig2 ,
397
+ string sigf
398
+ ) {
399
+ elementSpec ( package , type , subtypes , name , signature , _) and
400
+ not exists ( interpretElement0 ( package , type , subtypes , name , signature ) ) and
401
+ exists ( Callable c |
402
+ c = interpretElement0_old ( package , type , subtypes , name , signature ) and
403
+ sig2 = paramsString ( c ) and
404
+ sigf = paramsStringQualified ( c )
405
+ )
406
+ }
407
+
408
+ private Element interpretElement0_old (
361
409
string package , string type , boolean subtypes , string name , string signature
362
410
) {
363
411
elementSpec ( package , type , subtypes , name , signature , _) and
364
- exists ( RefType t | t . hasQualifiedName ( package , type ) |
412
+ (
365
413
exists ( Member m |
366
414
(
367
415
result = m
368
416
or
369
417
subtypes = true and result .( SrcMethod ) .overridesOrInstantiates + ( m )
370
418
) and
371
- m .getDeclaringType ( ) = t and
372
- m .hasName ( name )
419
+ m .hasQualifiedName ( package , type , name )
373
420
|
374
421
signature = "" or
375
422
m .( Callable ) .getSignature ( ) = any ( string nameprefix ) + signature or
423
+ paramsString_old ( m ) = signature
424
+ )
425
+ or
426
+ exists ( RefType t |
427
+ t .hasQualifiedName ( package , type ) and
428
+ ( if subtypes = true then result .( SrcRefType ) .getASourceSupertype * ( ) = t else result = t ) and
429
+ name = "" and
430
+ signature = ""
431
+ )
432
+ )
433
+ }
434
+
435
+ private Element interpretElement0 (
436
+ string package , string type , boolean subtypes , string name , string signature
437
+ ) {
438
+ elementSpec ( package , type , subtypes , name , signature , _) and
439
+ (
440
+ exists ( Member m |
441
+ (
442
+ result = m
443
+ or
444
+ subtypes = true and result .( SrcMethod ) .overridesOrInstantiates + ( m )
445
+ ) and
446
+ m .hasQualifiedName ( package , type , name )
447
+ |
448
+ signature = "" or
449
+ paramsStringQualified ( m ) = signature or
376
450
paramsString ( m ) = signature
377
451
)
378
452
or
379
- ( if subtypes = true then result .( SrcRefType ) .getASourceSupertype * ( ) = t else result = t ) and
380
- name = "" and
381
- signature = ""
453
+ exists ( RefType t |
454
+ t .hasQualifiedName ( package , type ) and
455
+ ( if subtypes = true then result .( SrcRefType ) .getASourceSupertype * ( ) = t else result = t ) and
456
+ name = "" and
457
+ signature = ""
458
+ )
382
459
)
383
460
}
384
461
0 commit comments