Search code examples
rubysorbet

Error when accessing singleton class of object (https://srb.help/3001)


When I access the singleton class of an object using the following code

(class << object; self; end)

The srb command raises an error:

class << EXPRESSION is only supported for class << self https://srb.help/3001

Due to special circumstances (proxy/mock object) I cannot call any methods on the object. The object especially is extremely unenthusiastic about being asked about singleton_class, instance eval, instance_exec or binding, so I need to use this expression.

How can I suppress this error? Wrapping the expression in T.unsafe did not help.


Solution

  • It looks like your best bet is to isolate this test (I assume it is due to the proxy/mock reference) in its own file and mark that file as typed: ignore. Since the error is a processing stage error (specifically, 3xxx errors are from the desugaring stage where code is being rewritten for simpler representation), it won't be suppressible with T.unsafe or other methods.