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

Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/BindingResolver.java (-1 / +2 lines)
Lines 219-227 Link Here
219
	 * </p>
219
	 * </p>
220
	 *
220
	 *
221
	 * @param recoveredTypeBinding the recovered type binding
221
	 * @param recoveredTypeBinding the recovered type binding
222
	 * @param dimensions the dimensions to add the to given type binding dimensions
222
	 * @return the new type binding
223
	 * @return the new type binding
223
	 */
224
	 */
224
	ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding) {
225
	ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding, int dimensions) {
225
		return null;
226
		return null;
226
	}
227
	}
227
228
(-)dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java (-12 / +53 lines)
Lines 55-63 Link Here
55
		}
55
		}
56
	}
56
	}
57
57
58
	RecoveredTypeBinding(BindingResolver resolver, RecoveredTypeBinding typeBinding) {
58
	RecoveredTypeBinding(BindingResolver resolver, RecoveredTypeBinding typeBinding, int dimensions) {
59
		this.innerTypeBinding = typeBinding;
59
		this.innerTypeBinding = typeBinding;
60
		this.dimensions = typeBinding.getDimensions() - 1;
60
		this.dimensions = typeBinding.getDimensions() + dimensions;
61
		this.resolver = resolver;
61
		this.resolver = resolver;
62
	}
62
	}
63
63
Lines 65-71 Link Here
65
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#createArrayType(int)
65
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#createArrayType(int)
66
	 */
66
	 */
67
	public ITypeBinding createArrayType(int dimension) {
67
	public ITypeBinding createArrayType(int dimension) {
68
		throw new IllegalArgumentException("Cannot be called on a recovered type binding"); //$NON-NLS-1$
68
		return this.resolver.getTypeBinding(this, dimensions);
69
	}
69
	}
70
70
71
	/* (non-Javadoc)
71
	/* (non-Javadoc)
Lines 87-93 Link Here
87
	 */
87
	 */
88
	public ITypeBinding getComponentType() {
88
	public ITypeBinding getComponentType() {
89
		if (this.dimensions == 0) return null;
89
		if (this.dimensions == 0) return null;
90
		return this.resolver.getTypeBinding(this);
90
		return this.resolver.getTypeBinding(this, -1);
91
	}
91
	}
92
92
93
	/* (non-Javadoc)
93
	/* (non-Javadoc)
Lines 230-236 Link Here
230
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass()
230
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass()
231
	 */
231
	 */
232
	public ITypeBinding getSuperclass() {
232
	public ITypeBinding getSuperclass() {
233
		return null;
233
		return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
234
	}
234
	}
235
235
236
	/* (non-Javadoc)
236
	/* (non-Javadoc)
Lines 240-246 Link Here
240
		if (this.referenceBinding != null) {
240
		if (this.referenceBinding != null) {
241
			return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS;
241
			return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS;
242
		}
242
		}
243
		if (this.typeArguments != null) return typeArguments;
243
		if (this.typeArguments != null) {
244
			return typeArguments;
245
		}
244
246
245
		if (this.innerTypeBinding != null) {
247
		if (this.innerTypeBinding != null) {
246
			return this.innerTypeBinding.getTypeArguments();
248
			return this.innerTypeBinding.getTypeArguments();
Lines 315-322 Link Here
315
	/* (non-Javadoc)
317
	/* (non-Javadoc)
316
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#isAssignmentCompatible(org.eclipse.jdt.core.dom.ITypeBinding)
318
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#isAssignmentCompatible(org.eclipse.jdt.core.dom.ITypeBinding)
317
	 */
319
	 */
318
	public boolean isAssignmentCompatible(ITypeBinding variableType) {
320
	public boolean isAssignmentCompatible(ITypeBinding typeBinding) {
319
		return false;
321
		if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$
322
			return true;
323
		}
324
		return this.isEqualTo(typeBinding);
320
	}
325
	}
321
326
322
	/* (non-Javadoc)
327
	/* (non-Javadoc)
Lines 330-336 Link Here
330
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#isCastCompatible(org.eclipse.jdt.core.dom.ITypeBinding)
335
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#isCastCompatible(org.eclipse.jdt.core.dom.ITypeBinding)
331
	 */
336
	 */
332
	public boolean isCastCompatible(ITypeBinding typeBinding) {
337
	public boolean isCastCompatible(ITypeBinding typeBinding) {
333
		return false;
338
		if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$
339
			return true;
340
		}
341
		return this.isEqualTo(typeBinding);
334
	}
342
	}
