- (Simplified) It doesn’t work because
Pcould already match a concrete type. For example,Pcould beArray{Float64,1}, soP{T}is not valid. - Use
instead.struct MyType{T <: AbstractFloat, P <: AbstractArray{T}} x::T data::P end
Note also that in your original example, data::Array{T} is not a concrete type (the second type parameter is missing), so this would slow down your code.