mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add return type restriction
This overrides the previous definition which doesn't have a restriction. This is a workaround for the inability to infer a stub's return type.
This commit is contained in:
parent
b3f98cd50c
commit
231323bbf1
2 changed files with 7 additions and 6 deletions
|
@ -163,7 +163,7 @@ module Spectator
|
|||
# The value of the stub could be returned as-is.
|
||||
# This may produce a "bloated" union of all known stub types,
|
||||
# and generally causes more annoying problems.
|
||||
raise TypeCastError.new("#{_spectator_stubbed_name} received message #{%call} but cannot resolve the return type.")
|
||||
raise TypeCastError.new("#{_spectator_stubbed_name} received message #{%call} but cannot resolve the return type. Please add a return type restriction.")
|
||||
{% end %}
|
||||
else
|
||||
# A stub wasn't found, invoke the type-specific fallback logic.
|
||||
|
@ -239,13 +239,14 @@ module Spectator
|
|||
# Finding a suitable stub is delegated to the type including the `Stubbable` module.
|
||||
if %stub = _spectator_find_stub(%call)
|
||||
{% if method.return_type %}
|
||||
# Return type was provided with a restriction.
|
||||
_spectator_cast_stub_value(%stub, %call, {{method.return_type}}, {{method.return_type.resolve >= Nil}})
|
||||
{% else %}
|
||||
# Stubbed method is abstract and there's no return type annotation.
|
||||
# The value of the stub could be returned as-is.
|
||||
# This may produce a "bloated" union of all known stub types,
|
||||
# and generally causes more annoying problems.
|
||||
raise TypeCastError.new("#{_spectator_stubbed_name} received message #{%call} but cannot resolve the return type.")
|
||||
raise TypeCastError.new("#{_spectator_stubbed_name} received message #{%call} but cannot resolve the return type. Please add a return type restriction.")
|
||||
{% end %}
|
||||
else
|
||||
# A stub wasn't found, invoke the type-specific fallback logic.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue