mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Remove custom handling of NoReturn
This commit is contained in:
parent
a395e26bae
commit
b07e13aeb4
1 changed files with 2 additions and 24 deletions
|
@ -82,18 +82,7 @@ module Spectator::Mocks
|
|||
%call = ::Spectator::Mocks::MethodCall.new({{name.symbolize}}, %args)
|
||||
%harness.mocks.record_call(self, %call)
|
||||
if (%stub = %harness.mocks.find_stub(self, %call))
|
||||
if typeof({{original}}) == NoReturn
|
||||
# NOTE: This may break at some point if the Crystal compiler gets smarter.
|
||||
# The `nil` after raise changes the return type of the method from `NoReturn` to `Nil`.
|
||||
# Technically, the `nil` will never be reached and if the compiler realizes it,
|
||||
# the return type could become `NoReturn`
|
||||
return %stub.call!(%args) do
|
||||
raise "Cannot call original implementation of {{name}} - it won't return."
|
||||
nil
|
||||
end
|
||||
else
|
||||
return %stub.call!(%args) { {{original}} }
|
||||
end
|
||||
return %stub.call!(%args) { {{original}} }
|
||||
end
|
||||
|
||||
{% if body && !body.is_a?(Nop) || return_type.is_a?(ArrayLiteral) %}
|
||||
|
@ -112,18 +101,7 @@ module Spectator::Mocks
|
|||
%call = ::Spectator::Mocks::MethodCall.new({{name.symbolize}}, %args)
|
||||
%harness.mocks.record_call(self, %call)
|
||||
if (%stub = %harness.mocks.find_stub(self, %call))
|
||||
if typeof({{original}}) == NoReturn
|
||||
# NOTE: This may break at some point if the Crystal compiler gets smarter.
|
||||
# The `nil` after raise changes the return type of the method from `NoReturn` to `Nil`.
|
||||
# Technically, the `nil` will never be reached and if the compiler realizes it,
|
||||
# the return type could become `NoReturn`
|
||||
return %stub.call!(%args) do
|
||||
raise "Cannot call original implementation of {{name}} - it won't return."
|
||||
nil
|
||||
end
|
||||
else
|
||||
return %stub.call!(%args) { {{original}} { |*%ya| yield *%ya } }
|
||||
end
|
||||
return %stub.call!(%args) { {{original}} { |*%ya| yield *%ya } }
|
||||
end
|
||||
|
||||
{% if body && !body.is_a?(Nop) || return_type.is_a?(ArrayLiteral) %}
|
||||
|
|
Loading…
Reference in a new issue