diff --git a/src/server/analysis.odin b/src/server/analysis.odin index ab2902f0..fc2a3d7a 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -406,8 +406,13 @@ resolve_base_symbol :: proc(ast_context: ^AstContext, symbol: Symbol, bypass_dis if !ok { return symbol } - if resolved.name == symbol.name && resolved.pkg == symbol.pkg && resolved.type == symbol.type { - return symbol + if resolved.type == symbol.type { + if resolved.name == symbol.name && resolved.pkg == symbol.pkg { + return symbol + } + // NOTE: This path causes alias of struct, unions, bit_sets etc. + // to resolve to anonymous symbols (e.g. struct{}) + reset_ast_context(ast_context) } return resolve_base_symbol(ast_context, resolved, bypass_distinct) } diff --git a/tests/hover_test.odin b/tests/hover_test.odin index df1e2e3d..aa925542 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -6877,3 +6877,43 @@ ast_hover_test_with_mulitple_files :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.Bar :: struct{}") } + +@(test) +ast_hover_overload_resolve_aliased_arguments :: proc(t: ^testing.T) { + packages := make([dynamic]test.Package, context.temp_allocator) + + append( + &packages, + test.Package { + pkg = "pkg1", + source = `package pkg1 + Foo :: struct{} + Bar :: proc(table: Foo) {} + `, + }, + test.Package { + pkg = "pkg2", + source = `package pkg2 + import "pkg1" + Foo :: pkg1.Foo + `, + }, + ) + source := test.Source { + main = `package test + import "pkg1" + import "pkg2" + + Bar :: proc { + pkg1.Bar, + } + + main :: proc() { + Ba{*}r(pkg2.Foo{}) + } + `, + packages = packages[:], + } + + test.expect_hover(t, &source, "pkg1.Bar :: proc(table: Foo)") +}