Never mind, after a re-re-read of the docs and a few other resources, it 
finally clicked :) 

type SQLFoo{T<:AbstractModel}
  model_name::Type{T}
  bar::Bool


  SQLFoo(model_name, bar) = new(model_name, bar)
end
SQLFoo{T<:AbstractModel}(model_name::Type{T}; bar::Bool = true) = SQLFoo{T}(
model_name, bar)


vineri, 10 iunie 2016, 20:21:18 UTC+2, Adrian Salceanu a scris:
>
> Hi,
>
> I don't know how to code this, any help appreciated. 
>
> I want to have a concrete type that has a field referencing any of the 
> subtypes of an(other) abstract type. How would I write that? 
>
> This is one of my many attempts: 
>
> type SQLFoo{T <: AbstractModel}
>   model_name::Type{T}
>
>
>   SQLFoo(model_name) = new(model_name)
> end
>
>
> julia> issubtype(Repo, AbstractModel)
> true
>
> julia> SQLFoo(Repo)
> ERROR: MethodError: `convert` has no method matching convert(::Type{SQLFoo
> {T<:AbstractModel}}, ::Type{Repo})
> This may have arisen from a call to the constructor SQLFoo{T<:
> AbstractModel}(...),
> since type constructors fall back to convert methods.
> Closest candidates are:
>   call{T}(::Type{T}, ::Any)
>   convert{T}(::Type{T}, ::T)
>  in call at essentials.jl:56
>
>
> Thanks,
> -- Adrian
>

Reply via email to