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

Collapse All | Expand All

(-).cvsignore (-1 / +3 lines)
Lines 1-2 Link Here
1
bin
1
bin
2
antbin
2
antbin
3
*.ipr
4
*.iws
(-).settings/org.eclipse.jdt.core.prefs (-10 / +11 lines)
Lines 1-9 Link Here
1
#Fri Sep 03 12:55:26 CEST 2004
1
#Thu Feb 03 14:27:11 PST 2005
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
3
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
4
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
4
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
5
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
5
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
6
org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
6
org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
7
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
7
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
8
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
8
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
9
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
9
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
10
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
Lines 23-28 Link Here
23
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
24
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
24
org.eclipse.jdt.core.compiler.compliance=1.4
25
org.eclipse.jdt.core.compiler.compliance=1.4
25
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
26
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
27
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
26
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
28
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
27
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
29
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
28
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
30
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
Lines 32-56 Link Here
32
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
34
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
33
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
35
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
34
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
36
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
35
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
36
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
37
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
37
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
38
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
39
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
38
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
40
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
39
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
41
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
40
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
41
org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
42
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
42
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
43
org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
44
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
43
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
45
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
44
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
46
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
45
eclipse.preferences.version=1
47
eclipse.preferences.version=1
46
org.eclipse.jdt.core.circularClasspath=error
48
org.eclipse.jdt.core.circularClasspath=error
47
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
48
org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
49
org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
50
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
49
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
51
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
50
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
51
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
52
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
52
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
53
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
53
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
54
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
55
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
54
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
56
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
55
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
57
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
56
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
58
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
Lines 58-65 Link Here
58
org.eclipse.jdt.core.incompleteClasspath=error
60
org.eclipse.jdt.core.incompleteClasspath=error
59
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
61
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
60
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
62
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
61
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
62
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
63
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
64
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
63
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
65
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
64
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
66
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
65
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java (-1 / +4 lines)
Lines 203-209 Link Here
203
		if (positionType != null) {
203
		if (positionType != null) {
204
			position.computeConversion(scope, IntBinding, positionType);
204
			position.computeConversion(scope, IntBinding, positionType);
205
		}
205
		}
206
		return this.resolvedType;
206
207
        // The type of this expression needs to be captured, unless it is being assigned to.
208
        return (this.bits & IsStrictlyAssignedMASK) != 0 ? 
209
                this.resolvedType : captureResolvedType();
207
	}
210
	}
208
211
209
	public void traverse(ASTVisitor visitor, BlockScope scope) {
212
	public void traverse(ASTVisitor visitor, BlockScope scope) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java (-1 / +2 lines)
Lines 173-184 Link Here
173
			scope.problemReporter().expressionShouldBeAVariable(this.lhs);
173
			scope.problemReporter().expressionShouldBeAVariable(this.lhs);
174
			return null;
174
			return null;
175
		}
175
		}
176
		TypeBinding lhsType = this.resolvedType = lhs.resolveType(scope);
176
		TypeBinding lhsType = lhs.resolveType(scope);
177
		expression.setExpectedType(lhsType); // needed in case of generic method invocation
177
		expression.setExpectedType(lhsType); // needed in case of generic method invocation
178
		TypeBinding rhsType = expression.resolveType(scope);
178
		TypeBinding rhsType = expression.resolveType(scope);
179
		if (lhsType == null || rhsType == null) {
179
		if (lhsType == null || rhsType == null) {
180
			return null;
180
			return null;
181
		}
181
		}
182
        this.resolvedType = lhsType.capture();
182
		checkAssignmentEffect(scope);
183
		checkAssignmentEffect(scope);
183
184
184
		// Compile-time conversion of base-types : implicit narrowing integer into byte/short/character
185
		// Compile-time conversion of base-types : implicit narrowing integer into byte/short/character
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java (-1 / +1 lines)
Lines 381-387 Link Here
381
					scope.problemReporter().typeCastError(this,  this.resolvedType, expressionType);
