@@ -345,6 +345,29 @@ private predicate elementSpec(
345345 neutralModel ( package , type , name , signature , _, _) and ext = "" and subtypes = false
346346}
347347
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+
348371/**
349372 * Gets a parenthesized string containing all parameter types of this callable, separated by a comma.
350373 *
@@ -353,32 +376,86 @@ private predicate elementSpec(
353376 */
354377cached
355378string 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 ) {
356385 result =
357386 "(" + concat ( int i | | c .getParameterType ( i ) .getErasure ( ) .toString ( ) , "," order by i ) + ")"
358387}
359388
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 (
361409 string package , string type , boolean subtypes , string name , string signature
362410) {
363411 elementSpec ( package , type , subtypes , name , signature , _) and
364- exists ( RefType t | t . hasQualifiedName ( package , type ) |
412+ (
365413 exists ( Member m |
366414 (
367415 result = m
368416 or
369417 subtypes = true and result .( SrcMethod ) .overridesOrInstantiates + ( m )
370418 ) and
371- m .getDeclaringType ( ) = t and
372- m .hasName ( name )
419+ m .hasQualifiedName ( package , type , name )
373420 |
374421 signature = "" or
375422 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
376450 paramsString ( m ) = signature
377451 )
378452 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+ )
382459 )
383460}
384461
0 commit comments