From 7149ef7df572eddd3037e0e2a0ee922a66332ec5 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 26 Jan 2023 16:12:54 -0700 Subject: [PATCH] Revert "Compiler bug when using unsafe_as" This reverts commit cb89589155cedc89dd9faeeca864e97266284edd. --- src/spectator/mocks/stubbable.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spectator/mocks/stubbable.cr b/src/spectator/mocks/stubbable.cr index 6c5f7ad..3385ad4 100644 --- a/src/spectator/mocks/stubbable.cr +++ b/src/spectator/mocks/stubbable.cr @@ -550,7 +550,7 @@ module Spectator # Check if nil was returned by the stub and if its okay to return it. if %value.nil? && %type.nilable? # Value was nil and nil is allowed to be returned. - %cast.unsafe_as({{type}}) + %type.cast(%cast) elsif %cast.nil? # The stubbed value was something else entirely and cannot be cast to the return type. raise TypeCastError.new("#{_spectator_stubbed_name} received message #{ {{call}} } and is attempting to return a `#{%value.class}`, but returned type must be `#{%type}`.")