From 932350baa98fc3a040a714d974ec0654794acef4 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Sat, 6 Sep 2025 10:37:18 -0400 Subject: Store the identifier rather than the specialization for poly types when the types match --- src/server/generics.odin | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/server/generics.odin') diff --git a/src/server/generics.odin b/src/server/generics.odin index 33543cf..cec9926 100644 --- a/src/server/generics.odin +++ b/src/server/generics.odin @@ -61,7 +61,20 @@ resolve_poly :: proc( return true } else if type != nil { if ident, ok := unwrap_ident(type); ok { - save_poly_map(ident, specialization, poly_map) + call_node_id := reflect.union_variant_typeid(call_node.derived) + specialization_id := reflect.union_variant_typeid(specialization.derived) + if call_node_id == specialization_id { + // if the specialization type matches the type of the parameter passed to the proc + // we store that rather than the specialization so we can follow it correctly + // for things like `textDocument/typeDefinition` + save_poly_map( + ident, + make_ident_ast(ast_context, call_node.pos, call_node.end, call_symbol.name), + poly_map, + ) + } else { + save_poly_map(ident, specialization, poly_map) + } } } -- cgit v1.2.3