381
					scope.problemReporter().typeCastError(this,  this.resolvedType, expressionType);
382
				}
382
				}
383
			}
383
			}
384
			return this.resolvedType;
384
			return captureResolvedType();
385
		} else { // expression as a cast
385
		} else { // expression as a cast
386
			TypeBinding expressionType = expression.resolveType(scope);
386
			TypeBinding expressionType = expression.resolveType(scope);
387
			if (expressionType == null) return null;
387
			if (expressionType == null) return null;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java (-1 / +1 lines)
Lines 411-417 Link Here
411
			if (commonType != null) {
411
			if (commonType != null) {
412
				valueIfTrue.computeConversion(scope, commonType, valueIfTrueType);
412
				valueIfTrue.computeConversion(scope, commonType, valueIfTrueType);
413
				valueIfFalse.computeConversion(scope, commonType, valueIfFalseType);
413
				valueIfFalse.computeConversion(scope, commonType, valueIfFalseType);
414
				return this.resolvedType = commonType;
414
				return this.resolvedType = commonType.capture();
415
			}
415
			}
416
		}
416
		}
417
		scope.problemReporter().conditionalArgumentsIncompatibleTypes(
417
		scope.problemReporter().conditionalArgumentsIncompatibleTypes(
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java (+6 lines)
Lines 848-851 Link Here
848
	public LocalVariableBinding localVariableBinding() {
848
	public LocalVariableBinding localVariableBinding() {
849
		return null;
849
		return null;
850
	}
850
	}
851
    
852
    public final TypeBinding captureResolvedType() {
853
        if (this.resolvedType != null)
854
            this.resolvedType = this.resolvedType.capture();
855
        return this.resolvedType;
856
    }
851
}
857
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (-1 / +3 lines)
Lines 523-529 Link Here
523
				scope.problemReporter().indirectAccessToStaticField(this, binding);
523
				scope.problemReporter().indirectAccessToStaticField(this, binding);
524
			}
524
			}
525
		}
525
		}
526
		return this.resolvedType = binding.type;
526
527
        // The type of this expression needs to be captured, unless it is being assigned to.
528
		return this.resolvedType = (this.bits & IsStrictlyAssignedMASK) == 0 ? binding.type.capture() : binding.type;
527
	}
529
	}
528
530
529
	public void setActualReceiverType(ReferenceBinding receiverType) {
531
	public void setActualReceiverType(ReferenceBinding receiverType) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-3 / +3 lines)
Lines 259-265 Link Here
259
	// resolve type arguments (for generic constructor call)
259
	// resolve type arguments (for generic constructor call)
260
	if (this.typeArguments != null) {
260
	if (this.typeArguments != null) {
261
		int length = this.typeArguments.length;
261
		int length = this.typeArguments.length;
262
		boolean argHasError = false; // typeChecks all arguments
262
		boolean argHasError = false; // typeChecks all aFrguments
263
		this.genericTypeArguments = new TypeBinding[length];
263
		this.genericTypeArguments = new TypeBinding[length];
264
		for (int i = 0; i < length; i++) {
264
		for (int i = 0; i < length; i++) {
265
			if ((this.genericTypeArguments[i] = this.typeArguments[i].resolveType(scope, true /* check bounds*/)) == null) {
265
			if ((this.genericTypeArguments[i] = this.typeArguments[i].resolveType(scope, true /* check bounds*/)) == null) {
Lines 336-342 Link Here
336
				closestMatch.original().modifiers |= AccPrivateUsed;
336
				closestMatch.original().modifiers |= AccPrivateUsed;
337
			}
337
			}
338
		}
338
		}
339
		return this.resolvedType;
339
		return captureResolvedType();
340
	}
340
	}
