return SpecificCompilerWorkarounds.isSubType( typeUtils, superBound, p ) ||
typeUtils.isSameType( p, superBound );
case TYPEVAR:
TypeParameterElement typeParameter = getTypeParamFromCandidate( superBound );
// for example method: <T extends String & Serializable> T method(? super T)
if ( !isWithinBounds( p, typeParameter ) ) {
// this checks the part? <T extends String & Serializable>
return Boolean.FALSE;
}
// now, it becomes a bit more hairy. We have the relation (? super T). From T we know that
// it is a subclass of String & Serializable. However, The Java Language Secification,
// Chapter 4.4, states that a bound is either: 'A type variable-', 'A class-' or 'An
// interface-' type followed by further interface types. So we must compare with the first
// argument in the Expression String & Serializable & ..., so, in this case String.
// to check super type, we can simply reverse the argument, but that would initially yield
// a result: <type, superType] (so type not included) so we need to check sameType also.
TypeMirror superBoundAsDeclared = typeParameter.getBounds().get( 0 );
return ( SpecificCompilerWorkarounds.isSubType( typeUtils, superBoundAsDeclared, p ) ||
typeUtils.isSameType( p, superBoundAsDeclared ) );
default:
// does this situation occur?
return Boolean.FALSE;