Pass the correct handle to hasSelfParam in bound type parameter evaluation code
This commit is contained in:
parent
b03fb5ffe3
commit
902c91e98f
@ -702,7 +702,6 @@ pub fn resolveTypeOfNodeInternal(
|
|||||||
try state.resolve_trail.append(arena.child_allocator, node_handle);
|
try state.resolve_trail.append(arena.child_allocator, node_handle);
|
||||||
defer _ = state.resolve_trail.pop();
|
defer _ = state.resolve_trail.pop();
|
||||||
|
|
||||||
|
|
||||||
const main_tokens = tree.nodes.items(.main_token);
|
const main_tokens = tree.nodes.items(.main_token);
|
||||||
const node_tags = tree.nodes.items(.tag);
|
const node_tags = tree.nodes.items(.tag);
|
||||||
const datas = tree.nodes.items(.data);
|
const datas = tree.nodes.items(.data);
|
||||||
@ -770,8 +769,8 @@ pub fn resolveTypeOfNodeInternal(
|
|||||||
if (field.ast.type_expr == 0) return null;
|
if (field.ast.type_expr == 0) return null;
|
||||||
const field_type = .{ .node = field.ast.type_expr, .handle = handle };
|
const field_type = .{ .node = field.ast.type_expr, .handle = handle };
|
||||||
|
|
||||||
const typ = (try resolveTypeOfNodeInternal(store, arena, field_type, bound_type_params))
|
const typ = (try resolveTypeOfNodeInternal(store, arena, field_type, bound_type_params)) orelse
|
||||||
orelse return null;
|
return null;
|
||||||
return typ.instanceTypeVal();
|
return typ.instanceTypeVal();
|
||||||
},
|
},
|
||||||
.call,
|
.call,
|
||||||
@ -787,9 +786,8 @@ pub fn resolveTypeOfNodeInternal(
|
|||||||
const call = callFull(tree, node, ¶ms) orelse unreachable;
|
const call = callFull(tree, node, ¶ms) orelse unreachable;
|
||||||
|
|
||||||
const callee = .{ .node = call.ast.fn_expr, .handle = handle };
|
const callee = .{ .node = call.ast.fn_expr, .handle = handle };
|
||||||
const decl =
|
const decl = (try resolveTypeOfNodeInternal(store, arena, callee, bound_type_params)) orelse
|
||||||
(try resolveTypeOfNodeInternal(store, arena, callee, bound_type_params))
|
return null;
|
||||||
orelse return null;
|
|
||||||
|
|
||||||
if (decl.type.is_type_val) return null;
|
if (decl.type.is_type_val) return null;
|
||||||
const decl_node = switch (decl.type.data) {
|
const decl_node = switch (decl.type.data) {
|
||||||
@ -805,7 +803,7 @@ pub fn resolveTypeOfNodeInternal(
|
|||||||
// TODO: Back-parse to extract the self argument?
|
// TODO: Back-parse to extract the self argument?
|
||||||
var it = fn_decl.iterate(decl.handle.tree);
|
var it = fn_decl.iterate(decl.handle.tree);
|
||||||
if (token_tags[call.ast.lparen - 2] == .period) {
|
if (token_tags[call.ast.lparen - 2] == .period) {
|
||||||
if (try hasSelfParam(arena, store, handle, fn_decl)) {
|
if (try hasSelfParam(arena, store, decl.handle, fn_decl)) {
|
||||||
_ = it.next();
|
_ = it.next();
|
||||||
expected_params -= 1;
|
expected_params -= 1;
|
||||||
}
|
}
|
||||||
@ -819,10 +817,14 @@ pub fn resolveTypeOfNodeInternal(
|
|||||||
if (!isMetaType(decl.handle.tree, decl_param.type_expr))
|
if (!isMetaType(decl.handle.tree, decl_param.type_expr))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const argument = .{.node = call.ast.params[i], .handle = handle};
|
const argument = .{ .node = call.ast.params[i], .handle = handle };
|
||||||
const argument_type =
|
const argument_type = (try resolveTypeOfNodeInternal(
|
||||||
(try resolveTypeOfNodeInternal(store, arena, argument, bound_type_params))
|
store,
|
||||||
orelse continue;
|
arena,
|
||||||
|
argument,
|
||||||
|
bound_type_params,
|
||||||
|
)) orelse
|
||||||
|
continue;
|
||||||
if (!argument_type.type.is_type_val) continue;
|
if (!argument_type.type.is_type_val) continue;
|
||||||
|
|
||||||
_ = try bound_type_params.put(decl_param, argument_type);
|
_ = try bound_type_params.put(decl_param, argument_type);
|
||||||
@ -2317,15 +2319,15 @@ fn resolveUse(
|
|||||||
|
|
||||||
for (uses) |use| {
|
for (uses) |use| {
|
||||||
const expr = .{ .node = handle.tree.nodes.items(.data)[use.*].lhs, .handle = handle };
|
const expr = .{ .node = handle.tree.nodes.items(.data)[use.*].lhs, .handle = handle };
|
||||||
const expr_type_node = (try resolveTypeOfNode(store, arena, expr))
|
const expr_type_node = (try resolveTypeOfNode(store, arena, expr)) orelse
|
||||||
orelse continue;
|
continue;
|
||||||
|
|
||||||
const expr_type = .{
|
const expr_type = .{
|
||||||
.node = switch (expr_type_node.type.data) {
|
.node = switch (expr_type_node.type.data) {
|
||||||
.other => |n| n,
|
.other => |n| n,
|
||||||
else => continue,
|
else => continue,
|
||||||
},
|
},
|
||||||
.handle = expr_type_node.handle
|
.handle = expr_type_node.handle,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (try lookupSymbolContainer(store, arena, expr_type, symbol, false)) |candidate| {
|
if (try lookupSymbolContainer(store, arena, expr_type, symbol, false)) |candidate| {
|
||||||
|
Loading…
Reference in New Issue
Block a user