File tree 1 file changed +8
-13
lines changed
src/main/ruby/truffleruby/core 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -33,19 +33,14 @@ class << self
33
33
alias_method :subclass_new , :new
34
34
end
35
35
36
- def self . new ( klass_name = nil , *attrs , keyword_init : nil , &block )
37
- if klass_name
38
- if Primitive . is_a? ( klass_name , Symbol ) # Truffle: added to avoid exception and match MRI
39
- attrs . unshift klass_name
40
- klass_name = nil
41
- else
42
- begin
43
- klass_name = StringValue klass_name
44
- rescue TypeError
45
- attrs . unshift klass_name
46
- klass_name = nil
47
- end
48
- end
36
+ def self . new ( *attrs , keyword_init : nil , &block )
37
+ klass_name = nil
38
+
39
+ first = attrs [ 0 ]
40
+ if attrs . size >= 1 && !Primitive . is_a? ( first , Symbol )
41
+ # nil check because Struct.new(nil, :foo) is valid
42
+ klass_name = StringValue ( first ) unless Primitive . nil? ( first )
43
+ attrs . shift
49
44
end
50
45
51
46
attrs = attrs . map { |a | Truffle ::Type . symbol_or_string_to_symbol ( a ) }
You can’t perform that action at this time.
0 commit comments