EDIT: In the example below I created an incorrect inner constructor. But the part of my question that remains of interest is why is an inner constructor needed at all? What are the features of this type definition that require this?
I ran into a problem today with defining a new type in a more complex way than I normally do and this led to no constructor being defined. I tried to specify my own inner constructor, but without success. Is this a limitation I’m unaware of or am I doing something wrong? (I can work around this but it feels like a hack.)
module M
abstract type A1{T} end
abstract type A2{T} end
struct B{S, T} <: A1{T} where {S <: A2{T}}
x::S
# new(x::S) where {S <: A2{T}} where {T} = B{S, T}(x)
# EDIT: correct constructor:
# B(x::S) where {S <: A2{T}} where {T} = new{S,T}(x)
end
struct C{T} <: A2{T}
x::T
end
end
methods(M.B)
The result of methods(...)
is the same with or without the inner constructor.