Skip to content

Commit 58fe5ec

Browse files
nirvdrumeregon
authored andcommitted
Undefine allocator for Polyglot::ForeignException
* The same way as for Integer, Symbol, etc. * Polyglot::ForeignObject.new would otherwise return a RubyBasicObject which is not actually a foreign object, and that would lead to confusion. * #new is overridden by InstantiableTrait and that works fine for InteropLibrary#isInstantiable() foreign objects.
1 parent a7d2155 commit 58fe5ec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/ruby/truffleruby/core/truffle/polyglot.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,14 @@ def self.__allocate__
546546
class ForeignException < Exception # rubocop:disable Lint/InheritException
547547
include ObjectTrait
548548
include ExceptionTrait
549+
550+
class << self
551+
undef_method :new
552+
end
553+
554+
def self.__allocate__
555+
raise TypeError, "allocator undefined for #{self}"
556+
end
549557
end
550558
# endregion
551559
end

0 commit comments

Comments
 (0)