@@ -1866,6 +1866,9 @@ private MethodInvocationTreeImpl invocation(Node node) {
18661866 } else if (identifier .symbol () instanceof Symbol .MethodSymbol bound ) {
18671867 identifier .symbol = sema .preferOverload (bound , libraryMethod (qualifier , identifier .name (), arguments ), arguments );
18681868 }
1869+ if (identifier .symbol instanceof JMethodSymbol method && !method .isUnknown () && !JSema .arityMatches (method , arguments .size ())) {
1870+ identifier .symbol = Symbol .MethodSymbol .UNKNOWN_METHOD ;
1871+ }
18691872 if (identifier .symbol instanceof JMethodSymbol method ) {
18701873 List <Type > parameters = sema .invocationParameters (method , receiver , arguments );
18711874 ascribeArguments (method , parameters , tree .arguments ());
@@ -1924,7 +1927,7 @@ private void bindConstructor(NewClassTreeImpl tree, @Nullable Node typeNode) {
19241927 Symbol resolved = sema .resolve (constructor );
19251928 String owner = resolved .owner () == null || resolved .owner ().type () == null ? "" : resolved .owner ().type ().erasure ().fullyQualifiedName ();
19261929 boolean importedElsewhere = imported != null && sema .declaresType (imported ) && !imported .equals (owner );
1927- if (resolved instanceof Symbol .MethodSymbol method && !importedElsewhere ) {
1930+ if (resolved instanceof Symbol .MethodSymbol method && !importedElsewhere && JSema . arityMatches ( method , tree . arguments (). size ()) ) {
19281931 identifier .symbol = resolved ;
19291932 recordUse (resolved , identifier );
19301933 ascribeArguments (method , tree .arguments ());
@@ -1938,7 +1941,7 @@ private void bindConstructor(NewClassTreeImpl tree, @Nullable Node typeNode) {
19381941 }
19391942 String owner = tree .classBody () != null && type .symbol ().isInterface () ? "java.lang.Object" : type .fullyQualifiedName ();
19401943 Symbol .MethodSymbol declared = type .isClass () ? sema .declaredMethod (owner , "<init>" , argumentTypes (tree .arguments ())) : null ;
1941- if (declared != null ) {
1944+ if (declared != null && JSema . arityMatches ( declared , tree . arguments (). size ()) ) {
19421945 identifier .symbol = declared ;
19431946 recordUse (declared , identifier );
19441947 ascribeArguments (declared , tree .arguments ());
0 commit comments