From 14a69a2debca40ac8283dd9a37ece95885d6942f Mon Sep 17 00:00:00 2001 From: nick evans Date: Sat, 26 Apr 2025 15:28:00 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Check=20for=20Ractor=20(for=20JR?= =?UTF-8?q?uby,=20TruffleRuby)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the same code I used in the `v0.4-stable` backport. I didn't use it in the main branch because the minimum ruby version is 3.1. But that breaks when JRuby and TruffleRuby try to `require "net/imap"`. Fixes #452. --- lib/net/imap/config/attr_type_coercion.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/net/imap/config/attr_type_coercion.rb b/lib/net/imap/config/attr_type_coercion.rb index 264bc63a8..f992ce9aa 100644 --- a/lib/net/imap/config/attr_type_coercion.rb +++ b/lib/net/imap/config/attr_type_coercion.rb @@ -28,7 +28,11 @@ def self.included(mod) end private_class_method :included - def self.safe(...) = Ractor.make_shareable nil.instance_eval(...).freeze + if defined?(Ractor.make_shareable) + def self.safe(...) Ractor.make_shareable nil.instance_eval(...).freeze end + else + def self.safe(...) nil.instance_eval(...).freeze end + end private_class_method :safe Types = Hash.new do |h, type| type => Proc | nil; safe{type} end