}
public void resolveTypeExpecting(final BlockScope scope, final TypeBinding requiredType) {
if (this.value == null) {
this.compilerElementPair = new ElementValuePair(this.name, this.value, this.binding);
return;
}
if (requiredType == null) {
// fault tolerance: keep resolving
if (this.value instanceof ArrayInitializer) {
this.value.resolveTypeExpecting(scope, null);
} else {
this.value.resolveType(scope);
}
this.compilerElementPair = new ElementValuePair(this.name, this.value, this.binding);
return;
}
this.value.setExpectedType(requiredType); // needed in case of generic method invocation - looks suspect, generic method invocation here ???
final TypeBinding valueType;
if (this.value instanceof ArrayInitializer) {
ArrayInitializer initializer = (ArrayInitializer) this.value;
valueType = initializer.resolveTypeExpecting(scope, this.binding.returnType);
} else if (this.value instanceof ArrayAllocationExpression) {
scope.problemReporter().annotationValueMustBeArrayInitializer(this.binding.declaringClass, this.name, this.value);
this.value.resolveType(scope);
valueType = null; // no need to pursue
} else {
valueType = this.value.resolveType(scope);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=248897
ASTVisitor visitor = new ASTVisitor() {
public boolean visit(SingleNameReference reference, BlockScope scop) {
if (reference.binding instanceof LocalVariableBinding) {
((LocalVariableBinding) reference.binding).useFlag = LocalVariableBinding.USED;
}
return true;
}
};
this.value.traverse(visitor, scope);
}
this.compilerElementPair = new ElementValuePair(this.name, this.value, this.binding);
if (valueType == null)
return;
final TypeBinding leafType = requiredType.leafComponentType();
// the next check may need deferring: