cocoa-xu / evision

Evision: An OpenCV-Erlang/Elixir binding
https://evision.app
Apache License 2.0
322 stars 22 forks source link

Expand types in function specs #245

Open cocoa-xu opened 1 month ago

cocoa-xu commented 1 month ago

Classes like cv::Algorithm can have a few subclasses, and in the Evision.Algorithm module, functions that accepts cv:: Algorithm parameters are expecting Evision.Algorithm.t() in their type specs.

Currently, although subclasses will have their own copies of these functions from the parent classes with correct type specs, we can find all derived classes of a class, and expand the type specs to accept them.

For example, say we have class Foo, and class Bar and Buzz are derived from Foo, then we're expecting the following changes:

Before

@spec func(Evision.Foo.t()) :: nil

After

@spec func(Evision.Foo.t() | Evision.Bar.t() | Evision.Buzz.t()) :: nil

This issue is not urgent but definitely can help users, the language server and tools like dialyzer.