Hello,
I’m trying to play with supertypes but I’m encountering an issue so I made this MWE:
abstract type AbstractFoo{T} end
struct Foo{T} <: AbstractFoo{T}
x::T
end
So far so good. Now I would like to define a wrapper of Foo
that has the same parametric supertype as its wrapped object. That means I need access to the parametres of the type of the wrapped foo. Ideally I would be able to do this:
struct Bar{F <: AbstractFoo} <: supertype(F)
foo::F
end
But Julia does not allow this kind of stuff I recon. So I tried to access T
directly like so
struct Bar{F <: AbstractFoo{T}} <: AbstractFoo{T}
foo::F
end
which tells me that T
is not defined. How do I define it? Note that I use F <: AbstractFoo{T}
because I would like foo
to be any <: AbstractFoo
even though I defined only one here.