Simplified some code
This commit is contained in:
parent
48019dd7e2
commit
e68bec8673
@ -217,9 +217,10 @@ fn findReturnStatementInternal(
|
|||||||
var child_idx: usize = 0;
|
var child_idx: usize = 0;
|
||||||
while (base_node.iterate(child_idx)) |child_node| : (child_idx += 1) {
|
while (base_node.iterate(child_idx)) |child_node| : (child_idx += 1) {
|
||||||
switch (child_node.id) {
|
switch (child_node.id) {
|
||||||
.ControlFlowExpression => {
|
.ControlFlowExpression => blk: {
|
||||||
const cfe = child_node.cast(ast.Node.ControlFlowExpression).?;
|
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 we are calling ourselves recursively, ignore this return.
|
||||||
if (cfe.rhs) |rhs| {
|
if (cfe.rhs) |rhs| {
|
||||||
if (rhs.cast(ast.Node.Call)) |call_node| {
|
if (rhs.cast(ast.Node.Call)) |call_node| {
|
||||||
@ -235,7 +236,6 @@ fn findReturnStatementInternal(
|
|||||||
already_found.* = true;
|
already_found.* = true;
|
||||||
result = cfe;
|
result = cfe;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
},
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
@ -262,16 +262,12 @@ fn resolveReturnType(
|
|||||||
// If this is a type function and it only contains a single return statement that returns
|
// If this is a type function and it only contains a single return statement that returns
|
||||||
// a container declaration, we will return that declaration.
|
// a container declaration, we will return that declaration.
|
||||||
const ret = findReturnStatement(handle.tree, fn_decl) orelse return null;
|
const ret = findReturnStatement(handle.tree, fn_decl) orelse return null;
|
||||||
if (ret.rhs) |rhs|
|
if (ret.rhs) |rhs| {
|
||||||
if (try resolveTypeOfNodeInternal(store, arena, .{
|
return try resolveTypeOfNodeInternal(store, arena, .{
|
||||||
.node = rhs,
|
.node = rhs,
|
||||||
.handle = handle,
|
.handle = handle,
|
||||||
}, bound_type_params)) |res_rhs| switch (res_rhs.node.id) {
|
}, bound_type_params);
|
||||||
.ContainerDecl => {
|
}
|
||||||
return res_rhs;
|
|
||||||
},
|
|
||||||
else => return null,
|
|
||||||
};
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user