@@ -441,9 +441,15 @@ public Description matchNewClass(NewClassTree tree, VisitorState state) {
441
441
if (methodSymbol == null ) {
442
442
throw new RuntimeException ("not expecting unresolved method here" );
443
443
}
444
+ ExpressionTree enclosingExpression = tree .getEnclosingExpression ();
445
+ if (enclosingExpression != null ) {
446
+ // technically this is not a dereference; there is a requireNonNull() call in the
447
+ // bytecode. but it's close enough for error reporting
448
+ state .reportMatch (matchDereference (enclosingExpression , tree , state ));
449
+ }
444
450
List <? extends ExpressionTree > actualParams = tree .getArguments ();
445
- if (tree .getClassBody () != null && actualParams . size () > 0 ) {
446
- // passing parameters to constructor of anonymous class
451
+ if (tree .getClassBody () != null ) {
452
+ // invoking constructor of anonymous class
447
453
// this constructor just invokes the constructor of the superclass, and
448
454
// in the AST does not have the parameter nullability annotations from the superclass.
449
455
// so, treat as if the superclass constructor is being invoked directly
@@ -1861,18 +1867,7 @@ private Description handleInvocation(
1861
1867
Symbol .MethodSymbol methodSymbol ,
1862
1868
List <? extends ExpressionTree > actualParams ) {
1863
1869
List <VarSymbol > formalParams = methodSymbol .getParameters ();
1864
-
1865
1870
boolean varArgsMethod = methodSymbol .isVarArgs ();
1866
- if (formalParams .size () != actualParams .size ()
1867
- && !varArgsMethod
1868
- && !methodSymbol .isStatic ()
1869
- && methodSymbol .isConstructor ()
1870
- && methodSymbol .enclClass ().isInner ()) {
1871
- // In special cases like one in issue #366
1872
- // formal params and actual params do not match while using JDK11+
1873
- // we bail out in this particular case
1874
- return Description .NO_MATCH ;
1875
- }
1876
1871
1877
1872
// always do unboxing checks, whether or not the invoked method is annotated
1878
1873
for (int i = 0 ; i < formalParams .size () && i < actualParams .size (); i ++) {
0 commit comments