Skip to content

Commit 96d478f

Browse files
authored
Merge pull request #304 from julia-vscode/is974
hand aliased imports
2 parents cc1008e + bb8b4eb commit 96d478f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/imports.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ function _get_field(par, arg, state)
161161
return _get_field(par.val, arg, state)
162162
elseif par.val isa EXPR && CSTParser.defines_module(par.val) && scopeof(par.val) isa Scope
163163
return _get_field(scopeof(par.val), arg, state)
164+
elseif par.val isa EXPR && isassignment(par.val)
165+
if hasref(par.val.args[2])
166+
return _get_field(refof(par.val.args[2]), arg, state)
167+
elseif is_getfield_w_quotenode(par.val.args[2])
168+
return _get_field(refof_maybe_getfield(par.val.args[2]), arg, state)
169+
end
164170
elseif par.val isa SymbolServer.ModuleStore
165171
return _get_field(par.val, arg, state)
166172
end

test/runtests.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,3 +1755,17 @@ end
17551755
""")
17561756
@test isempty(StaticLint.collect_hints(cst, server))
17571757
end
1758+
1759+
@testset "aliased import: #974" begin
1760+
cst = parse_and_pass("""
1761+
const CC = Core.Compiler
1762+
import .CC: div
1763+
""")
1764+
@test isempty(StaticLint.collect_hints(cst, server))
1765+
1766+
cst = parse_and_pass("""
1767+
const C = Core
1768+
import .C: div
1769+
""")
1770+
@test isempty(StaticLint.collect_hints(cst, server))
1771+
end

0 commit comments

Comments
 (0)