Simplified some code

This commit is contained in:
Alexandros Naskos 2020-06-14 23:43:29 +03:00
parent 48019dd7e2
commit e68bec8673

View File

@ -217,9 +217,10 @@ fn findReturnStatementInternal(
var child_idx: usize = 0;
while (base_node.iterate(child_idx)) |child_node| : (child_idx += 1) {
switch (child_node.id) {
.ControlFlowExpression => {
.ControlFlowExpression => blk: {
const cfe = child_node.cast(ast.Node.ControlFlowExpression).?;
if (cfe.kind == .Return) {
if (cfe.kind != .Return) break :blk;
// If we are calling ourselves recursively, ignore this return.
if (cfe.rhs) |rhs| {
if (rhs.cast(ast.Node.Call)) |call_node| {
@ -235,7 +236,6 @@ fn findReturnStatementInternal(
already_found.* = true;
result = cfe;
continue;
}
},
else => {},
}
@ -262,16 +262,12 @@ fn resolveReturnType(
// If this is a type function and it only contains a single return statement that returns
// a container declaration, we will return that declaration.
const ret = findReturnStatement(handle.tree, fn_decl) orelse return null;
if (ret.rhs) |rhs|
if (try resolveTypeOfNodeInternal(store, arena, .{
if (ret.rhs) |rhs| {
return try resolveTypeOfNodeInternal(store, arena, .{
.node = rhs,
.handle = handle,
}, bound_type_params)) |res_rhs| switch (res_rhs.node.id) {
.ContainerDecl => {
return res_rhs;
},
else => return null,
};
}, bound_type_params);
}
return null;
}