341
	if (!binding.isStatic()) {
341
	if (!binding.isStatic()) {
342
		// the "receiver" must not be a type, in other words, a NameReference that the TC has bound to a Type
342
		// the "receiver" must not be a type, in other words, a NameReference that the TC has bound to a Type
Lines 385-391 Link Here
385
	} else {
385
	} else {
386
		this.resolvedType = this.binding.returnType;
386
		this.resolvedType = this.binding.returnType;
387
	}
387
	}
388
	return this.resolvedType;
388
	return captureResolvedType();
389
}
389
}
390
390
391
public void setActualReceiverType(ReferenceBinding receiverType) {
391
public void setActualReceiverType(ReferenceBinding receiverType) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-1 / +5 lines)
Lines 607-612 Link Here
607
			field = null;
607
			field = null;
608
		}
608
		}
609
		TypeBinding type = ((VariableBinding) binding).type;
609
		TypeBinding type = ((VariableBinding) binding).type;
610
        if (type != null) type = type.capture();
611
        
610
		int index = indexOfFirstFieldBinding;
612
		int index = indexOfFirstFieldBinding;
611
		if (index == length) { //	restrictiveFlag == FIELD
613
		if (index == length) { //	restrictiveFlag == FIELD
612
			this.constant = FieldReference.getConstantFor((FieldBinding) binding, this, false, scope);
614
			this.constant = FieldReference.getConstantFor((FieldBinding) binding, this, false, scope);
Lines 673-679 Link Here
673
			}
675
			}
674
		}
676
		}
675
		setDepth(firstDepth);
677
		setDepth(firstDepth);
676
		return (otherBindings[otherBindingsLength - 1]).type;
678
        final TypeBinding result = (otherBindings[otherBindingsLength - 1]).type;
679
        // The type of this expression needs to be captured, unless it is being assigned to.
680
		return (this.bits & IsStrictlyAssignedMASK) != 0 ? result : result.capture();
677
	}
681
	}
678
	public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
682
	public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
679
		if (!flowInfo.isReachable()) return;
683
		if (!flowInfo.isReachable()) return;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java (-7 / +15 lines)
Lines 661-674 Link Here
661
							if (!variable.isFinal() && (bits & DepthMASK) != 0) {
661
							if (!variable.isFinal() && (bits & DepthMASK) != 0) {
662
								scope.problemReporter().cannotReferToNonFinalOuterLocal((LocalVariableBinding)variable, this);
662
								scope.problemReporter().cannotReferToNonFinalOuterLocal((LocalVariableBinding)variable, this);
663
							}
663
							}
664
							return this.resolvedType = variable.type;
664
                            // If assigning to this variable, it's type is not captured.
665
							this.resolvedType = variable.type;
665
						}
666
						}
666
						// a field
667
                        else {
667
						FieldBinding field = (FieldBinding) this.binding;
668
                            // a field
668
						if (!field.isStatic() && scope.environment().options.getSeverity(CompilerOptions.UnqualifiedFieldAccess) != ProblemSeverities.Ignore) {
669
                            FieldBinding field = (FieldBinding) this.binding;
669
							scope.problemReporter().unqualifiedFieldAccess(this, field);
670
                            if (!field.isStatic() && scope.environment().options.getSeverity(CompilerOptions.UnqualifiedFieldAccess) != ProblemSeverities.Ignore) {
670
						}
671
                                scope.problemReporter().unqualifiedFieldAccess(this, field);
671
						return this.resolvedType = checkFieldAccess(scope);
672
                            }
673
                            this.resolvedType = checkFieldAccess(scope);
674
                        }
675
676
                        // The type of this expression needs to be captured, unless it is being assigned to.
677
                        if (((this.bits & IsStrictlyAssignedMASK) == 0))
678
                            captureResolvedType();
679
						return this.resolvedType;
672
					}
680
					}
673
	
681
	
674
					// thus it was a type
