diff options
| -rw-r--r-- | src/server/generics.odin | 26 | ||||
| -rw-r--r-- | tests/hover_test.odin | 22 |
2 files changed, 32 insertions, 16 deletions
diff --git a/src/server/generics.odin b/src/server/generics.odin index 7eea7a2..33543cf 100644 --- a/src/server/generics.odin +++ b/src/server/generics.odin @@ -431,19 +431,21 @@ resolve_generic_function :: proc { } resolve_generic_function_ast :: proc(ast_context: ^AstContext, proc_lit: ast.Proc_Lit) -> (Symbol, bool) { - if proc_lit.type.params == nil { + if ast_context.call == nil { return Symbol{}, false } - if proc_lit.type.results == nil { - return Symbol{}, false + params: []^ast.Field + if proc_lit.type.params != nil { + params = proc_lit.type.params.list } - if ast_context.call == nil { - return Symbol{}, false + results: []^ast.Field + if proc_lit.type.results != nil { + results = proc_lit.type.results.list } - return resolve_generic_function_symbol(ast_context, proc_lit.type.params.list, proc_lit.type.results.list) + return resolve_generic_function_symbol(ast_context, params, results) } @@ -455,14 +457,6 @@ resolve_generic_function_symbol :: proc( Symbol, bool, ) { - if params == nil { - return {}, false - } - - if results == nil { - return {}, false - } - if ast_context.call == nil { return {}, false } @@ -701,7 +695,7 @@ resolve_poly_struct :: proc(ast_context: ^AstContext, b: ^SymbolStructValueBuild poly_map: map[string]^ast.Expr, symbol_value_builder: ^SymbolStructValueBuilder, parent: ^ast.Node, - parent_proc: ^ast.Proc_Type, + parent_proc: ^ast.Proc_Type, i: int, poly_index: int, } @@ -755,7 +749,7 @@ resolve_poly_struct :: proc(ast_context: ^AstContext, b: ^SymbolStructValueBuild } #partial switch v in node.derived { - case ^ast.Array_Type, ^ast.Dynamic_Array_Type, ^ast.Selector_Expr, ^ast.Pointer_Type: + case ^ast.Array_Type, ^ast.Dynamic_Array_Type, ^ast.Selector_Expr, ^ast.Pointer_Type: data.parent = node case ^ast.Proc_Type: data.parent_proc = v diff --git a/tests/hover_test.odin b/tests/hover_test.odin index d8e18be..c64f328 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -4408,6 +4408,28 @@ ast_hover_parapoly_elem_overloaded_proc_multiple_options :: proc(t: ^testing.T) } test.expect_hover(t, &source, "test.foo: proc {\n\tfoo_int :: proc(i: int),\n\tfoo_string :: proc(s: string),\n}") } + +@(test) +ast_hover_overloaded_proc_slice_dynamic_array :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + + foo :: proc { + foo_slice, + foo_dynamic, + } + + foo_dynamic :: proc(array: $A/[dynamic]$T) {} + foo_slice :: proc(array: $A/[]$T) {} + + main :: proc() { + foos: [dynamic]int + f{*}oo(foos) + } + `, + } + test.expect_hover(t, &source, "test.foo: proc(array: $A/[dynamic]$T)") +} /* Waiting for odin fix |