### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.307 diff -u -r1.307 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 16 May 2007 20:49:40 -0000 1.307 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 22 May 2007 07:44:46 -0000 @@ -2536,12 +2536,12 @@ nextCandidate: for (int k = 0, max = mecs.length; k < max; k++) { TypeBinding mec = mecs[k]; if (mec == null) continue nextCandidate; - Set invalidInvocations = (Set) invocations.get(mec); - int invalidSize = invalidInvocations.size(); - if (invalidSize > 1) { - TypeBinding[] collisions; - invalidInvocations.toArray(collisions = new TypeBinding[invalidSize]); - problemReporter().superinterfacesCollide(collisions[0].erasure(), typeRef, collisions[0], collisions[1]); + Object value = invocations.get(mec); + if (value instanceof List) { + List invalidInvocations = (List) value; + TypeBinding firstInvocation = (TypeBinding) invalidInvocations.get(0); + TypeBinding secondInvocation = (TypeBinding) invalidInvocations.get(1); + problemReporter().superinterfacesCollide(firstInvocation.erasure(), typeRef, firstInvocation, secondInvocation); type.tagBits |= TagBits.HierarchyHasProblems; return true; } @@ -2756,11 +2756,13 @@ return false; } - private TypeBinding leastContainingInvocation(TypeBinding mec, Set invocations, List lubStack) { - if (invocations == null) return mec; // no alternate invocation - int length = invocations.size(); + private TypeBinding leastContainingInvocation(TypeBinding mec, Object invocationValue, List lubStack) { + if (invocationValue == null) return mec; // no alternate invocation + if (!(invocationValue instanceof List)) { // only one invocation, simply return it (list only allocated if more than one) + return (TypeBinding) invocationValue; + } + List invocations = (List) invocationValue; Iterator iter = invocations.iterator(); - if (length == 1) return (TypeBinding) iter.next(); // if mec is an array type, intersect invocation leaf component types, then promote back to array int dim = mec.dimensions(); @@ -2928,7 +2930,7 @@ for (int i = 0; i < length; i++) { TypeBinding mec = mecs[i]; if (mec == null) continue; - mec = leastContainingInvocation(mec, (Set)invocations.get(mec), lubStack); + mec = leastContainingInvocation(mec, invocations.get(mec), lubStack); if (mec == null) return null; int dim = mec.dimensions(); if (commonDim == -1) { @@ -3001,9 +3003,7 @@ TypeBinding leafType = firstType.leafComponentType(); TypeBinding firstErasure = (leafType.isTypeVariable() || leafType.isWildcard()/*&& !leafType.isCapture()*/) ? firstType : firstType.erasure(); if (firstErasure != firstType) { - Set someInvocations = new HashSet(1); - someInvocations.add(firstType); - allInvocations.put(firstErasure, someInvocations); + allInvocations.put(firstErasure, firstType); } typesToVisit.add(firstType); int max = 1; @@ -3063,9 +3063,7 @@ max++; TypeBinding superTypeErasure = (firstBound.isTypeVariable() || firstBound.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure(); if (superTypeErasure != superType) { - Set someInvocations = new HashSet(1); - someInvocations.add(superType); - allInvocations.put(superTypeErasure, someInvocations); + allInvocations.put(superTypeErasure, superType); } } continue; @@ -3082,9 +3080,7 @@ max++; TypeBinding superTypeErasure = (itsInterface.isTypeVariable() || itsInterface.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure(); if (superTypeErasure != superType) { - Set someInvocations = new HashSet(1); - someInvocations.add(superType); - allInvocations.put(superTypeErasure, someInvocations); + allInvocations.put(superTypeErasure, superType); } } } @@ -3097,9 +3093,7 @@ max++; TypeBinding superTypeErasure = (itsSuperclass.isTypeVariable() || itsSuperclass.isWildcard() /*&& !itsSuperclass.isCapture()*/) ? superType : superType.erasure(); if (superTypeErasure != superType) { - Set someInvocations = new HashSet(1); - someInvocations.add(superType); - allInvocations.put(superTypeErasure, someInvocations); + allInvocations.put(superTypeErasure, superType); } } } @@ -3128,10 +3122,24 @@ continue nextSuperType; } // record invocation - Set someInvocations = (Set) allInvocations.get(erasedSuperType); - if (someInvocations == null) someInvocations = new HashSet(1); - someInvocations.add(match); - allInvocations.put(erasedSuperType, someInvocations); + Object value = allInvocations.get(erasedSuperType); + if (value == null) { + allInvocations.put(erasedSuperType, match); + } else if (!(value instanceof List)) { + if (match != value) { + // using a list to record invocations in order (188103) + List someInvocations = new ArrayList(2); + someInvocations.add(value); + someInvocations.add(match); + allInvocations.put(erasedSuperType, someInvocations); + } + } else { + List someInvocations = (List) value; + if (!someInvocations.contains(match)) { + someInvocations.add(match); + allInvocations.put(erasedSuperType, someInvocations); + } + } } continue nextOtherType; } @@ -3154,10 +3162,24 @@ } } // record invocation - Set someInvocations = (Set) allInvocations.get(erasedSuperType); - if (someInvocations == null) someInvocations = new HashSet(1); - someInvocations.add(match); - allInvocations.put(erasedSuperType, someInvocations); + Object value = allInvocations.get(erasedSuperType); + if (value == null) { + allInvocations.put(erasedSuperType, match); + } else if (!(value instanceof List)) { + if (match != value) { + // using a list to record invocations in order (188103) + List someInvocations = new ArrayList(2); + someInvocations.add(value); + someInvocations.add(match); + allInvocations.put(erasedSuperType, someInvocations); + } + } else { + List someInvocations = (List) value; + if (!someInvocations.contains(match)) { + someInvocations.add(match); + allInvocations.put(erasedSuperType, someInvocations); + } + } } } // eliminate non minimal super types