682
					// thus it was a type
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java (+105 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.compiler.lookup;
11
package org.eclipse.jdt.internal.compiler.lookup;
12
12
13
import java.util.Map;
13
import java.util.Map;
14
14
import org.eclipse.jdt.core.compiler.CharOperation;
15
import org.eclipse.jdt.core.compiler.CharOperation;
15
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
16
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
16
17
Lines 187-192 Link Here
187
     */
188
     */
188
    public TypeBinding erasure() {
189
    public TypeBinding erasure() {
189
        return this.type.erasure(); // erasure
190
        return this.type.erasure(); // erasure
191
    }
192
    
193
    /**
194
     * @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#capture()
195
     */
196
    public TypeBinding capture() {
197
        final TypeBinding[] oldArgs = this.arguments;
198
        if (oldArgs == null) return this;
199
        final TypeBinding[] newArgs = new TypeBinding[oldArgs.length];
200
        final TypeVariableBinding[] typeParams = this.type.typeVariables();
201
        boolean hasWildcard = false;
202
203
        // Perform capture in two passes. First construct a fresh type variable for each
204
        // wildcard type argument
205
        for (int i = 0, len = newArgs.length ; i < len ; i++) {
206
            final TypeBinding oldArg = oldArgs[i];
207
            if (! oldArg.isWildcard())
208
                newArgs[i] = oldArg;
209
            else {
210
                TypeVariableBinding newArg = new TypeVariableBinding(
211
                        CharOperation.concat(TypeConstants.CAPTURE_OF, oldArg.readableName()),
212
                        null, ((WildcardBinding)oldArg).rank);
213
                newArg.fPackage = ((WildcardBinding)oldArg).fPackage;
214
                newArgs[i] = newArg;
215
                hasWildcard = true;
216
            }
217
        }
218
219
        if (! hasWildcard) return this;
220
221
        // Construct a substitution from the Type Parameters of the generic type that is being captured
222
        // to the new captured wildcards. This is used below in setting the bounds of the captured wildcards.
223
        Substitution sub = new Substitution() {
224
            public LookupEnvironment environment() { return ParameterizedTypeBinding.this.environment(); }
225
            public boolean isRawSubstitution() { return false; }
226
227
            public TypeBinding substitute(TypeVariableBinding typeVariable) {
228
                for (int i = 0, len = typeParams.length ; i < len ; i++)
229
                    if (typeVariable == typeParams[i])
230
                        return newArgs[i];
231
                return typeVariable;
232
            }
233
        };
234
235
        // Second. Set the bounds of the new type variables
236
        for (int i = 0, len = newArgs.length; i < len; i++) {
237
            final TypeBinding oldArg = oldArgs[i];
238
            if (oldArg.isWildcard()) {
239
                final WildcardBinding wildcard = (WildcardBinding) oldArg;
240
                final TypeVariableBinding capture = (TypeVariableBinding) newArgs[i];
241
242
                // unbounded wildcards and lower bounded wildcards generate a type variable with
243
                // whose upper bound is the same as the upper bounds of the corresponding type variable
244
                if (wildcard.kind == Wildcard.UNBOUND || wildcard.kind == Wildcard.SUPER) {
245
                    final TypeBinding bound = Scope.substitute(sub, typeParams[i].superclass());
246
                    capture.superclass = bound.isClass() ? (ReferenceBinding) bound : environment.getType(JAVA_LANG_OBJECT);
247
248
                    final ReferenceBinding[] intfs = typeParams[i].superInterfaces;
249
                    final ReferenceBinding[] bounds = new ReferenceBinding[intfs.length];
250
                    for (int j = 0, len2 = bounds.length; j < len2; j++) {
251
                        bounds[j] = (ReferenceBinding)Scope.substitute(sub, intfs[j]);
252
                    }
253
                    capture.superInterfaces = bounds;
254
                }
255
256
                // The upper bound has already been set. Now set the lower bound.
257
                if (wildcard.kind == Wildcard.SUPER) {
258
                    capture.lowerBound = wildcard.bound;
259
                }
260
                else if (wildcard.kind == Wildcard.EXTENDS) {
261
                    if (wildcard.bound.isArrayType())
262
                        capture.arrayBound = wildcard.bound;
263
                    
264
                    if (wildcard.bound.isClass())
265
                        capture.firstBound = capture.superclass = (ReferenceBinding)wildcard.bound;
266
                    else if (typeParams[i].firstBound != null && typeParams[i].firstBound.isClass())
267
                        capture.firstBound = capture.superclass = typeParams[i].firstBound;
268
                    else
269
                        capture.superclass = environment.getType(JAVA_LANG_OBJECT);
270
                    
271
                    int intfs = (wildcard.bound.isInterface() ? 1 : 0) +
272
                        typeParams[i].superInterfaces().length;
273
                    
274
                    if (intfs == 0)
275
                        capture.superInterfaces = NoSuperInterfaces;
276
                    else {
277
                        ReferenceBinding[] interfaces = 
278
                            Scope.substitute(sub, typeParams[i].superInterfaces);
279
                        if (wildcard.bound.isInterface()) {
280
                            System.arraycopy(interfaces, 0, interfaces = new ReferenceBinding[intfs], 0, intfs - 1);
281
                            interfaces[intfs - 1] = (ReferenceBinding) wildcard.bound;
282
                        }
283
                        interfaces = Scope.greaterLowerBound(interfaces);
284
                        
285
                        capture.superInterfaces = interfaces;
286
                        if (capture.firstBound == null)
287
                            capture.firstBound = interfaces[0];
288
                    }
289
                    
290
                }
291
            }
292
        }
293
        
294
        return this.environment().createParameterizedType(this.type, newArgs, this.enclosingType);
190
    }
295
    }
191
	/**
296
	/**
192
	 * @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#fieldCount()
297
	 * @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#fieldCount()
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java (+9 lines)
Lines 625-630 Link Here
625
	}
625
	}
626
	if (otherReferenceType.isInterface())
626
	if (otherReferenceType.isInterface())
627
		return implementsInterface(otherReferenceType, true);
627
		return implementsInterface(otherReferenceType, true);
628
629
    if (otherReferenceType.isTypeVariable()) {
630
        // This handles the case for captured wildcards, For example:
631
        // <capture of ? super Number> is assignable from Integer
632
        TypeVariableBinding otherTypeVariable = (TypeVariableBinding) otherReferenceType;
633
        if (otherTypeVariable.lowerBound != null)
634
            return this.isCompatibleWith(otherTypeVariable.lowerBound);
635
    }
636
628
	if (isInterface())  // Explicit conversion from an interface to a class is not allowed
637
	if (isInterface())  // Explicit conversion from an interface to a class is not allowed
629
		return false;
638
		return false;
630
	return otherReferenceType.isSuperclassOf(this);
639
	return otherReferenceType.isSuperclassOf(this);
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-14 / +75 lines)
Lines 675-682 Link Here
675
675
676
		CompilationUnitScope unitScope = compilationUnitScope();
676
		CompilationUnitScope unitScope = compilationUnitScope();
677
		unitScope.recordTypeReference(receiverType);
677
		unitScope.recordTypeReference(receiverType);
678
		if (receiverType.isArrayType()) {
678
		checkArrayField: {
679
			TypeBinding leafType = receiverType.leafComponentType();
679
			TypeBinding leafType;
680
			switch (receiverType.kind()) {
681
				case Binding.WILDCARD_TYPE :
682
					TypeBinding receiverErasure = receiverType.erasure();
683
					if (!receiverErasure.isArrayType())
684
						break checkArrayField;
685
					leafType =receiverErasure.leafComponentType();
686
					break;
687
				case Binding.ARRAY_TYPE :
688
					leafType = receiverType.leafComponentType();
689
					break;
690
                case Binding.TYPE_PARAMETER:
691
                    leafType = ((TypeVariableBinding)receiverType).arrayBound;
692
                    if (leafType == null)
693
                        break checkArrayField;
694
                    break;
695
				default:
696
					break checkArrayField;
697
			}
680
			if (leafType instanceof ReferenceBinding)
698
			if (leafType instanceof ReferenceBinding)
681
				if (!((ReferenceBinding) leafType).canBeSeenBy(this))
699
				if (!((ReferenceBinding) leafType).canBeSeenBy(this))
682
					return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ReceiverTypeNotVisible);
700
					return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ReceiverTypeNotVisible);
Lines 2467-2477 Link Here
2467
		return qualifiedType;
2485
		return qualifiedType;
2468
	}
2486
	}
2469
	
2487
	
2488
 
2489
    // 5.1.10
2490
    static public TypeBinding[] greaterLowerBound(TypeBinding[] types) {
2491
        if (types == null) return null;
2492
        int length = types.length;
2493
        TypeBinding[] result = types;
2494
        int removed = 0;
2495
        for (int i = 0; i < length; i++) {
2496
            TypeBinding iType = result[i];
2497
            for (int j = 0; j < length; j++) {
2498
                if (i == j) continue;
2499
                TypeBinding jType = result[j];
2500
                if (jType == null) continue;
2501
                if (iType.isCompatibleWith(jType)) { // if Vi <: Vj, Vj is removed
2502
                    if (result == types) { // defensive copy
2503
                        System.arraycopy(result, 0, result = new TypeBinding[length], 0, length);
2504
                    }
2505
                    result[j] = null;
2506
                    removed ++;
2507
                }
2508
            }
2509
        }
2510
        if (removed == 0) return result;
2511
        TypeBinding[] trimmedResult = new TypeBinding[length - removed];
2512
        for (int i = 0, index = 0; i < length; i++) {
2513
            TypeBinding iType = result[i];
2514
            if (iType != null) {
2515
                trimmedResult[index++] = iType;
2516
            }
2517
        }
2518
        return trimmedResult;
2519
    }
2520
    
2470
	// 5.1.10
2521
	// 5.1.10
2471
	public TypeBinding[] greaterLowerBound(TypeBinding[] types) {
2522
	static public ReferenceBinding[] greaterLowerBound(ReferenceBinding[] types) {
2472
		if (types == null) return null;
2523
		if (types == null) return null;
2473
		int length = types.length;
2524
		int length = types.length;
2474
		TypeBinding[] result = types;
2525
		ReferenceBinding[] result = types;
2475
		int removed = 0;
2526
		int removed = 0;
2476
		for (int i = 0; i < length; i++) {
2527
		for (int i = 0; i < length; i++) {
2477
			TypeBinding iType = result[i];
2528
			TypeBinding iType = result[i];
Lines 2481-2487 Link Here
2481
				if (jType == null) continue;
2532
				if (jType == null) continue;
2482
				if (iType.isCompatibleWith(jType)) { // if Vi <: Vj, Vj is removed
2533
				if (iType.isCompatibleWith(jType)) { // if Vi <: Vj, Vj is removed
2483
					if (result == types) { // defensive copy
2534
					if (result == types) { // defensive copy
2484
						System.arraycopy(result, 0, result = new TypeBinding[length], 0, length);
2535
						System.arraycopy(result, 0, result = new ReferenceBinding[length], 0, length);
2485
					}
2536
					}
2486
					result[j] = null;
2537
					result[j] = null;
2487
					removed ++;
2538
					removed ++;
Lines 2489-2497 Link Here
2489
			}
2540
			}
2490
		}
2541
		}
2491
		if (removed == 0) return result;
2542
		if (removed == 0) return result;
2492
		TypeBinding[] trimmedResult = new TypeBinding[length - removed];
2543
		ReferenceBinding[] trimmedResult = new ReferenceBinding[length - removed];
2493
		for (int i = 0, index = 0; i < length; i++) {
2544
		for (int i = 0, index = 0; i < length; i++) {
2494
			TypeBinding iType = result[i];
2545
			ReferenceBinding iType = result[i];
2495
			if (iType != null) {
2546
			if (iType != null) {
2496
				trimmedResult[index++] = iType;
2547
				trimmedResult[index++] = iType;
2497
			}
2548
			}
Lines 2801-2807 Link Here
2801
			case 0: return NoTypes;
2852
			case 0: return NoTypes;
2802
			case 1: return types;
2853
			case 1: return types;
2803
		}
2854
		}
2804
2855
	
2805
		// record all supertypes of type
2856
		// record all supertypes of type
2806
		// intersect with all supertypes of otherType
2857
		// intersect with all supertypes of otherType
2807
		TypeBinding firstType = types[indexOfFirst];
2858
		TypeBinding firstType = types[indexOfFirst];
Lines 2824-2838 Link Here
2824
			};
2875
			};
2825
		} else {
2876
		} else {
2826
			ArrayList typesToVisit = new ArrayList(5);
2877
			ArrayList typesToVisit = new ArrayList(5);
2827
			if (firstType.erasure() != firstType) {
2878
			TypeBinding firstErasure = firstType.erasure();
2879
			if (firstErasure != firstType) {
2828
				Set someInvocations = new HashSet(1);
2880
				Set someInvocations = new HashSet(1);
2829
				someInvocations.add(firstType);
2881
				someInvocations.add(firstType);
2830
				allInvocations.put(firstType.erasure(), someInvocations);
2882
				allInvocations.put(firstErasure, someInvocations);
2831
			}			
2883
			}
2832
			typesToVisit.add(firstType.erasure());
2884
			typesToVisit.add(firstErasure);
2885
			int max = 1;
2886
			if (firstErasure.isArrayType()) {
2887
				typesToVisit.add(getJavaIoSerializable());
2888
				typesToVisit.add(getJavaLangCloneable());
2889
				typesToVisit.add(getJavaLangObject());
2890
				max += 3;
2891
			}
2833
			ReferenceBinding currentType = (ReferenceBinding)firstType;
2892
			ReferenceBinding currentType = (ReferenceBinding)firstType;
2834
			for (int i = 0, max = 1; i < max; i++) {
2893
			for (int i = 0; i < max; i++) {
2835
				currentType = (ReferenceBinding) typesToVisit.get(i);
2894
				TypeBinding typeToVisit = (TypeBinding) typesToVisit.get(i);
2895
				if (typeToVisit.isArrayType()) continue;
2896
				currentType = (ReferenceBinding) typeToVisit;
2836
				// inject super interfaces prior to superclass
2897
				// inject super interfaces prior to superclass
2837
				ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
2898
				ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
2838
				for (int j = 0, count = itsInterfaces.length; j < count; j++) {
2899
				for (int j = 0, count = itsInterfaces.length; j < count; j++) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java (+6 lines)
Lines 106-111 Link Here
106
public TypeBinding erasure() {
106
public TypeBinding erasure() {
107
    return this;
107
    return this;
108
}
108
}
109
110
/** Returns the type of this type after performing Capture Conversion(5.1.10) */
111
public TypeBinding capture() {
112
    return this;
113
}
114
109
/**
115
/**
110
 * Returns the type to use for generic cast, or null if none required
116
 * Returns the type to use for generic cast, or null if none required
111
 */
117
 */
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java (+1 lines)
Lines 67-72 Link Here
67
    char[] UPPER_LOCAL_VARIABLE = "LOCAL_VARIABLE".toCharArray(); //$NON-NLS-1$
67
    char[] UPPER_LOCAL_VARIABLE = "LOCAL_VARIABLE".toCharArray(); //$NON-NLS-1$
68
    char[] UPPER_ANNOTATION_TYPE = "ANNOTATION_TYPE".toCharArray(); //$NON-NLS-1$
68
    char[] UPPER_ANNOTATION_TYPE = "ANNOTATION_TYPE".toCharArray(); //$NON-NLS-1$
69
    char[] UPPER_PACKAGE = "PACKAGE".toCharArray(); //$NON-NLS-1$
69
    char[] UPPER_PACKAGE = "PACKAGE".toCharArray(); //$NON-NLS-1$
70
    char[] CAPTURE_OF = "capture of ".toCharArray(); //$NON-NLS-1$
70
    
71
    
71
	// Constant compound names
72
	// Constant compound names
72
	char[][] JAVA_LANG = {JAVA, LANG};
73
	char[][] JAVA_LANG = {JAVA, LANG};
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java (-1 / +26 lines)
Lines 33-38 Link Here
33
	public ReferenceBinding[] superInterfaces; 
33
	public ReferenceBinding[] superInterfaces; 
34
	public char[] genericTypeSignature;
34
	public char[] genericTypeSignature;
35
35
36
    /**
37
     * The lower bound of this type variable. Declared type variables never have
38
     * lower bounds. Only wildcard captures have lower bounds.
39
     */
40
    public TypeBinding lowerBound;
41
    
42
    /** 
43
     * The upper array bound of this type variable. Only captured wildcards
44
     * can have an array type as an upper bound. 
45
     */
46
    public TypeBinding arrayBound;
47
48
36
	public TypeVariableBinding(char[] sourceName, Binding declaringElement, int rank) {
49
	public TypeVariableBinding(char[] sourceName, Binding declaringElement, int rank) {
37
		this.sourceName = sourceName;
50
		this.sourceName = sourceName;
38
		this.declaringElement = declaringElement;
51
		this.declaringElement = declaringElement;
Lines 133-138 Link Here
133
	 * p.X<T> { ... } --> Lp/X<TT;>;:TT;
146
	 * p.X<T> { ... } --> Lp/X<TT;>;:TT;
134
	 */
147
	 */
135
	public char[] computeUniqueKey() {
148
	public char[] computeUniqueKey() {
149
        // TODO: for captured wildcards declaring element is null. Is this the right thing to do?
150
        if (this.declaringElement == null) return genericTypeSignature();
151
136
		char[] declaringKey = this.declaringElement.computeUniqueKey();
152
		char[] declaringKey = this.declaringElement.computeUniqueKey();
137
		int declaringLength = declaringKey.length;
153
		int declaringLength = declaringKey.length;
138
		char[] sig = genericTypeSignature();
154
		char[] sig = genericTypeSignature();
Lines 290-295 Link Here
290
	    return true;
306
	    return true;
291
	}
307
	}
292
	
308
	
309
    /* (non-Javadoc)
310
     * @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#isCompatibleWith(org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
311
     */
312
    public boolean isCompatibleWith(TypeBinding otherType) {
313
        return (this.arrayBound != null && this.arrayBound.isCompatibleWith(otherType)) ||
314
            super.isCompatibleWith(otherType);
315
    }
316
    
293
	/** 
317
	/** 
294
	 * Returns the original type variable for a given variable.
318
	 * Returns the original type variable for a given variable.
295
	 * Only different from receiver for type variables of generic methods of parameterized types
319
	 * Only different from receiver for type variables of generic methods of parameterized types
Lines 352-358 Link Here
352
	}
376
	}
353
	public ReferenceBinding[] superInterfaces() {
377
	public ReferenceBinding[] superInterfaces() {
354
		return superInterfaces;
378
		return superInterfaces;
355
	}	
379
	}
380
356
	/**
381
	/**
357
	 * @see java.lang.Object#toString()
382
	 * @see java.lang.Object#toString()
358
	 */
383
	 */

Return to bug 84496