335
343
336
	/* (non-Javadoc)
344
	/* (non-Javadoc)
Lines 427-433 Link Here
427
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#isSubTypeCompatible(org.eclipse.jdt.core.dom.ITypeBinding)
435
	 * @see org.eclipse.jdt.core.dom.ITypeBinding#isSubTypeCompatible(org.eclipse.jdt.core.dom.ITypeBinding)
428
	 */
436
	 */
429
	public boolean isSubTypeCompatible(ITypeBinding typeBinding) {
437
	public boolean isSubTypeCompatible(ITypeBinding typeBinding) {
430
		return false;
438
		if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$
439
			return true;
440
		}
441
		return this.isEqualTo(typeBinding);
431
	}
442
	}
432
443
433
	/* (non-Javadoc)
444
	/* (non-Javadoc)
Lines 476-482 Link Here
476
	 * @see org.eclipse.jdt.core.dom.IBinding#getKey()
487
	 * @see org.eclipse.jdt.core.dom.IBinding#getKey()
477
	 */
488
	 */
478
	public String getKey() {
489
	public String getKey() {
479
		return null;
490
		StringBuffer buffer = new StringBuffer();
491
		buffer.append("Recovered#"); //$NON-NLS-1$
492
		if (this.innerTypeBinding != null) {
493
			buffer.append("innerTypeBinding") //$NON-NLS-1$
494
			      .append(this.innerTypeBinding.getKey());
495
		} else if (this.currentType != null) {
496
			buffer.append("currentType") //$NON-NLS-1$
497
			      .append(this.currentType.toString());
498
		} else if (this.referenceBinding != null) {
499
			buffer.append("referenceBinding") //$NON-NLS-1$
500
				  .append(this.referenceBinding.computeUniqueKey());
501
		} else if (variableDeclaration != null) {
502
			buffer
503
				.append("variableDeclaration") //$NON-NLS-1$
504
				.append(this.variableDeclaration.getClass())
505
				.append(this.variableDeclaration.getName().getIdentifier())
506
				.append(this.variableDeclaration.getExtraDimensions());
507
		}
508
		buffer.append(this.getDimensions());
509
		if (this.typeArguments != null) {
510
			buffer.append('<');
511
			for (int i = 0, max = this.typeArguments.length; i < max; i++) {
512
				if (i != 0) {
513
					buffer.append(',');
514
				}
515
				buffer.append(this.typeArguments[i].getKey());
516
			}
517
			buffer.append('>');
518
		}
519
		return String.valueOf(buffer);
480
	}
520
	}
481
521
482
	/* (non-Javadoc)
522
	/* (non-Javadoc)
Lines 497-503 Link Here
497
	 * @see org.eclipse.jdt.core.dom.IBinding#isEqualTo(org.eclipse.jdt.core.dom.IBinding)
537
	 * @see org.eclipse.jdt.core.dom.IBinding#isEqualTo(org.eclipse.jdt.core.dom.IBinding)
498
	 */
538
	 */
499
	public boolean isEqualTo(IBinding other) {
539
	public boolean isEqualTo(IBinding other) {
500
		return false;
540
		if (!other.isRecovered()) return false;
541
		return this.getKey().equals(other.getKey());
501
	}
542
	}
502
543
503
	/* (non-Javadoc)
544
	/* (non-Javadoc)
(-)dom/org/eclipse/jdt/core/dom/ITypeBinding.java (-14 / +15 lines)
Lines 54-66 Link Here
54
	 * <p>If the receiver is an array binding, then the resulting dimension is the given dimension
54
	 * <p>If the receiver is an array binding, then the resulting dimension is the given dimension
55
	 * plus the dimension of the receiver. Otherwise the resulting dimension is the given
55
	 * plus the dimension of the receiver. Otherwise the resulting dimension is the given
56
	 * dimension.</p>
56
	 * dimension.</p>
57
	 * <p>It cannot be called on a recovered binding.</p>
58
	 *
57
	 *
59
	 * @param dimension the given dimension
58
	 * @param dimension the given dimension
60
	 * @return an array type binding
59
	 * @return an array type binding
61
	 * @throws IllegalArgumentException:<ul>
60
	 * @throws IllegalArgumentException:<ul>
62
	 * <li>if the receiver represents the void type</li>
61
	 * <li>if the receiver represents the void type</li>
63
	 * <li>if the receiver represents a recovered binding</li>
64
	 * <li>if the resulting dimensions is lower than one or greater than 255</li>
62
	 * <li>if the resulting dimensions is lower than one or greater than 255</li>
65
	 * </ul>
63
	 * </ul>
66
	 * @since 3.3
64
	 * @since 3.3
Lines 306-317 Link Here
306
	 * original source, since the compiler may change them (in particular,
304
	 * original source, since the compiler may change them (in particular,
307
	 * for inner class emulation). The <code>getDeclaredModifiers</code> method
305
	 * for inner class emulation). The <code>getDeclaredModifiers</code> method
308
	 * should be used if the original modifiers are needed.
306
	 * should be used if the original modifiers are needed.
309
	 * Returns 0 if this type does not represent a class, interface, enum, or annotation
307
	 * Returns 0 if this type does not represent a class, an interface, an enum, an annotation
310
	 * type.
308
	 * type or a recovered type.
311
	 *
309
	 *
312
	 * @return the compiled modifiers for this type binding or 0
310
	 * @return the compiled modifiers for this type binding or 0
313
	 * if this type does not represent a class, interface, enum, or annotation
311
	 * if this type does not represent a class, an interface, an enum, an annotation
314
	 * type
312
	 * type or a recovered type.
315
	 * @see #getDeclaredModifiers()
313
	 * @see #getDeclaredModifiers()
316
	 */
