@@ -410,7 +410,9 @@ private int matchMethodTypeArguments(ASTNode node, IMethodBinding method,
410410 boolean isErasurePattern = isPatternErasureMatch ();
411411 boolean isEquivPattern = isPatternEquivalentMatch ();
412412 boolean methodIsRaw = method .isRawMethod ();
413- ITypeBinding [] argBindings = method .getTypeArguments ();
413+ ITypeBinding [] argBindings = node instanceof MethodDeclaration ?
414+ method .getTypeParameters () :
415+ method .getTypeArguments ();
414416 char [][] goal = this .locator .pattern .methodArguments ;
415417
416418 if ( goal .length > 0 && methodIsRaw && isExactPattern ) {
@@ -467,11 +469,14 @@ private int matchMethodTypeArguments(ASTNode node, IMethodBinding method,
467469 for ( int i = 0 ; i < argBindings .length ; i ++ ) {
468470 // Compare each
469471 String goaliString = new String (goal [i ]);
470- IBinding patternBinding = findPossiblyUnresolvedBindingForType (node , goaliString );
471- if ( argBindings [i ].isTypeVariable () && patternBinding == null ) {
472+ ITypeBinding patternBinding = findPossiblyUnresolvedBindingForType (node , goaliString );
473+ ITypeBinding argBinding = argBindings [i ];
474+ if (argBinding .isTypeVariable () && patternBinding == null ) {
472475 continue ;
473476 }
474- boolean match = TypeArgumentMatchingUtility .validateSingleTypeArgMatches (isExactPattern , goaliString , patternBinding , argBindings [i ]);
477+ boolean match =
478+ TypeArgumentMatchingUtility .validateSingleTypeArgMatches (isExactPattern , goaliString , patternBinding , argBindings [i ])
479+ | (bindingIsDeclaration && patternBinding != null && patternBinding .isCastCompatible (argBinding ));
475480 if ( !match ) {
476481 if ( isExactPattern || (!isErasurePattern && !isEquivPattern )) {
477482 return IMPOSSIBLE_MATCH ;
@@ -662,8 +667,7 @@ protected int resolveLevelForNodeWithMethodBinding(ASTNode messageSend,
662667 int declarationLevel = IMPOSSIBLE_MATCH ;
663668 if (invocationLevel == IMPOSSIBLE_MATCH ) {
664669 declarationBinding = invocationBinding .getMethodDeclaration ();
665- if (invocationBinding != declarationBinding )
666- declarationLevel = matchMethod (messageSend , declarationBinding , skipVerif , true );
670+ declarationLevel = matchMethod (messageSend , declarationBinding , skipVerif , true );
667671 if (declarationLevel == IMPOSSIBLE_MATCH )
668672 return IMPOSSIBLE_MATCH ;
669673 invocationOrDeclarationBinding = declarationBinding ;
@@ -1111,6 +1115,17 @@ private IMethodBinding getMethodBindingFromPattern(AST context) {
11111115 */
11121116 @ Override
11131117 public void reportSearchMatch (MatchLocator locator , ASTNode node , SearchMatch match ) throws CoreException {
1118+ if (!(node instanceof MethodDeclaration )
1119+ && !(node instanceof AnnotationTypeMemberDeclaration )
1120+ && DOMASTNodeUtils .getBinding (node ) instanceof IMethodBinding methodBinding
1121+ && (methodBinding .isGenericMethod () || methodBinding .isParameterizedMethod ())
1122+ && pattern .focus instanceof IMethod method
1123+ && !pattern .hasMethodArguments ()) {
1124+ int rule = match .getRule ();
1125+ rule &= ~SearchPattern .R_FULL_MATCH ;
1126+ rule |= SearchPattern .R_EQUIVALENT_MATCH | SearchPattern .R_ERASURE_MATCH ;
1127+ match .setRule (rule );
1128+ }
11141129 if ( preferParamaterizedNode () ) {
11151130 if ( node instanceof MethodInvocation iv ) {
11161131 List <?> l = iv .typeArguments ();
0 commit comments