This commit is contained in:
Douglas Eichelberger 2024-01-12 11:45:19 -08:00
parent 44e6b48fd7
commit 66aff2af7b

View File

@ -25,9 +25,7 @@ class Object
# False for method objects; # False for method objects;
# true otherwise. # true otherwise.
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def duplicable? def duplicable? = true
true
end
end end
class Method class Method
@ -36,9 +34,7 @@ class Method
# method(:puts).duplicable? # => false # method(:puts).duplicable? # => false
# method(:puts).dup # => TypeError: allocator undefined for Method # method(:puts).dup # => TypeError: allocator undefined for Method
sig { returns(FalseClass) } sig { returns(FalseClass) }
def duplicable? def duplicable? = false
false
end
end end
class UnboundMethod class UnboundMethod
@ -47,9 +43,7 @@ class UnboundMethod
# method(:puts).unbind.duplicable? # => false # method(:puts).unbind.duplicable? # => false
# method(:puts).unbind.dup # => TypeError: allocator undefined for UnboundMethod # method(:puts).unbind.dup # => TypeError: allocator undefined for UnboundMethod
sig { returns(FalseClass) } sig { returns(FalseClass) }
def duplicable? def duplicable? = false
false
end
end end
require "singleton" require "singleton"
@ -59,7 +53,5 @@ module Singleton
# #
# Class.new.include(Singleton).instance.dup # TypeError (can't dup instance of singleton # Class.new.include(Singleton).instance.dup # TypeError (can't dup instance of singleton
sig { returns(FalseClass) } sig { returns(FalseClass) }
def duplicable? def duplicable? = false
false
end
end end