diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-09-22 19:34:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-22 19:34:24 -0400 |
| commit | d4e3c3a58d3ae0c5d42ef76b3de037fc5b720f77 (patch) | |
| tree | 2b72fbcdf647c19131b899407496d8413c982733 | |
| parent | 7f68dbed834baf3bd697d47c59ac95e914a90fab (diff) | |
| parent | c72350d844e15c530e0b3da1ff2faf6e91dfa7c2 (diff) | |
Merge pull request #1041 from BradLewis/feat/poly-map-type
Substitute poly types for generic maps
| -rw-r--r-- | src/server/generics.odin | 11 | ||||
| -rw-r--r-- | tests/hover_test.odin | 19 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/server/generics.odin b/src/server/generics.odin index 374ffc9..6f0be73 100644 --- a/src/server/generics.odin +++ b/src/server/generics.odin @@ -452,6 +452,17 @@ find_and_replace_poly_type :: proc(expr: ^ast.Expr, poly_map: ^map[string]^ast.E v.pos.file = expr.pos.file v.end.file = expr.end.file } + case ^ast.Map_Type: + if expr, ok := get_poly_map(v.key, poly_map); ok { + v.key = expr + v.pos.file = expr.pos.file + v.end.file = expr.end.file + } + if expr, ok := get_poly_map(v.value, poly_map); ok { + v.value = expr + v.pos.file = expr.pos.file + v.end.file = expr.end.file + } } return visitor diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 562a2d6..3063d13 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -4980,6 +4980,25 @@ ast_hover_proc_impl :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.foo :: proc(a: int) -> int") } + +@(test) +ast_hover_proc_overload_generic_map :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + clear_dynamic_array :: proc "contextless" (array: ^$T/[dynamic]$E) {} + clear_map :: proc "contextless" (m: ^$T/map[$K]$V) {} + clear :: proc{ + clear_dynamic_array, + clear_map, + } + main :: proc() { + foo: map[int]string + c{*}lear(&foo) + } + `, + } + test.expect_hover(t, &source, "test.clear :: proc(m: ^$T/map[$K]$V)") +} /* Waiting for odin fix |