Fetching defined types in compile time

Guys, I have a library that contains a macro that defines a @type t only if it is not defined.

In order to check if the type was already defined at compile time I was doing a Module.get_attribute(SomeModule, :type) and checking if any of it was a :t.

In order to do that in 1.6.X I used this code https://github.com/bamorim/exchema/blob/master/lib/exchema/notation/typespec.ex#L8-L12

However, it is breaking on 1.7.X because Module.get_attribute(SomeModule, :type) now returns nil (it was running on a before_compile macro).

What is an alternative way to get the defined typespecs?

Try:

Module.defines_type?({:t, 0})
1 Like

Thanks! It worked
https://travis-ci.org/bamorim/exchema/builds/416084594?utm_source=github_status&utm_medium=notification