[erlang-questions] Make dialyzer use -callback types in behaviour module

Bach Le thebullno1@REDACTED
Mon Aug 20 09:30:08 CEST 2018


Currently, `-callback` declaration only affects how dialyzer works on the
callback module. Those info are ignored in the behaviour module when a
dynamic call is made: `HandlerMod:callback_fun()`. Right now, I am
rewriting some behaviour specs and having dialyzer check the types would be
great.

I can think of two ways to do this:

* Make dialyzer consider all dynamic calls in a module that declare
`-callback` to be calls to the matching callback functions. I have no idea
about dialyzer's internal though.
* Create a parse transform that is only called when using dialyzer. Each
`-callback` will have a matching wrapper function e.g: `-callback
foo(number()) -> ok` will generate `
`'$call_foo'(module(), number()) -> ok`. All dynamic calls (e.g:
`HandlerMod:foo(42)`) will be rewritten to use those wrappers
(`'$call_foo'(HandlerMod, 42)`). IIRC, there are ways to pass compiler
options into dialyzer.

What are your thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180820/90b09962/attachment.htm>


More information about the erlang-questions mailing list