Compile-time recognition of parametric types e.g. K{T} for any K

This is a type of dispatch which is not allowed in Julia. The correct way to do it is indeed exactly the second thing you mention, but I didn’t understand this part:

Do you mean that in this case its its not inferred, so dispatch will happen at runtime? That’s not what I’m seeing. After a small fix to your fun by changing ^ to a .^, it looks everything is inferred hence dispatch is happening at compile time:

julia> function fun(x::AbstractGeneric{T}, z::AbstractArray{T}) where {T <: AbstractFloat}
         return sum((myMethod(x) .- z).^2)
       end
fun (generic function with 1 method)

julia> @code_warntype fun(MyType(1.), [1.,2,3])
Variables
  #self#::Core.Compiler.Const(fun, false)
  x::MyType{Float64}
  z::Array{Float64,1}

Body::Float64
1 ─ %1 = Main.myMethod(x)::Float64
...