View | Details | Raw Unified | Return to bug 342671 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java (-8 / +9 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 128-133 Link Here
128
			}
128
			}
129
		}
129
		}
130
		this.bits |= ASTNode.DidResolve;
130
		this.bits |= ASTNode.DidResolve;
131
		TypeBinding type = internalResolveLeafType(scope, checkBounds);
132
		createArrayType(scope);
133
		return type == null ? type : this.resolvedType;
134
	}
135
	private TypeBinding internalResolveLeafType(Scope scope, boolean checkBounds) {
131
		boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
136
		boolean isClassScope = scope.kind == Scope.CLASS_SCOPE;
132
		Binding binding = scope.getPackage(this.tokens);
137
		Binding binding = scope.getPackage(this.tokens);
133
		if (binding != null && !binding.isValidBinding()) {
138
		if (binding != null && !binding.isValidBinding()) {
Lines 236-246 Link Here
236
					this.resolvedType =  (qualifyingType != null && qualifyingType.isParameterizedType())
241
					this.resolvedType =  (qualifyingType != null && qualifyingType.isParameterizedType())
237
						? scope.environment().createParameterizedType(currentOriginal, null, qualifyingType)
242
						? scope.environment().createParameterizedType(currentOriginal, null, qualifyingType)
238
						: currentType;
243
						: currentType;
239
					if (this.dimensions > 0) {
240
						if (this.dimensions > 255)
241
							scope.problemReporter().tooManyDimensions(this);
242
						this.resolvedType = scope.createArrayType(this.resolvedType, this.dimensions);
243
					}
244
					return this.resolvedType;
244
					return this.resolvedType;
245
				} else if (argLength != typeVariables.length) { // check arity
245
				} else if (argLength != typeVariables.length) { // check arity
246
					scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes, i);
246
					scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes, i);
Lines 283-295 Link Here
283
				reportDeprecatedType(qualifyingType, scope, i);
283
				reportDeprecatedType(qualifyingType, scope, i);
284
			this.resolvedType = qualifyingType;
284
			this.resolvedType = qualifyingType;
285
		}
285
		}
286
		// array type ?
286
		return this.resolvedType;
287
	}
288
	public void createArrayType(Scope scope) {
287
		if (this.dimensions > 0) {
289
		if (this.dimensions > 0) {
288
			if (this.dimensions > 255)
290
			if (this.dimensions > 255)
289
				scope.problemReporter().tooManyDimensions(this);
291
				scope.problemReporter().tooManyDimensions(this);
290
			this.resolvedType = scope.createArrayType(this.resolvedType, this.dimensions);
292
			this.resolvedType = scope.createArrayType(this.resolvedType, this.dimensions);
291
		}
293
		}
292
		return this.resolvedType;
293
	}
294
	}
294
295
295
	public StringBuffer printExpression(int indent, StringBuffer output) {
296
	public StringBuffer printExpression(int indent, StringBuffer output) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java (-22 / +28 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 105-119 Link Here
105
				}
105
				}
106
			}
106
			}
107
		}
107
		}
108
		boolean hasGenericError = false;
109
		ReferenceBinding currentType;
110
		this.bits |= ASTNode.DidResolve;
108
		this.bits |= ASTNode.DidResolve;
109
		TypeBinding type = internalResolveLeafType(scope, enclosingType, checkBounds);
110
		// handle three different outcomes:
111
		if (type == null) {		 
112
			this.resolvedType = createArrayType(scope, this.resolvedType);
113
			return null;							// no useful type, but still captured dimensions into this.resolvedType
114
		} else {
115
			type = createArrayType(scope, type);
116
			if (!this.resolvedType.isValidBinding())
117
				return type;						// found some error, but could recover useful type (like closestMatch)	
118
			else 
119
				return this.resolvedType = type; 	// no complaint, keep fully resolved type (incl. dimensions)
120
		}
121
	}
