@@ -53,8 +53,9 @@ public ClassFileConstructorInvocationExpression newConstructorInvocationExpressi
5353 int lineNumber , ObjectType objectType , String descriptor ,
5454 TypeMaker .MethodTypes methodTypes , BaseExpression parameters ) {
5555
56+ Map <String , TypeArgument > bindings = new HashMap <>();
5657 BaseType parameterTypes = clone (methodTypes .parameterTypes );
57- Map < String , TypeArgument > bindings = createBindings (null , null , null , methodTypes .typeParameters , TYPE_OBJECT , null , parameterTypes , parameters );
58+ createBindings (bindings , null , null , null , methodTypes .typeParameters , TYPE_OBJECT , null , parameterTypes , parameters );
5859
5960 parameterTypes = bind (bindings , parameterTypes );
6061 bindParameters (parameterTypes , parameters );
@@ -74,11 +75,12 @@ public ClassFileSuperConstructorInvocationExpression newSuperConstructorInvocati
7475 TypeMaker .TypeTypes superTypeTypes = typeMaker .makeTypeTypes (objectType .getInternalName ());
7576
7677 if (superTypeTypes != null ) {
78+ bindings = new HashMap <>();
7779 BaseTypeParameter typeParameters = superTypeTypes .typeParameters ;
7880 BaseTypeArgument typeArguments = typeTypes .superType .getTypeArguments ();
7981 BaseTypeParameter methodTypeParameters = methodTypes .typeParameters ;
8082
81- bindings = createBindings (null , typeParameters , typeArguments , methodTypeParameters , TYPE_OBJECT , null , parameterTypes , parameters );
83+ createBindings (bindings , null , typeParameters , typeArguments , methodTypeParameters , TYPE_OBJECT , null , parameterTypes , parameters );
8284 }
8385 }
8486
@@ -115,10 +117,11 @@ public FieldReferenceExpression newFieldReferenceExpression(
115117 if (typeTypes == null ) {
116118 bindings = contextualBindings ;
117119 } else {
120+ bindings = new HashMap <>();
118121 BaseTypeParameter typeParameters = typeTypes .typeParameters ;
119122 BaseTypeArgument typeArguments = expressionObjectType .getTypeArguments ();
120123
121- bindings = createBindings (expression , typeParameters , typeArguments , null , TYPE_OBJECT , null , null , null );
124+ createBindings (bindings , expression , typeParameters , typeArguments , null , TYPE_OBJECT , null , null , null );
122125 }
123126
124127 type = (Type )bind (bindings , type );
@@ -210,13 +213,13 @@ protected void bind(Type type, ClassFileMethodInvocationExpression mie) {
210213 }
211214 }
212215
213- Map <String , TypeArgument > bindings = createBindings ( expression , typeParameters , typeArguments , methodTypeParameters , type , t , parameterTypes , parameters );
214- boolean bindingsContainsNull = bindings . containsValue ( null );
216+ Map <String , TypeArgument > bindings = new HashMap <>( );
217+ boolean partialBinding = createBindings ( bindings , expression , typeParameters , typeArguments , methodTypeParameters , type , t , parameterTypes , parameters );
215218
216219 mie .setParameterTypes (parameterTypes = bind (bindings , parameterTypes ));
217220 mie .setType ((Type ) bind (bindings , mie .getType ()));
218221
219- if ((methodTypeParameters != null ) && !bindingsContainsNull ) {
222+ if ((methodTypeParameters != null ) && !partialBinding ) {
220223 bindTypeParametersToNonWildcardTypeArgumentsVisitor .init (bindings );
221224 methodTypeParameters .accept (bindTypeParametersToNonWildcardTypeArgumentsVisitor );
222225 mie .setNonWildcardTypeArguments (bindTypeParametersToNonWildcardTypeArgumentsVisitor .getTypeArgument ());
@@ -225,7 +228,7 @@ protected void bind(Type type, ClassFileMethodInvocationExpression mie) {
225228 if (expressionType .isObjectType ()) {
226229 ObjectType expressionObjectType = (ObjectType ) expressionType ;
227230
228- if (bindings .isEmpty () || bindingsContainsNull ) {
231+ if (bindings .isEmpty () || partialBinding ) {
229232 expressionType = expressionObjectType .createType (null );
230233 } else {
231234 if (expression .isObjectTypeReferenceExpression () || (typeParameters == null )) {
@@ -241,7 +244,7 @@ protected void bind(Type type, ClassFileMethodInvocationExpression mie) {
241244 }
242245 }
243246 } else if (expressionType .isGenericType ()) {
244- if (bindings .isEmpty () || bindingsContainsNull ) {
247+ if (bindings .isEmpty () || partialBinding ) {
245248 expressionType = ObjectType .TYPE_OBJECT ;
246249 } else {
247250 TypeArgument typeArgument = bindings .get (expressionType .getName ());
@@ -297,7 +300,8 @@ protected void bind(Type type, ClassFileNewExpression ne) {
297300 }
298301 }
299302
300- Map <String , TypeArgument > bindings = createBindings (null , typeParameters , typeArguments , null , type , t , parameterTypes , parameters );
303+ Map <String , TypeArgument > bindings = new HashMap <>();
304+ boolean partialBinding = createBindings (bindings , null , typeParameters , typeArguments , null , type , t , parameterTypes , parameters );
301305
302306 ne .setParameterTypes (parameterTypes = bind (bindings , parameterTypes ));
303307
@@ -308,7 +312,9 @@ protected void bind(Type type, ClassFileNewExpression ne) {
308312 entry .setValue (typeArgumentToTypeVisitor .getType ());
309313 }
310314
311- ne .setType ((ObjectType ) bind (bindings , neObjectType ));
315+ if (!partialBinding ) {
316+ ne .setType ((ObjectType ) bind (bindings , neObjectType ));
317+ }
312318 }
313319 }
314320
@@ -347,12 +353,10 @@ public static void staticBindParameterTypesWithArgumentTypes(Type type, Expressi
347353 }
348354 }
349355
350- protected Map < String , TypeArgument > createBindings (
351- Expression expression ,
356+ protected boolean createBindings (
357+ Map < String , TypeArgument > bindings , Expression expression ,
352358 BaseTypeParameter typeParameters , BaseTypeArgument typeArguments , BaseTypeParameter methodTypeParameters ,
353359 Type returnType , Type returnExpressionType , BaseType parameterTypes , BaseExpression parameters ) {
354-
355- Map <String , TypeArgument > bindings = new HashMap <>();
356360 Map <String , BaseType > typeBounds = new HashMap <>();
357361 boolean statik = (expression != null ) && expression .isObjectTypeReferenceExpression ();
358362
@@ -401,7 +405,9 @@ protected Map<String, TypeArgument> createBindings(
401405 }
402406 }
403407
404- if (bindings .containsValue (null )) {
408+ boolean bindingsContainsNull = bindings .containsValue (null );
409+
410+ if (bindingsContainsNull ) {
405411 if (eraseTypeArguments (expression , typeParameters , typeArguments )) {
406412 for (Map .Entry <String , TypeArgument > entry : bindings .entrySet ()) {
407413 entry .setValue (null );
@@ -428,7 +434,7 @@ protected Map<String, TypeArgument> createBindings(
428434 }
429435 }
430436
431- return bindings ;
437+ return bindingsContainsNull ;
432438 }
433439
434440 protected boolean eraseTypeArguments (Expression expression , BaseTypeParameter typeParameters , BaseTypeArgument typeArguments ) {
0 commit comments