File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -428,7 +428,12 @@ def translate_struct_assign_decl(decl, rbs) #: void
428428 members : [ *attributes , new ] ,
429429 super_class : RBS ::AST ::Declarations ::Class ::Super . new (
430430 name : RBS ::TypeName . new ( name : :Struct , namespace : RBS ::Namespace . empty ) ,
431- args : [ RBS ::Types ::Bases ::Any . new ( location : nil ) ] ,
431+ args : [
432+ RBS ::Types ::Union . new (
433+ types : decl . each_attribute . map { |_ , attr | attr &.type || RBS ::Types ::Bases ::Any . new ( location : nil ) } . uniq ,
434+ location : nil
435+ )
436+ ] ,
432437 location : nil
433438 ) ,
434439 annotations : decl . class_annotations ,
Original file line number Diff line number Diff line change @@ -1011,7 +1011,7 @@ class Account
10111011
10121012 assert_equal <<~RBS , output
10131013 # Account record
1014- class Account < Struct[untyped ]
1014+ class Account < Struct[Integer | String ]
10151015 attr_accessor id(): Integer
10161016
10171017 attr_accessor email(): String
@@ -1029,7 +1029,7 @@ def self.new: (?name: untyped) -> instance
10291029 end
10301030 end
10311031
1032- class Item < Struct[untyped ]
1032+ class Item < Struct[String | Integer ]
10331033 attr_accessor sku(): String
10341034
10351035 attr_accessor price(): Integer
@@ -1041,7 +1041,7 @@ def self.new: (?String sku, ?Integer price) -> instance
10411041 # @rbs %a{rbs-inline:readonly-attributes=true}
10421042 %a{rbs-inline:new-args=required}
10431043 %a{rbs-inline:readonly-attributes=true}
1044- class User < Struct[untyped ]
1044+ class User < Struct[String ]
10451045 attr_reader name(): String
10461046
10471047 def self.new: (String name) -> instance
You can’t perform that action at this time.
0 commit comments