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++) { |