Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 345559 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (+7 lines)
Lines 375-380 Link Here
375
	}
375
	}
376
	if (isDiamond) {
376
	if (isDiamond) {
377
		TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope);
377
		TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope);
378
		if (inferredTypes == null) {
379
			// inference failed because no the number of arguments did not match the number in any constructor
380
			this.resolvedType = null;
381
			return null;
382
		}
378
		this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType());
383
		this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType());
379
 	}
384
 	}
380
	ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
385
	ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
Lines 413-418 Link Here
413
		return ((ParameterizedTypeBinding)factory.returnType).arguments;
418
		return ((ParameterizedTypeBinding)factory.returnType).arguments;
414
	}
419
	}
415
	scope.problemReporter().cannotInferElidedTypes(this);
420
	scope.problemReporter().cannotInferElidedTypes(this);
421
	if (factory == null)
422
		return null;
416
	int arity = allocationType.typeVariables().length;
423
	int arity = allocationType.typeVariables().length;
417
	TypeBinding [] inferredTypes = new TypeBinding[arity];
424
	TypeBinding [] inferredTypes = new TypeBinding[arity];
418
	for (int i = 0; i < arity; i++) {
425
	for (int i = 0; i < arity; i++) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (+5 lines)
Lines 400-405 Link Here
400
			}
400
			}
401
			if (isDiamond) {
401
			if (isDiamond) {
402
				TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) receiverType).genericType(), argumentTypes, scope);
402
				TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) receiverType).genericType(), argumentTypes, scope);
403
				if (inferredTypes == null) {
404
					// inference failed because no the number of arguments did not match the number in any constructor
405
					this.resolvedType = null;
406
					return null;
407
				}
403
				receiverType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) receiverType).genericType(), inferredTypes, ((ParameterizedTypeBinding) receiverType).enclosingType());
408
				receiverType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) receiverType).genericType(), inferredTypes, ((ParameterizedTypeBinding) receiverType).enclosingType());
404
			}
409
			}
405
			ReferenceBinding allocationType = (ReferenceBinding) receiverType;
410
			ReferenceBinding allocationType = (ReferenceBinding) receiverType;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-1 / +7 lines)
Lines 4036-4042 Link Here
4036
		int sfi = 0;
4036
		int sfi = 0;
4037
		for (int i = 0, length = methods.length; i < length; i++) {
4037
		for (int i = 0, length = methods.length; i < length; i++) {
4038
			MethodBinding method = methods[i];
4038
			MethodBinding method = methods[i];
4039
			
4039
			int paramLength = method.parameters.length;
4040
			boolean isVarArgs = method.isVarargs();
4041
			if (argumentTypes.length != paramLength)
4042
				if (!isVarArgs || argumentTypes.length < paramLength - 1)
4043
					continue; // this method has number of arguments different from that used in the allocation
4040
			TypeVariableBinding[] methodTypeVariables = method.typeVariables();
4044
			TypeVariableBinding[] methodTypeVariables = method.typeVariables();
4041
			int methodTypeVariablesArity = methodTypeVariables.length;
4045
			int methodTypeVariablesArity = methodTypeVariables.length;
4042
	        
4046
	        
Lines 4114-4119 Link Here
4114
			staticFactories[sfi++] = new ParameterizedMethodBinding((ParameterizedTypeBinding) environment.convertToParameterizedType(staticFactory.declaringClass),
4118
			staticFactories[sfi++] = new ParameterizedMethodBinding((ParameterizedTypeBinding) environment.convertToParameterizedType(staticFactory.declaringClass),
4115
																												staticFactory);
4119
																												staticFactory);
4116
		}
4120
		}
4121
		if (sfi == 0)
4122
			return null; // no possible static factory methods found. So bail out.
4117
		if (sfi != methods.length) {
4123
		if (sfi != methods.length) {
4118
			System.arraycopy(staticFactories, 0, staticFactories = new MethodBinding[sfi], 0, sfi);
4124
			System.arraycopy(staticFactories, 0, staticFactories = new MethodBinding[sfi], 0, sfi);
4119
		}
4125
		}

Return to bug 345559