if (var.getName().equals("self")) {
result.add(receiver);
} else if (var.getName().equals("nil")) {
result.add(runtime.getNil());
} else {
Vertex vertex = env.get(var);
TypeVarMap typeVarMap = RuntimeHelper.getTypeVarMap(receiver);
if (vertex != null) {
result.addAll(vertex.getTypeSet());
} else if (classType != null
&& typeVarMap != null
&& classType.containsType(var)) {
vertex = typeVarMap.get(var);
if (vertex != null) {
result.addAll(vertex.getTypeSet());
} else {
result.add(runtime.getNil());
}
}
}
return result;
}
case APPLICATION: {
TypeApplication app = (TypeApplication) returnType;
List<TypeExpression> types = app.getTypes();
IRubyObject ret = resolveIdentity(template, app.getIdentity());
if (ret != null && ret instanceof RubyClass) {
RubyClass klass = (RubyClass) ret;
ret = graph.newInstanceOf(klass);
ClassType klassType = RuntimeHelper.getClassAnnotation(klass);
TypeVarMap typeVarMap = RuntimeHelper.getTypeVarMap(ret);
if (klassType != null && typeVarMap != null) {
List<TypeVariable> vars = klassType.getTypes();
for (int i = 0; i < vars.size(); i++) {
TypeVariable var = vars.get(i);
if (i < types.size()) {
TypeExpression expr = types.get(i);
TypeSet ts = processMethodReturn(template, classType, expr, receiver);
Vertex vertex = graph.createFreeVertex();
vertex.addTypes(ts);
typeVarMap.put(var, vertex);
}
}
}
result.add(ret);