ericphanson / ExplicitImports.jl

Developer tooling for Julia namespace management: detecting implicit imports, improper explicit imports, and improper qualified accesses
https://ericphanson.github.io/ExplicitImports.jl/
MIT License
62 stars 2 forks source link

False positive with type parameter that shadows name from imported package #34

Closed fredrikekre closed 2 months ago

fredrikekre commented 2 months ago

Source:

module TestPackage

using LinearAlgebra

struct Bar{QR}
    x::QR
end

end

Gives:

Module TestPackage is relying on implicit imports for 2 names. These could be explicitly imported as follows:

```julia
using LinearAlgebra: LinearAlgebra # used at /home/fredrik/dev/TestPackage/src/TestPackage.jl:3:7
using LinearAlgebra: QR # used at /home/fredrik/dev/TestPackage/src/TestPackage.jl:5:12
ericphanson commented 2 months ago

Probably I need to handle struct definitions similarly to functions and identify the "arguments" (i.e. the type parameters and names), like https://github.com/ericphanson/ExplicitImports.jl/blob/87dff774fa22df7c21f60b47efe8d6616b1f29c4/src/get_names_used.jl#L93

We might want to handle things like @kwdef where the RHS of the = is a global though.