@@ -163,7 +163,7 @@ def send_setup(method_type, receiver, method, args, proc)
163163 end
164164 end
165165
166- last_trace = trace . last or raise
166+ last_trace = trace . last or raise "empty trace"
167167
168168 yield ( mt , last_trace , result , exception )
169169 end
@@ -182,9 +182,9 @@ def send_setup(method_type, receiver, method, args, proc)
182182
183183 assert_empty errors . map { |x | RBS ::Test ::Errors . to_string ( x ) } , "Call trace does not match with given method type: #{ trace . inspect } "
184184
185- method_types = method_types ( method )
186- all_errors = method_types . map { |t | typecheck . method_call ( method , t , trace , errors : [ ] ) }
187- assert all_errors . any? { |es | es . empty? } , "Call trace does not match one of method definitions:\n #{ trace . inspect } \n #{ method_types . join ( " | " ) } "
185+ method_defs = method_defs ( method )
186+ all_errors = method_defs . map { |t | typecheck . method_call ( method , t . type , trace , errors : [ ] , annotations : t . annotations ) }
187+ assert all_errors . any? { |es | es . empty? } , "Call trace does not match one of method definitions:\n #{ trace . inspect } \n #{ method_defs . map ( & :type ) . join ( " | " ) } "
188188
189189 raise exception if exception
190190
@@ -219,30 +219,36 @@ def send_setup(method_type, receiver, method, args, proc)
219219 assert_operator exception , :is_a? , ::Exception
220220 assert_empty errors . map { |x | RBS ::Test ::Errors . to_string ( x ) }
221221
222- method_types = method_types ( method )
223- all_errors = method_types . map { |t | typecheck . method_call ( method , t , trace , errors : [ ] ) }
224- assert all_errors . all? { |es | es . size > 0 } , "Call trace unexpectedly matches one of method definitions:\n #{ trace . inspect } \n #{ method_types . join ( " | " ) } "
222+ method_defs = method_defs ( method )
223+ all_errors = method_defs . map { |t | typecheck . method_call ( method , t . type , trace , errors : [ ] , annotations : t . annotations ) }
224+ assert all_errors . all? { |es | es . size > 0 } , "Call trace unexpectedly matches one of method definitions:\n #{ trace . inspect } \n #{ method_defs . map ( & :type ) . join ( " | " ) } "
225225
226226 result
227227 end
228228 end
229229
230- def method_types ( method )
230+ def method_defs ( method )
231231 type , definition = target
232232
233233 case type
234234 when Types ::ClassInstance
235235 subst = RBS ::Substitution . build ( definition . type_params , type . args )
236- definition . methods [ method ] . method_types . map do |method_type |
237- method_type . sub ( subst )
236+ definition . methods [ method ] . defs . map do |type_def |
237+ type_def . update (
238+ type : type_def . type . sub ( subst )
239+ )
238240 end
239241 when Types ::ClassSingleton
240- definition . methods [ method ] . method_types
242+ definition . methods [ method ] . defs
241243 else
242244 raise
243245 end
244246 end
245247
248+ def method_types ( method )
249+ method_defs ( method ) . map ( &:type )
250+ end
251+
246252 def allows_error ( *errors )
247253 yield
248254 rescue *errors => exn
0 commit comments