122
	private TypeBinding internalResolveLeafType(Scope scope, ReferenceBinding enclosingType, boolean checkBounds) {
123
		ReferenceBinding currentType;
111
		if (enclosingType == null) {
124
		if (enclosingType == null) {
112
			this.resolvedType = scope.getType(this.token);
125
			this.resolvedType = scope.getType(this.token);
113
			if (this.resolvedType.isValidBinding()) {
126
			if (this.resolvedType.isValidBinding()) {
114
				currentType = (ReferenceBinding) this.resolvedType;
127
				currentType = (ReferenceBinding) this.resolvedType;
115
			} else {
128
			} else {
116
				hasGenericError = true;
129
				
117
				reportInvalidType(scope);
130
				reportInvalidType(scope);
118
				switch (this.resolvedType.problemId()) {
131
				switch (this.resolvedType.problemId()) {
119
					case ProblemReasons.NotFound :
132
					case ProblemReasons.NotFound :
Lines 150-156 Link Here
150
		} else { // resolving member type (relatively to enclosingType)
163
		} else { // resolving member type (relatively to enclosingType)
151
			this.resolvedType = currentType = scope.getMemberType(this.token, enclosingType);
164
			this.resolvedType = currentType = scope.getMemberType(this.token, enclosingType);
152
			if (!this.resolvedType.isValidBinding()) {
165
			if (!this.resolvedType.isValidBinding()) {
153
				hasGenericError = true;
154
				scope.problemReporter().invalidEnclosingType(this, currentType, enclosingType);
166
				scope.problemReporter().invalidEnclosingType(this, currentType, enclosingType);
155
				return null;
167
				return null;
156
			}
168
			}
Lines 205-220 Link Here
205
			}
217
			}
206
			// resilience do not rebuild a parameterized type unless compliance is allowing it
218
			// resilience do not rebuild a parameterized type unless compliance is allowing it
207
			if (!isCompliant15) {
219
			if (!isCompliant15) {
208
				// array type ?
220
				if (!this.resolvedType.isValidBinding())
209
				TypeBinding type = currentType;
221
					return currentType;
210
				if (this.dimensions > 0) {
222
				return this.resolvedType = currentType;
211
					if (this.dimensions > 255)
212
						scope.problemReporter().tooManyDimensions(this);
213
					type = scope.createArrayType(type, this.dimensions);
214
				}
215
				if (hasGenericError)
216
					return type;
217
				return this.resolvedType = type;
218
			}
223
			}
219
			// 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
220
		} else if (argLength != typeVariables.length) { // check arity
225
		} else if (argLength != typeVariables.length) { // check arity
Lines 238-254 Link Here
238
		if (isTypeUseDeprecated(parameterizedType, scope))
243
		if (isTypeUseDeprecated(parameterizedType, scope))
239
			reportDeprecatedType(parameterizedType, scope);
244
			reportDeprecatedType(parameterizedType, scope);
240
245
241
		TypeBinding type = parameterizedType;
246
		if (!this.resolvedType.isValidBinding()) {
242
		// array type ?
247
			return parameterizedType;
248
		}
249
		return this.resolvedType = parameterizedType;
250
	}
251
	public TypeBinding createArrayType(Scope scope, TypeBinding type) {
243
		if (this.dimensions > 0) {
252
		if (this.dimensions > 0) {
244
			if (this.dimensions > 255)
253
			if (this.dimensions > 255)
245
				scope.problemReporter().tooManyDimensions(this);
254
				scope.problemReporter().tooManyDimensions(this);
246
			type = scope.createArrayType(type, this.dimensions);
255
			return scope.createArrayType(type, this.dimensions);
247
		}
248
		if (hasGenericError) {
249
			return type;
250
		}
256
		}
251
		return this.resolvedType = type;
257
		return type;
252
	}
258
	}
253
259
254
	public StringBuffer printExpression(int indent, StringBuffer output){
260
	public StringBuffer printExpression(int indent, StringBuffer output){
(-)dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java (-10 / +4 lines)
Lines 1523-1533 Link Here
1523
						return null;
1523
						return null;
1524
					}
1524
					}
1525
					ArrayType arrayType = (ArrayType) type;
1525
					ArrayType arrayType = (ArrayType) type;
1526
					if (typeBinding.isArrayType()) {
1526
					ArrayBinding arrayBinding = (ArrayBinding) typeBinding;
1527
						ArrayBinding arrayBinding = (ArrayBinding) typeBinding;
1527
					return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, arrayType.getDimensions()));
1528
						return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, arrayType.getDimensions()));
