Lines 2536-2547
Link Here
|
2536 |
nextCandidate: for (int k = 0, max = mecs.length; k < max; k++) { |
2536 |
nextCandidate: for (int k = 0, max = mecs.length; k < max; k++) { |
2537 |
TypeBinding mec = mecs[k]; |
2537 |
TypeBinding mec = mecs[k]; |
2538 |
if (mec == null) continue nextCandidate; |
2538 |
if (mec == null) continue nextCandidate; |
2539 |
Set invalidInvocations = (Set) invocations.get(mec); |
2539 |
Object value = invocations.get(mec); |
2540 |
int invalidSize = invalidInvocations.size(); |
2540 |
if (value instanceof TypeBinding[]) { |
2541 |
if (invalidSize > 1) { |
2541 |
TypeBinding[] invalidInvocations = (TypeBinding[]) value; |
2542 |
TypeBinding[] collisions; |
2542 |
problemReporter().superinterfacesCollide(invalidInvocations[0].erasure(), typeRef, invalidInvocations[0], invalidInvocations[1]); |
2543 |
invalidInvocations.toArray(collisions = new TypeBinding[invalidSize]); |
|
|
2544 |
problemReporter().superinterfacesCollide(collisions[0].erasure(), typeRef, collisions[0], collisions[1]); |
2545 |
type.tagBits |= TagBits.HierarchyHasProblems; |
2543 |
type.tagBits |= TagBits.HierarchyHasProblems; |
2546 |
return true; |
2544 |
return true; |
2547 |
} |
2545 |
} |
Lines 2756-2766
Link Here
|
2756 |
return false; |
2754 |
return false; |
2757 |
} |
2755 |
} |
2758 |
|
2756 |
|
2759 |
private TypeBinding leastContainingInvocation(TypeBinding mec, Set invocations, List lubStack) { |
2757 |
private TypeBinding leastContainingInvocation(TypeBinding mec, Object invocationData, List lubStack) { |
2760 |
if (invocations == null) return mec; // no alternate invocation |
2758 |
if (invocationData == null) return mec; // no alternate invocation |
2761 |
int length = invocations.size(); |
2759 |
if (invocationData instanceof TypeBinding) { // only one invocation, simply return it (array only allocated if more than one) |
2762 |
Iterator iter = invocations.iterator(); |
2760 |
return (TypeBinding) invocationData; |
2763 |
if (length == 1) return (TypeBinding) iter.next(); |
2761 |
} |
|
|
2762 |
TypeBinding[] invocations = (TypeBinding[]) invocationData; |
2764 |
|
2763 |
|
2765 |
// if mec is an array type, intersect invocation leaf component types, then promote back to array |
2764 |
// if mec is an array type, intersect invocation leaf component types, then promote back to array |
2766 |
int dim = mec.dimensions(); |
2765 |
int dim = mec.dimensions(); |
Lines 2771-2793
Link Here
|
2771 |
|
2770 |
|
2772 |
// infer proper parameterized type from invocations |
2771 |
// infer proper parameterized type from invocations |
2773 |
TypeBinding[] bestArguments = new TypeBinding[argLength]; |
2772 |
TypeBinding[] bestArguments = new TypeBinding[argLength]; |
2774 |
while (iter.hasNext()) { |
2773 |
for (int i = 0, length = invocations.length; i < length; i++) { |
2775 |
TypeBinding invocation = ((TypeBinding)iter.next()).leafComponentType(); |
2774 |
TypeBinding invocation = invocations[i].leafComponentType(); |
2776 |
switch (invocation.kind()) { |
2775 |
switch (invocation.kind()) { |
2777 |
case Binding.GENERIC_TYPE : |
2776 |
case Binding.GENERIC_TYPE : |
2778 |
TypeVariableBinding[] invocationVariables = invocation.typeVariables(); |
2777 |
TypeVariableBinding[] invocationVariables = invocation.typeVariables(); |
2779 |
for (int i = 0; i < argLength; i++) { |
2778 |
for (int j = 0; j < argLength; j++) { |
2780 |
TypeBinding bestArgument = leastContainingTypeArgument(bestArguments[i], invocationVariables[i], (ReferenceBinding) mec, i, lubStack); |
2779 |
TypeBinding bestArgument = leastContainingTypeArgument(bestArguments[j], invocationVariables[j], (ReferenceBinding) mec, j, lubStack); |
2781 |
if (bestArgument == null) return null; |
2780 |
if (bestArgument == null) return null; |
2782 |
bestArguments[i] = bestArgument; |
2781 |
bestArguments[j] = bestArgument; |
2783 |
} |
2782 |
} |
2784 |
break; |
2783 |
break; |
2785 |
case Binding.PARAMETERIZED_TYPE : |
2784 |
case Binding.PARAMETERIZED_TYPE : |
2786 |
ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding)invocation; |
2785 |
ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding)invocation; |
2787 |
for (int i = 0; i < argLength; i++) { |
2786 |
for (int j = 0; j < argLength; j++) { |
2788 |
TypeBinding bestArgument = leastContainingTypeArgument(bestArguments[i], parameterizedType.arguments[i], (ReferenceBinding) mec, i, lubStack); |
2787 |
TypeBinding bestArgument = leastContainingTypeArgument(bestArguments[j], parameterizedType.arguments[j], (ReferenceBinding) mec, j, lubStack); |
2789 |
if (bestArgument == null) return null; |
2788 |
if (bestArgument == null) return null; |
2790 |
bestArguments[i] = bestArgument; |
2789 |
bestArguments[j] = bestArgument; |
2791 |
} |
2790 |
} |
2792 |
break; |
2791 |
break; |
2793 |
case Binding.RAW_TYPE : |
2792 |
case Binding.RAW_TYPE : |
Lines 2928-2934
Link Here
|
2928 |
for (int i = 0; i < length; i++) { |
2927 |
for (int i = 0; i < length; i++) { |
2929 |
TypeBinding mec = mecs[i]; |
2928 |
TypeBinding mec = mecs[i]; |
2930 |
if (mec == null) continue; |
2929 |
if (mec == null) continue; |
2931 |
mec = leastContainingInvocation(mec, (Set)invocations.get(mec), lubStack); |
2930 |
mec = leastContainingInvocation(mec, invocations.get(mec), lubStack); |
2932 |
if (mec == null) return null; |
2931 |
if (mec == null) return null; |
2933 |
int dim = mec.dimensions(); |
2932 |
int dim = mec.dimensions(); |
2934 |
if (commonDim == -1) { |
2933 |
if (commonDim == -1) { |
Lines 3001-3009
Link Here
|
3001 |
TypeBinding leafType = firstType.leafComponentType(); |
3000 |
TypeBinding leafType = firstType.leafComponentType(); |
3002 |
TypeBinding firstErasure = (leafType.isTypeVariable() || leafType.isWildcard()/*&& !leafType.isCapture()*/) ? firstType : firstType.erasure(); |
3001 |
TypeBinding firstErasure = (leafType.isTypeVariable() || leafType.isWildcard()/*&& !leafType.isCapture()*/) ? firstType : firstType.erasure(); |
3003 |
if (firstErasure != firstType) { |
3002 |
if (firstErasure != firstType) { |
3004 |
Set someInvocations = new HashSet(1); |
3003 |
allInvocations.put(firstErasure, firstType); |
3005 |
someInvocations.add(firstType); |
|
|
3006 |
allInvocations.put(firstErasure, someInvocations); |
3007 |
} |
3004 |
} |
3008 |
typesToVisit.add(firstType); |
3005 |
typesToVisit.add(firstType); |
3009 |
int max = 1; |
3006 |
int max = 1; |
Lines 3063-3071
Link Here
|
3063 |
max++; |
3060 |
max++; |
3064 |
TypeBinding superTypeErasure = (firstBound.isTypeVariable() || firstBound.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure(); |
3061 |
TypeBinding superTypeErasure = (firstBound.isTypeVariable() || firstBound.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure(); |
3065 |
if (superTypeErasure != superType) { |
3062 |
if (superTypeErasure != superType) { |
3066 |
Set someInvocations = new HashSet(1); |
3063 |
allInvocations.put(superTypeErasure, superType); |
3067 |
someInvocations.add(superType); |
|
|
3068 |
allInvocations.put(superTypeErasure, someInvocations); |
3069 |
} |
3064 |
} |
3070 |
} |
3065 |
} |
3071 |
continue; |
3066 |
continue; |
Lines 3082-3090
Link Here
|
3082 |
max++; |
3077 |
max++; |
3083 |
TypeBinding superTypeErasure = (itsInterface.isTypeVariable() || itsInterface.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure(); |
3078 |
TypeBinding superTypeErasure = (itsInterface.isTypeVariable() || itsInterface.isWildcard() /*&& !itsInterface.isCapture()*/) ? superType : superType.erasure(); |
3084 |
if (superTypeErasure != superType) { |
3079 |
if (superTypeErasure != superType) { |
3085 |
Set someInvocations = new HashSet(1); |
3080 |
allInvocations.put(superTypeErasure, superType); |
3086 |
someInvocations.add(superType); |
|
|
3087 |
allInvocations.put(superTypeErasure, someInvocations); |
3088 |
} |
3081 |
} |
3089 |
} |
3082 |
} |
3090 |
} |
3083 |
} |
Lines 3097-3105
Link Here
|
3097 |
max++; |
3090 |
max++; |
3098 |
TypeBinding superTypeErasure = (itsSuperclass.isTypeVariable() || itsSuperclass.isWildcard() /*&& !itsSuperclass.isCapture()*/) ? superType : superType.erasure(); |
3091 |
TypeBinding superTypeErasure = (itsSuperclass.isTypeVariable() || itsSuperclass.isWildcard() /*&& !itsSuperclass.isCapture()*/) ? superType : superType.erasure(); |
3099 |
if (superTypeErasure != superType) { |
3092 |
if (superTypeErasure != superType) { |
3100 |
Set someInvocations = new HashSet(1); |
3093 |
allInvocations.put(superTypeErasure, superType); |
3101 |
someInvocations.add(superType); |
|
|
3102 |
allInvocations.put(superTypeErasure, someInvocations); |
3103 |
} |
3094 |
} |
3104 |
} |
3095 |
} |
3105 |
} |
3096 |
} |
Lines 3128-3137
Link Here
|
3128 |
continue nextSuperType; |
3119 |
continue nextSuperType; |
3129 |
} |
3120 |
} |
3130 |
// record invocation |
3121 |
// record invocation |
3131 |
Set someInvocations = (Set) allInvocations.get(erasedSuperType); |
3122 |
Object invocationData = allInvocations.get(erasedSuperType); |
3132 |
if (someInvocations == null) someInvocations = new HashSet(1); |
3123 |
if (invocationData == null) { |
3133 |
someInvocations.add(match); |
3124 |
allInvocations.put(erasedSuperType, match); // no array for singleton |
3134 |
allInvocations.put(erasedSuperType, someInvocations); |
3125 |
} else if (invocationData instanceof TypeBinding) { |
|
|
3126 |
if (match != invocationData) { |
3127 |
// using an array to record invocations in order (188103) |
3128 |
TypeBinding[] someInvocations = { (TypeBinding) invocationData, match, }; |
3129 |
allInvocations.put(erasedSuperType, someInvocations); |
3130 |
} |
3131 |
} else { // using an array to record invocations in order (188103) |
3132 |
TypeBinding[] someInvocations = (TypeBinding[]) invocationData; |
3133 |
checkExisting: { |
3134 |
int invocLength = someInvocations.length; |
3135 |
for (int k = 0; k < invocLength; k++) { |
3136 |
if (someInvocations[k] == match) break checkExisting; |
3137 |
} |
3138 |
System.arraycopy(someInvocations, 0, someInvocations = new TypeBinding[invocLength+1], 0, invocLength); |
3139 |
allInvocations.put(erasedSuperType, someInvocations); |
3140 |
someInvocations[invocLength] = match; |
3141 |
} |
3142 |
} |
3135 |
} |
3143 |
} |
3136 |
continue nextOtherType; |
3144 |
continue nextOtherType; |
3137 |
} |
3145 |
} |
Lines 3154-3163
Link Here
|
3154 |
} |
3162 |
} |
3155 |
} |
3163 |
} |
3156 |
// record invocation |
3164 |
// record invocation |
3157 |
Set someInvocations = (Set) allInvocations.get(erasedSuperType); |
3165 |
Object invocationData = allInvocations.get(erasedSuperType); |
3158 |
if (someInvocations == null) someInvocations = new HashSet(1); |
3166 |
if (invocationData == null) { |
3159 |
someInvocations.add(match); |
3167 |
allInvocations.put(erasedSuperType, match); // no array for singleton |
3160 |
allInvocations.put(erasedSuperType, someInvocations); |
3168 |
} else if (invocationData instanceof TypeBinding) { |
|
|
3169 |
if (match != invocationData) { |
3170 |
// using an array to record invocations in order (188103) |
3171 |
TypeBinding[] someInvocations = { (TypeBinding) invocationData, match, }; |
3172 |
allInvocations.put(erasedSuperType, someInvocations); |
3173 |
} |
3174 |
} else { // using an array to record invocations in order (188103) |
3175 |
TypeBinding[] someInvocations = (TypeBinding[]) invocationData; |
3176 |
checkExisting: { |
3177 |
int invocLength = someInvocations.length; |
3178 |
for (int k = 0; k < invocLength; k++) { |
3179 |
if (someInvocations[k] == match) break checkExisting; |
3180 |
} |
3181 |
System.arraycopy(someInvocations, 0, someInvocations = new TypeBinding[invocLength+1], 0, invocLength); |
3182 |
allInvocations.put(erasedSuperType, someInvocations); |
3183 |
someInvocations[invocLength] = match; |
3184 |
} |
3185 |
} |
3161 |
} |
3186 |
} |
3162 |
} |
3187 |
} |
3163 |
// eliminate non minimal super types |
3188 |
// eliminate non minimal super types |