# Check that every subtype has a method defined

**URL:** https://discourse.julialang.org/t/check-that-every-subtype-has-a-method-defined/81811
**Category:** General Usage
**Created:** [May 27, 2022, 7:26pm UTC](https://discourse.julialang.org/t/check-that-every-subtype-has-a-method-defined/81811 "2022-05-27T19:26:12Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Satvik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/satvik/32/20486_2.png) [@Satvik](https://discourse.julialang.org/u/Satvik)
#### Post date: [May 27, 2022, 7:26pm UTC](https://discourse.julialang.org/t/check-that-every-subtype-has-a-method-defined/81811/1 "2022-05-27T19:26:12Z")

</div>

Say I have an abstract type with some structs, and I want to make sure some method is defined on every subtype. For example:

```julia
abstract type Shape end
struct Square <: Shape
    length::Float64
end

struct Circle <: Shape
    radius::Float64
end

area(s::Square) = s.length * s.length
area(c::Circle) = c.radius * c.radius * pi

area_plus(s::Square, y::Float64) = area(s) + y
area_plus(c::Circle, x::Float64, y::Float64) = area(c) + x + y

area_times(s::Square, y::Float) = area(s) * y

```

Then I’d like to be able to write a function `method_exists` so that

```julia
all_shapes = [Square, Circle]
method_exists(area, all_shapes) # == true
method_exists(area_plus, all_shapes) # == true
method_exists(area_times, all_shapes) # == false

```

How can I write something that checks for this? `hasmethod` gets me part of the way there, but it requires the whole signature of the function so I couldn’t find a way to apply it to something like `area_plus`.

(In real life, we have several dozen “Shapes” and different researchers writing new ones, so I want a quick way to test that each Shape is at least well-formed.)
