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 / +19 lines)
Lines 373-384 Link Here
373
		scope.problemReporter().cannotInstantiate(this.type, this.resolvedType);
373
		scope.problemReporter().cannotInstantiate(this.type, this.resolvedType);
374
		return this.resolvedType;
374
		return this.resolvedType;
375
	}
375
	}
376
	if (isDiamond) {
376
	
377
		TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope);
377
//	if (isDiamond) {
378
		this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType());
378
//		TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope);
379
 	}
379
//		this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType());
380
////		allocationType = (ReferenceBinding) this.resolvedType;
381
// 	}
382
	
380
	ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
383
	ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
381
	if (!(this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) {
384
	if (isDiamond) {
385
		this.binding = scope.getConstructor(((ParameterizedTypeBinding)allocationType).genericType(), argumentTypes, this);
386
	} else {
387
		this.binding = scope.getConstructor(allocationType, argumentTypes, this);
388
	}
389
	if (!this.binding.isValidBinding()) {
382
		if (this.binding.declaringClass == null) {
390
		if (this.binding.declaringClass == null) {
383
			this.binding.declaringClass = allocationType;
391
			this.binding.declaringClass = allocationType;
384
		}
392
		}
Lines 387-393 Link Here
387
		}
395
		}
388
		scope.problemReporter().invalidConstructor(this, this.binding);
396
		scope.problemReporter().invalidConstructor(this, this.binding);
389
		return this.resolvedType;
397
		return this.resolvedType;
390
	}
398
	} else if (isDiamond) {
399
		TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope);
400
		this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType());
401
		allocationType = (ReferenceBinding) this.resolvedType;
402
 	}
391
	if ((this.binding.tagBits & TagBits.HasMissingType) != 0) {
403
	if ((this.binding.tagBits & TagBits.HasMissingType) != 0) {
392
		scope.problemReporter().missingTypeInConstructor(this, this.binding);
404
		scope.problemReporter().missingTypeInConstructor(this, this.binding);
393
	}
405
	}
Lines 399-405 Link Here
399
	if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) {
411
	if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) {
400
		scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments);
412
		scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments);
401
	}
413
	}
402
	return allocationType;
414
	return this.resolvedType;
403
}
415
}
404
416
405
public TypeBinding[] inferElidedTypes(ReferenceBinding allocationType, TypeBinding[] argumentTypes, final BlockScope scope) {
417
public TypeBinding[] inferElidedTypes(ReferenceBinding allocationType, TypeBinding[] argumentTypes, final BlockScope scope) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-6 / +17 lines)
Lines 302-307 Link Here
302
		}
302
		}
303
303
304
		// resolve type arguments (for generic constructor call)
304
		// resolve type arguments (for generic constructor call)
305
		boolean isDiamond = this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0;
305
		if (this.typeArguments != null) {
306
		if (this.typeArguments != null) {
306
			int length = this.typeArguments.length;
307
			int length = this.typeArguments.length;
307
			boolean argHasError = scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5;
308
			boolean argHasError = scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5;
Lines 315-321 Link Here
315
					scope.problemReporter().illegalUsageOfWildcard(typeReference);
316
					scope.problemReporter().illegalUsageOfWildcard(typeReference);
316
				}
317
				}
317
			}
318
			}
318
			if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) {
319
			if (isDiamond) {
319
				scope.problemReporter().diamondNotWithExplicitTypeArguments(this.typeArguments);
320
				scope.problemReporter().diamondNotWithExplicitTypeArguments(this.typeArguments);
320
				return null;
321
				return null;
321
			}
322
			}
Lines 390-401 Link Here
390
				scope.problemReporter().cannotInstantiate(this.type, receiverType);
391
				scope.problemReporter().cannotInstantiate(this.type, receiverType);
391
				return this.resolvedType = receiverType;
392
				return this.resolvedType = receiverType;
392
			}
393
			}
393
			if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) {
394
//			if (isDiamond) {
394
				TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) receiverType).genericType(), argumentTypes, scope);
395
//				TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) receiverType).genericType(), argumentTypes, scope);
395
				receiverType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) receiverType).genericType(), inferredTypes, ((ParameterizedTypeBinding) receiverType).enclosingType());
396
//				receiverType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) receiverType).genericType(), inferredTypes, ((ParameterizedTypeBinding) receiverType).enclosingType());
396
			}
397
//			}
397
			ReferenceBinding allocationType = (ReferenceBinding) receiverType;
398
			ReferenceBinding allocationType = (ReferenceBinding) receiverType;
399
			if (isDiamond) {
400
				this.binding = scope.getConstructor(((ParameterizedTypeBinding)allocationType).genericType(), argumentTypes, this);
401
			} else {
402
				this.binding = scope.getConstructor(allocationType, argumentTypes, this);
403
			}
398
			if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) {
404
			if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) {
405
				if (isDiamond) {
406
					TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) receiverType).genericType(), argumentTypes, scope);
407
					receiverType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) receiverType).genericType(), inferredTypes, ((ParameterizedTypeBinding) receiverType).enclosingType());
408
					allocationType = (ReferenceBinding) receiverType;
409
				}
399
				if (isMethodUseDeprecated(this.binding, scope, true)) {
410
				if (isMethodUseDeprecated(this.binding, scope, true)) {
400
					scope.problemReporter().deprecatedMethod(this.binding, this);
411
					scope.problemReporter().deprecatedMethod(this.binding, this);
401
				}
412
				}
Lines 430-436 Link Here
430
			scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance, null);
441
			scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance, null);
431
			return this.resolvedType = receiverType;
442
			return this.resolvedType = receiverType;
432
		} else {
443
		} else {
433
			if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) {
444
			if (isDiamond) {
434
				scope.problemReporter().diamondNotWithAnoymousClasses(this.type);
445
				scope.problemReporter().diamondNotWithAnoymousClasses(this.type);
435
				return null;
446
				return null;
436
			}	
447
			}	

Return to bug 345559