# No method matching ::Type{A{\<:Real}}, only ::Type{A{T}} where {T\<:Real}

**URL:** <https://discourse.julialang.org/t/no-method-matching-type-a-real-only-type-a-t-where-t-real/54673>\
**Category:** General Usage\
**Created:** [February 5, 2021, 7:42am UTC](https://discourse.julialang.org/t/no-method-matching-type-a-real-only-type-a-t-where-t-real/54673 "2021-02-05T07:42:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikirill](https://avatars.discourse-cdn.com/v4/letter/i/43a26b/32.png) [@ikirill](https://discourse.julialang.org/u/ikirill)\
**Post date:** [February 5, 2021, 7:42am UTC](https://discourse.julialang.org/t/no-method-matching-type-a-real-only-type-a-t-where-t-real/54673/1 "2021-02-05T07:42:01Z")

</div>

I can’t find this in the julia manual right now, but I’d always assumed that using `<:Real` inside a type on the left-hand side of a function definition `f(x::A{<:Real})` is just an alias to `f(x::A{T}) where {T<:Real}`. But with julia 1.5.3 I’m getting a method error when trying to use `::Type{A{<:Real}}`.

```julia
julia> struct A{T}; x::T; end

julia> f(::Type{A{<:Real}}) = true
f (generic function with 1 method)

julia> f(x::A) = f(typeof(x))
f (generic function with 2 methods)

julia> f(A(1))
ERROR: MethodError: no method matching f(::Type{A{Int64}})
Closest candidates are:
  f(::Type{A{var"#s1"} where var"#s1"<:Real}) at REPL[2]:1
  f(::A) at REPL[3]:1
Stacktrace:
 [1] f(::A{Int64}) at ./REPL[3]:1
 [2] top-level scope at REPL[4]:1

julia> f(::Type{A{T}}) where T = 123
f (generic function with 3 methods)

julia> f(A(1))
123

julia> f(::Type{A{T}}) where {T<:Real} = 456
f (generic function with 4 methods)

julia> f(A(1))
456

julia> 

```

Is there a reason for this? What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [February 5, 2021, 8:22am UTC](https://discourse.julialang.org/t/no-method-matching-type-a-real-only-type-a-t-where-t-real/54673/2 "2021-02-05T08:22:40Z")

</div>

> [@ikirill](#):
>
> `f(::Type{A{<:Real}})`

You should have written  
`(::Type{<:A{<:Real}})`

Because `A{<:Real}` is an UnionAll which is a form of abstract type.  
And `A{Int}` is a subtype of it.  
Not equal to it

---

<div class="post-metadata">

**Author:** ![ikirill](https://avatars.discourse-cdn.com/v4/letter/i/43a26b/32.png) [@ikirill](https://discourse.julialang.org/u/ikirill)\
**Post date:** [February 5, 2021, 8:40am UTC](https://discourse.julialang.org/t/no-method-matching-type-a-real-only-type-a-t-where-t-real/54673/3 "2021-02-05T08:40:44Z")

</div>

I get it now, thanks!
