Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/server/analysis.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
40 changes: 40 additions & 0 deletions tests/hover_test.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
Loading