I have the following definitions (clipping out parts not relevant):
abstract class Change
...
def initialize(@model : ModelInterface, @unit : Unit)
end
...
abstract class NoOption < Change
...
end
...
end
class Change::Outline < Change::NoOption
...
end
module ModelInterface
...
end
class LanguageModel
include ModelInterface
...
end
abstract class Unit
...
end
I have some code that looks like:
@change_class.as(Change::NoOption).new @model, @unit
When I attempt to compile I get the following error:
78 | @change_class.as(Change::NoOption).new @model, @unit
^--
Error: no overload matches 'Change::Outline#new' with types LanguageModel, Unit+
Overloads are:
- Change.new(model : ModelInterface, unit : Unit)
Iām not clear on what the mismatch is. My constructor is defined as taking a ModelInterface
and some subclass of Unit
. The error indicates I am sending it a LanguageModel
(which ModelInterface
is mixed into) and some subclass of Unit
. What I am I missing? Those seem to match.