314
	 */
317
	public int getModifiers();
315
	public int getModifiers();
Lines 369-375 Link Here
369
	 * @return the binding for the package in which this class, interface,
367
	 * @return the binding for the package in which this class, interface,
370
	 * enum, or annotation type is declared, or <code>null</code> if this type
368
	 * enum, or annotation type is declared, or <code>null</code> if this type
371
	 * binding represents a primitive type, an array type, the null type,
369
	 * binding represents a primitive type, an array type, the null type,
372
	 * a type variable, a wildcard type, a capture binding, or a recovered binding.
370
	 * a type variable, a wildcard type, a capture binding or a recovered type binding.
373
	 */
371
	 */
374
	public IPackageBinding getPackage();
372
	public IPackageBinding getPackage();
375
373
Lines 454-461 Link Here
454
	 * <p>
452
	 * <p>
455
	 * If this type binding represents an interface, an array type, a
453
	 * If this type binding represents an interface, an array type, a
456
	 * primitive type, the null type, a type variable, an enum type,
454
	 * primitive type, the null type, a type variable, an enum type,
457
	 * an annotation type, a wildcard type, a capture binding, or a
455
	 * an annotation type, a wildcard type, or a capture binding then
458
	 * recovered binding then <code>null</code> is returned.
456
	 * <code>null</code> is returned.
459
	 * </p>
457
	 * </p>
460
	 *
458
	 *
461
	 * @return the superclass of the class represented by this type binding,
459
	 * @return the superclass of the class represented by this type binding,
Lines 593-599 Link Here
593
	 * of the given type, as specified in section 5.2 of <em>The Java Language
591
	 * of the given type, as specified in section 5.2 of <em>The Java Language
594
	 * Specification, Third Edition</em> (JLS3).
592
	 * Specification, Third Edition</em> (JLS3).
595
	 *
593
	 *
596
	 * <p>If the receiver or the argument is a recovered type, the answer is always false.</p>
594
	 * <p>If the receiver or the argument is a recovered type, the answer is always false,
595
	 * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p>
597
	 *
596
	 *
598
	 * @param variableType the type of a variable to check compatibility against
597
	 * @param variableType the type of a variable to check compatibility against
599
	 * @return <code>true</code> if an expression of this type can be assigned to a
598
	 * @return <code>true</code> if an expression of this type can be assigned to a
Lines 641-647 Link Here
641
	 * <code>A.isCastCompatible(B)</code>
640
	 * <code>A.isCastCompatible(B)</code>
642
	 * </p>
641
	 * </p>
643
	 *
642
	 *
644
	 * <p>If the receiver or the argument is a recovered type, the answer is always false.</p>
643
	 * <p>If the receiver or the argument is a recovered type, the answer is always false,
644
	 * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p>
645
	 *
645
	 *
646
	 * @param type the type to check compatibility against
646
	 * @param type the type to check compatibility against
647
	 * @return <code>true</code> if this type is cast compatible with the
647
	 * @return <code>true</code> if this type is cast compatible with the
Lines 651-659 Link Here
651
	public boolean isCastCompatible(ITypeBinding type);
651
	public boolean isCastCompatible(ITypeBinding type);
652
652
653
	/**
653
	/**
654
	 * Returns whether this type binding represents a class type.
654
	 * Returns whether this type binding represents a class type or a recovered binding.
655
	 *
655
	 *
656
	 * @return <code>true</code> if this object represents a class,
656
	 * @return <code>true</code> if this object represents a class or a recovered binding,
657
	 *    and <code>false</code> otherwise
657
	 *    and <code>false</code> otherwise
658
	 */
658
	 */
659
	public boolean isClass();
659
	public boolean isClass();
Lines 844-850 Link Here
844
	 * as specified in section 4.10 of <em>The Java Language
