if (target == null || target.isNull()) {
return null;
}
MemberReference member = node.getUserData(Keys.MEMBER_REFERENCE);
if (member == null && node.getParent() != null) {
member = node.getParent().getUserData(Keys.MEMBER_REFERENCE);
}
if (member == null) {
return null;
}
final ResolveResult targetResult = _resolver.apply(target);
if (targetResult == null || targetResult.getType() == null) {
return null;
}
final TypeReference declaringType = member.getDeclaringType();
final TypeDefinition resolvedDeclaringType = declaringType.resolve();
final boolean isSubType = MetadataHelper.isSubType(
targetResult.getType(),
resolvedDeclaringType != null ? resolvedDeclaringType : declaringType
);
if (isSubType) {
return null;
}
final AstBuilder astBuilder = context.getUserData(Keys.AST_BUILDER);
if (astBuilder == null) {
return null;
}
TypeReference castType = MetadataHelper.asSubType(targetResult.getType(), declaringType);
if (castType == null) {
if (resolvedDeclaringType != null &&
resolvedDeclaringType.isGenericDefinition() &&
member.containsGenericParameters()) {
final int wildcardCount = resolvedDeclaringType.getGenericParameters().size();
final TypeReference[] typeArguments = new TypeReference[wildcardCount];
for (int i = 0; i < typeArguments.length; i++) {