Lines 372-378
Link Here
|
372 |
protected boolean connectTypeVariables(TypeParameter[] typeParameters) { |
372 |
protected boolean connectTypeVariables(TypeParameter[] typeParameters) { |
373 |
boolean noProblems = true; |
373 |
boolean noProblems = true; |
374 |
if (typeParameters == null || compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) return true; |
374 |
if (typeParameters == null || compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) return true; |
375 |
|
375 |
TypeBinding[] types = new TypeBinding[2]; |
|
|
376 |
Map invocations = new HashMap(2); |
376 |
nextVariable : for (int i = 0, paramLength = typeParameters.length; i < paramLength; i++) { |
377 |
nextVariable : for (int i = 0, paramLength = typeParameters.length; i < paramLength; i++) { |
377 |
TypeParameter typeParameter = typeParameters[i]; |
378 |
TypeParameter typeParameter = typeParameters[i]; |
378 |
TypeVariableBinding typeVariable = typeParameter.binding; |
379 |
TypeVariableBinding typeVariable = typeParameter.binding; |
Lines 415-424
Link Here
|
415 |
typeVariable.superclass = superRefType; |
416 |
typeVariable.superclass = superRefType; |
416 |
} else { |
417 |
} else { |
417 |
typeVariable.superInterfaces = new ReferenceBinding[] {superRefType}; |
418 |
typeVariable.superInterfaces = new ReferenceBinding[] {superRefType}; |
418 |
typeVariable.modifiers |= AccInterface; |
|
|
419 |
} |
419 |
} |
420 |
typeVariable.firstBound = superRefType; // first bound used to compute erasure |
420 |
typeVariable.firstBound = superRefType; // first bound used to compute erasure |
421 |
|
|
|
422 |
TypeReference[] boundRefs = typeParameter.bounds; |
421 |
TypeReference[] boundRefs = typeParameter.bounds; |
423 |
if (boundRefs != null) { |
422 |
if (boundRefs != null) { |
424 |
for (int j = 0, k = boundRefs.length; j < k; j++) { |
423 |
for (int j = 0, k = boundRefs.length; j < k; j++) { |
Lines 432-437
Link Here
|
432 |
continue nextVariable; |
431 |
continue nextVariable; |
433 |
} |
432 |
} |
434 |
typeRef.resolvedType = superType; // hold onto the problem type |
433 |
typeRef.resolvedType = superType; // hold onto the problem type |
|
|
434 |
types[0] = superType; |
435 |
if (superType.isArrayType()) { |
435 |
if (superType.isArrayType()) { |
436 |
problemReporter().boundCannotBeArray(typeRef, superType); |
436 |
problemReporter().boundCannotBeArray(typeRef, superType); |
437 |
continue nextVariable; |
437 |
continue nextVariable; |
Lines 443-469
Link Here
|
443 |
noProblems = false; |
443 |
noProblems = false; |
444 |
continue nextVariable; |
444 |
continue nextVariable; |
445 |
} |
445 |
} |
446 |
if (superType.isParameterizedType()) { |
446 |
// check against superclass |
|
|
447 |
if (typeVariable.firstBound == typeVariable.superclass) { |
447 |
ReferenceBinding match = typeVariable.superclass.findSuperTypeWithSameErasure(superType); |
448 |
ReferenceBinding match = typeVariable.superclass.findSuperTypeWithSameErasure(superType); |
448 |
boolean isCollision = match != null && match != superType; |
449 |
if (match != null && match != superType) { |
449 |
for (int index = typeVariable.superInterfaces.length; !isCollision && --index >= 0;) { |
450 |
problemReporter().superinterfacesCollide(superType.erasure(), typeRef, superType, match); |
450 |
ReferenceBinding temp = typeVariable.superInterfaces[index]; |
|
|
451 |
isCollision = superType != temp && superType.erasure() == temp.erasure(); |
452 |
} |
453 |
if (isCollision) { |
454 |
problemReporter().boundHasConflictingArguments(typeRef, superType); |
455 |
typeVariable.tagBits |= HierarchyHasProblems; |
451 |
typeVariable.tagBits |= HierarchyHasProblems; |
456 |
noProblems = false; |
452 |
noProblems = false; |
457 |
continue nextVariable; |
453 |
continue nextVariable; |
458 |
} |
454 |
} |
459 |
} |
455 |
} |
|
|
456 |
// check against superinterfaces |
460 |
for (int index = typeVariable.superInterfaces.length; --index >= 0;) { |
457 |
for (int index = typeVariable.superInterfaces.length; --index >= 0;) { |
461 |
if (superType.erasure() == typeVariable.superInterfaces[index].erasure()) { |
458 |
ReferenceBinding previousInterface = typeVariable.superInterfaces[index]; |
|
|
459 |
if (previousInterface == superRefType) { |
462 |
problemReporter().duplicateBounds(typeRef, superType); |
460 |
problemReporter().duplicateBounds(typeRef, superType); |
463 |
typeVariable.tagBits |= HierarchyHasProblems; |
461 |
typeVariable.tagBits |= HierarchyHasProblems; |
464 |
noProblems = false; |
462 |
noProblems = false; |
465 |
continue nextVariable; |
463 |
continue nextVariable; |
466 |
} |
464 |
} |
|
|
465 |
types[1] = previousInterface; |
466 |
invocations.clear(); |
467 |
TypeBinding[] mecs = minimalErasedCandidates(types, invocations); |
468 |
if (mecs != null) { |
469 |
nextCandidate: for (int m = 0, max = mecs.length; m < max; m++) { |
470 |
TypeBinding mec = mecs[m]; |
471 |
if (mec == null) continue nextCandidate; |
472 |
Set invalidInvocations = (Set)invocations.get(mec); |
473 |
int invalidSize = invalidInvocations.size(); |
474 |
if (invalidSize > 1) { |
475 |
TypeBinding[] collisions; |
476 |
invalidInvocations.toArray(collisions = new TypeBinding[invalidSize]); |
477 |
problemReporter().superinterfacesCollide(collisions[0].erasure(), typeRef, collisions[0], collisions[1]); |
478 |
typeVariable.tagBits |= HierarchyHasProblems; |
479 |
noProblems = false; |
480 |
continue nextVariable; |
481 |
} |
482 |
} |
483 |
} |
467 |
} |
484 |
} |
468 |
int size = typeVariable.superInterfaces.length; |
485 |
int size = typeVariable.superInterfaces.length; |
469 |
System.arraycopy(typeVariable.superInterfaces, 0, typeVariable.superInterfaces = new ReferenceBinding[size + 1], 0, size); |
486 |
System.arraycopy(typeVariable.superInterfaces, 0, typeVariable.superInterfaces = new ReferenceBinding[size + 1], 0, size); |