Julia LSP on parametric structs

Hi,

I had a question about getting IntelliSense working for a defined object.

 abstract type Shape end

struct Square <: Shape
    s::Float64
end

struct Rectangle <: Shape
    b::Float64
    w::Float64
end

struct Box{T<:Shape}
    shape::T
    length::Float64
end

shape = Square(5)

box = Box{Square}(shape, 6)

box.shape.

When I type box. I get the following IntelliSense:
image

However, I do not get this when I do box.shape.. Is there any way to get IntelliSense here or does it have to be a concrete type in the definition of the Box struct definition?

1 Like

Type inference in Julia can go through arbitrary code. Here, the IDE successfully inferred the type of your box as Box, but not necessarily its parameter. IDE has to be responsive, even before the code is even run, so it can’t infer types as deep as the compiler can.

I would bet a few loafs of bread that this sort of thing could be inferred a few levels deep with reasonable latency.