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 339478 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java (-1 / +7 lines)
Lines 207-218 Link Here
207
				}
207
				}
208
			} else {
208
			} else {
209
			    this.initialization.setExpectedType(variableType);
209
			    this.initialization.setExpectedType(variableType);
210
			    boolean isCompliant17 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7;
211
			    boolean isDiamond = false;
210
				TypeBinding initializationType = this.initialization.resolveType(scope);
212
				TypeBinding initializationType = this.initialization.resolveType(scope);
213
				if (this.initialization instanceof AllocationExpression) {
214
					if (isCompliant17 && (((AllocationExpression) this.initialization).type.bits & ASTNode.IsDiamond) != 0)
215
						isDiamond = true;
216
				}
211
				if (initializationType != null) {
217
				if (initializationType != null) {
212
					if (variableType != initializationType) // must call before computeConversion() and typeMismatchError()
218
					if (variableType != initializationType) // must call before computeConversion() and typeMismatchError()
213
						scope.compilationUnitScope().recordTypeConversion(variableType, initializationType);
219
						scope.compilationUnitScope().recordTypeConversion(variableType, initializationType);
214
					if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, variableType)
220
					if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, variableType)
215
						|| initializationType.isCompatibleWith(variableType)) {
221
						|| initializationType.isCompatibleWith(variableType, isDiamond)) {
216
						this.initialization.computeConversion(scope, variableType, initializationType);
222
						this.initialization.computeConversion(scope, variableType, initializationType);
217
						if (initializationType.needsUncheckedConversion(variableType)) {
223
						if (initializationType.needsUncheckedConversion(variableType)) {
218
						    scope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, variableType);
224
						    scope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, variableType);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java (-2 / +13 lines)
Lines 90-95 Link Here
90
     * No need to check for reference to raw type per construction
90
     * No need to check for reference to raw type per construction
91
     */
91
     */
92
	private TypeBinding internalResolveType(Scope scope, ReferenceBinding enclosingType, boolean checkBounds) {
92
	private TypeBinding internalResolveType(Scope scope, ReferenceBinding enclosingType, boolean checkBounds) {
93
		boolean isCompliant17 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7;
93
		// handle the error here
94
		// handle the error here
94
		this.constant = Constant.NotAConstant;
95
		this.constant = Constant.NotAConstant;
95
		if ((this.bits & ASTNode.DidResolve) != 0) { // is a shared type reference which was already resolved
96
		if ((this.bits & ASTNode.DidResolve) != 0) { // is a shared type reference which was already resolved
Lines 222-229 Link Here
222
			}
223
			}
223
			// if missing generic type, and compliance >= 1.5, then will rebuild a parameterized binding
224
			// if missing generic type, and compliance >= 1.5, then will rebuild a parameterized binding
224
		} else if (argLength != typeVariables.length) { // check arity
225
		} else if (argLength != typeVariables.length) { // check arity
225
			scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes);
226
			if(isCompliant17 && argLength == 0) {
226
			return null;
227
				if ((this.bits & ASTNode.IsDiamond) ==0) {
228
					scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes);
229
					return null;
230
				}
231
				// argLength = 0 ok if its the diamond case for compliance >= 1.7
232
				// also no need to check bounds for such a case
233
				checkBounds = false;
234
			} else {
235
				scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes);
236
				return null;
237
			}
227
		} else if (!currentType.isStatic()) {
238
		} else if (!currentType.isStatic()) {
228
			ReferenceBinding actualEnclosing = currentType.enclosingType();
239
			ReferenceBinding actualEnclosing = currentType.enclosingType();
229
			if (actualEnclosing != null && actualEnclosing.isRawType()){
240
			if (actualEnclosing != null && actualEnclosing.isRawType()){
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java (-1 / +12 lines)
Lines 999-1005 Link Here
999
public boolean isClass() {
999
public boolean isClass() {
1000
	return (this.modifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | ClassFileConstants.AccEnum)) == 0;
1000
	return (this.modifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | ClassFileConstants.AccEnum)) == 0;
1001
}
1001
}
1002
1002
/**
1003
 * Answer true if the receiver type can be assigned to the argument type (right)
1004
 * In addition to improving performance, caching also ensures there is no infinite regression
1005
 * since per nature, the compatibility check is recursive through parameterized type arguments (122775)
1006
 */
1007
public boolean isCompatibleWith(TypeBinding otherType, boolean isDiamondCase) {
1008
	if (isDiamondCase) {
1009
		if (this.erasure() == otherType.erasure())
1010
			return true;
1011
	}
1012
	return isCompatibleWith(otherType);
1013
}
1003
/**
1014
/**
1004
 * Answer true if the receiver type can be assigned to the argument type (right)
1015
 * Answer true if the receiver type can be assigned to the argument type (right)
1005
 * In addition to improving performance, caching also ensures there is no infinite regression
1016
 * In addition to improving performance, caching also ensures there is no infinite regression
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1183-1186 Link Here
1183
public TypeVariableBinding[] typeVariables() {
1183
public TypeVariableBinding[] typeVariables() {
1184
	return Binding.NO_TYPE_VARIABLES;
1184
	return Binding.NO_TYPE_VARIABLES;
1185
}
1185
}
1186
1187
public boolean isCompatibleWith(TypeBinding variableType, boolean isDiamond){
1188
	return isCompatibleWith(variableType);
1189
}
1186
}
1190
}

Return to bug 339478