Stub's type might not match return type (subclass or union)

This commit is contained in:
Michael Miller 2022-03-12 11:08:58 -07:00
parent d891422b3a
commit 9b94245bd8
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF

View file

@ -23,7 +23,11 @@ module Spectator
{% if !method.abstract? %}
%stub.as(::Spectator::ValueStub(typeof(previous_def))).value
{% elsif method.return_type %}
%stub.as(::Spectator::ValueStub({{method.return_type}})).value
if %cast = %stub.as?(::Spectator::ValueStub({{method.return_type}}))
%cast.value
else
%stub.value.as({{method.return_type}})
end
{% else %}
%stub.value
{% end %}