844
	 * as specified in section 4.10 of <em>The Java Language
845
	 * Specification, Third Edition</em> (JLS3).
845
	 * Specification, Third Edition</em> (JLS3).
846
	 *
846
	 *
847
	 * <p>If the receiver or the argument is a recovered type, the answer is always false.</p>
847
	 * <p>If the receiver or the argument is a recovered type, the answer is always false,
848
	 * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p>
848
	 *
849
	 *
849
	 * @param type the type to check compatibility against
850
	 * @param type the type to check compatibility against
850
	 * @return <code>true</code> if this type is subtype compatible with the
851
	 * @return <code>true</code> if this type is subtype compatible with the
(-)dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java (-10 / +3 lines)
Lines 358-374 Link Here
358
	/*
358
	/*
359
	 * Method declared on BindingResolver.
359
	 * Method declared on BindingResolver.
360
	 */
360
	 */
361
	synchronized ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding) {
361
	synchronized ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding, int dimensions) {
362
		if (recoveredTypeBinding== null) {
362
		if (recoveredTypeBinding== null) {
363
			return null;
363
			return null;
364
		}
364
		}
365
		ITypeBinding binding = (ITypeBinding) this.bindingTables.compilerBindingsToASTBindings.get(recoveredTypeBinding);
365
		return new RecoveredTypeBinding(this, recoveredTypeBinding, dimensions);
366
		if (binding != null) {
367
			return binding;
368
		}
369
		binding = new RecoveredTypeBinding(this, recoveredTypeBinding);
370
		this.bindingTables.compilerBindingsToASTBindings.put(recoveredTypeBinding, binding);
371
		return binding;
372
	}
366
	}
373
367
374
	synchronized IVariableBinding getVariableBinding(org.eclipse.jdt.internal.compiler.lookup.VariableBinding variableBinding, VariableDeclaration variableDeclaration) {
368
	synchronized IVariableBinding getVariableBinding(org.eclipse.jdt.internal.compiler.lookup.VariableBinding variableBinding, VariableDeclaration variableDeclaration) {
Lines 1734-1741 Link Here
1734
	 * @param dimensions the given dimensions
1728
	 * @param dimensions the given dimensions
1735
	 * @return an array type binding with the given type binding and the given
1729
	 * @return an array type binding with the given type binding and the given
1736
	 * dimensions
1730
	 * dimensions
1737
	 * @throws IllegalArgumentException if the type binding represents the <code>void</code> type binding or if the
1731
	 * @throws IllegalArgumentException if the type binding represents the <code>void</code> type binding
1738
	 * given type binding is a recovered binding 
1739
	 */
1732
	 */
1740
	ITypeBinding resolveArrayType(ITypeBinding typeBinding, int dimensions) {
1733
	ITypeBinding resolveArrayType(ITypeBinding typeBinding, int dimensions) {
1741
		if (typeBinding.isRecovered()) throw new IllegalArgumentException("Cannot be called on a recovered type binding"); //$NON-NLS-1$
1734
		if (typeBinding.isRecovered()) throw new IllegalArgumentException("Cannot be called on a recovered type binding"); //$NON-NLS-1$
(-)dom/org/eclipse/jdt/core/dom/IBinding.java (-1 / +2 lines)
Lines 207-212 Link Here
207
	 * <li>the default constructor of a source class</li>
207
	 * <li>the default constructor of a source class</li>
208
	 * <li>the constructor of an anonymous class</li>
208
	 * <li>the constructor of an anonymous class</li>
209
	 * <li>member value pairs</li>
209
	 * <li>member value pairs</li>
210
	 * <li>recovered binding</li>
210
	 * </ul>
211
	 * </ul>
211
	 * For all other kind of type, method, variable, annotation and package bindings,
212
	 * For all other kind of type, method, variable, annotation and package bindings,
212
	 * this method returns non-<code>null</code>.
213
	 * this method returns non-<code>null</code>.
Lines 274-280 Link Here
274
	 * </p>
275
	 * </p>
275
	 * <p>Note that the key for annotation bindings and member value pair bindings is
276
	 * <p>Note that the key for annotation bindings and member value pair bindings is
276
	 * not yet implemented. This returns <code>null</code> for these 2 kinds of bindings.<br>
277
	 * not yet implemented. This returns <code>null</code> for these 2 kinds of bindings.<br>
277
	 * <code>null</code> is also returned for recovered bindings
278
	 * Recovered bindings have a unique key.
278
	 * </p>
279
	 * </p>
279
	 *
280
	 *
280
	 * @return the key for this binding
281
	 * @return the key for this binding

Return to bug 180905