1529
					}
1530
					return getTypeBinding(this.scope.createArrayType(typeBinding, arrayType.getDimensions()));
1531
				}
1528
				}
1532
				if (typeBinding.isArrayType()) {
1529
				if (typeBinding.isArrayType()) {
1533
					typeBinding = ((ArrayBinding) typeBinding).leafComponentType;
1530
					typeBinding = ((ArrayBinding) typeBinding).leafComponentType;
Lines 1567-1577 Link Here
1567
					if (this.scope == null) {
1564
					if (this.scope == null) {
1568
						return null;
1565
						return null;
1569
					}
1566
					}
1570
					if (binding.isArrayType()) {
1567
					ArrayBinding arrayBinding = (ArrayBinding) binding;
1571
						ArrayBinding arrayBinding = (ArrayBinding) binding;
1568
					return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, arrayType.getDimensions()));
1572
						return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, arrayType.getDimensions()));
1573
					}
1574
					return getTypeBinding(this.scope.createArrayType(binding, arrayType.getDimensions()));
1575
				} else if (binding.isArrayType()) {
1569
				} else if (binding.isArrayType()) {
1576
					ArrayBinding arrayBinding = (ArrayBinding) binding;
1570
					ArrayBinding arrayBinding = (ArrayBinding) binding;
1577
					return getTypeBinding(arrayBinding.leafComponentType);
1571
					return getTypeBinding(arrayBinding.leafComponentType);
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +12 lines)
Lines 49-55 Link Here
49
	static {
49
	static {
50
//		TESTS_NUMBERS = new int[] { 351, 352 };
50
//		TESTS_NUMBERS = new int[] { 351, 352 };
51
//		TESTS_RANGE = new int[] { 325, -1 };
51
//		TESTS_RANGE = new int[] { 325, -1 };
52
//		TESTS_NAMES = new String[] {"test0204"};
52
//		TESTS_NAMES = new String[] {"test035"};
53
	}
53
	}
54
	public static Test suite() {
54
	public static Test suite() {
55
		return buildModelTestSuite(ASTConverter15Test.class);
55
		return buildModelTestSuite(ASTConverter15Test.class);
Lines 11295-11300 Link Here
11295
		assertEquals("Wrong fully qualified name", "test0351.I1[]", typeBinding.getQualifiedName());
11295
		assertEquals("Wrong fully qualified name", "test0351.I1[]", typeBinding.getQualifiedName());
11296
	}
11296
	}
11297
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=342671
11297
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=342671
11298
	public void test0351a() throws JavaModelException {
11299
		ICompilationUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0351", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
11300
		ASTNode result = runJLS3Conversion(sourceUnit, true, true);
11301
		assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT);
11302
		CompilationUnit unit = (CompilationUnit) result;
11303
		MethodDeclaration methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 0);
11304
		Type componentType = ((ArrayType)methodDeclaration.getReturnType2()).getComponentType();
11305
		ITypeBinding typeBinding = componentType.resolveBinding();
11306
		assertEquals("Wrong fully qualified name", "test0351.I1", typeBinding.getQualifiedName());
11307
	}
11308
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=342671
11298
	public void test0352() throws JavaModelException {
11309
	public void test0352() throws JavaModelException {
11299
		ICompilationUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0352", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
11310
		ICompilationUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0352", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
11300
		ASTNode result = runJLS3Conversion(sourceUnit, true, true);
11311
		ASTNode result = runJLS3Conversion(sourceUnit, true, true);

Return to bug 342671