@@ -959,16 +959,44 @@ def to_s
959959 end
960960 end
961961
962+ class ForwardingParam
963+ attr_reader :location
964+
965+ def initialize ( location :)
966+ @location = location
967+ end
968+
969+ def ==( other )
970+ other . is_a? ( ForwardingParam )
971+ end
972+
973+ alias eql? ==
974+
975+ def hash
976+ self . class . hash
977+ end
978+
979+ def to_json ( state = nil )
980+ json = { } #: Hash[Symbol, untyped]
981+ json . to_json ( state )
982+ end
983+
984+ def to_s
985+ "..."
986+ end
987+ end
988+
962989 attr_reader :required_positionals
963990 attr_reader :optional_positionals
964991 attr_reader :rest_positionals
965992 attr_reader :trailing_positionals
966993 attr_reader :required_keywords
967994 attr_reader :optional_keywords
968995 attr_reader :rest_keywords
996+ attr_reader :forwarding
969997 attr_reader :return_type
970998
971- def initialize ( required_positionals :, optional_positionals :, rest_positionals :, trailing_positionals :, required_keywords :, optional_keywords :, rest_keywords :, return_type :)
999+ def initialize ( required_positionals :, optional_positionals :, rest_positionals :, trailing_positionals :, required_keywords :, optional_keywords :, rest_keywords :, return_type :, forwarding : nil )
9721000 @return_type = return_type
9731001 @required_positionals = required_positionals
9741002 @optional_positionals = optional_positionals
@@ -977,6 +1005,7 @@ def initialize(required_positionals:, optional_positionals:, rest_positionals:,
9771005 @required_keywords = required_keywords
9781006 @optional_keywords = optional_keywords
9791007 @rest_keywords = rest_keywords
1008+ @forwarding = forwarding
9801009 end
9811010
9821011 def ==( other )
@@ -988,6 +1017,7 @@ def ==(other)
9881017 other . required_keywords == required_keywords &&
9891018 other . optional_keywords == optional_keywords &&
9901019 other . rest_keywords == rest_keywords &&
1020+ other . forwarding == forwarding &&
9911021 other . return_type == return_type
9921022 end
9931023
@@ -1002,6 +1032,7 @@ def hash
10021032 required_keywords . hash ^
10031033 optional_keywords . hash ^
10041034 rest_keywords . hash ^
1035+ forwarding . hash ^
10051036 return_type . hash
10061037 end
10071038
@@ -1043,6 +1074,7 @@ def map_type(&block)
10431074 required_keywords : hmapv ( required_keywords ) { |param | param . map_type ( &block ) } ,
10441075 optional_keywords : hmapv ( optional_keywords ) { |param | param . map_type ( &block ) } ,
10451076 rest_keywords : rest_keywords &.yield_self { |param | param . map_type ( &block ) } ,
1077+ forwarding : forwarding ,
10461078 return_type : yield ( return_type )
10471079 )
10481080 else
@@ -1110,6 +1142,7 @@ def to_json(state = nil)
11101142 required_keywords : required_keywords ,
11111143 optional_keywords : optional_keywords ,
11121144 rest_keywords : rest_keywords ,
1145+ forwarding : forwarding ,
11131146 return_type : return_type
11141147 } . to_json ( state )
11151148 end
@@ -1129,6 +1162,7 @@ def self.empty(return_type)
11291162 required_keywords : { } ,
11301163 optional_keywords : { } ,
11311164 rest_keywords : nil ,
1165+ forwarding : nil ,
11321166 return_type : return_type
11331167 )
11341168 end
@@ -1142,12 +1176,13 @@ def with_return_type(type)
11421176 required_keywords : required_keywords ,
11431177 optional_keywords : optional_keywords ,
11441178 rest_keywords : rest_keywords ,
1179+ forwarding : forwarding ,
11451180 return_type : type
11461181 )
11471182 end
11481183
11491184 def update ( required_positionals : self . required_positionals , optional_positionals : self . optional_positionals , rest_positionals : self . rest_positionals , trailing_positionals : self . trailing_positionals ,
1150- required_keywords : self . required_keywords , optional_keywords : self . optional_keywords , rest_keywords : self . rest_keywords , return_type : self . return_type )
1185+ required_keywords : self . required_keywords , optional_keywords : self . optional_keywords , rest_keywords : self . rest_keywords , forwarding : self . forwarding , return_type : self . return_type )
11511186 Function . new (
11521187 required_positionals : required_positionals ,
11531188 optional_positionals : optional_positionals ,
@@ -1156,6 +1191,7 @@ def update(required_positionals: self.required_positionals, optional_positionals
11561191 required_keywords : required_keywords ,
11571192 optional_keywords : optional_keywords ,
11581193 rest_keywords : rest_keywords ,
1194+ forwarding : forwarding ,
11591195 return_type : return_type
11601196 )
11611197 end
@@ -1167,6 +1203,7 @@ def empty?
11671203 trailing_positionals . empty? &&
11681204 required_keywords . empty? &&
11691205 optional_keywords . empty? &&
1206+ !forwarding? &&
11701207 !rest_keywords
11711208 end
11721209
@@ -1175,6 +1212,7 @@ def param_to_s
11751212 params = [ ]
11761213
11771214 params . push ( *required_positionals . map ( &:to_s ) )
1215+ params . push ( forwarding . to_s ) if forwarding
11781216 params . push ( *optional_positionals . map { |p | "?#{ p } " } )
11791217 params . push ( "*#{ rest_positionals } " ) if rest_positionals
11801218 params . push ( *trailing_positionals . map ( &:to_s ) )
@@ -1185,6 +1223,10 @@ def param_to_s
11851223 params . join ( ", " )
11861224 end
11871225
1226+ def forwarding?
1227+ !forwarding . nil?
1228+ end
1229+
11881230 def return_to_s
11891231 return_type . to_s ( 1 )
11901232 end
0 commit comments