Commit 869e224e
869e224e708eMerged
ydah <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(analyze): prefer self method return for bare calls
Details
- Commit
- 869e224e708e
- Parent
- 1c819212d772
spinel_analyze.rbmodifiedView file
@@ -3253,6 +3253,15 @@
32533253
end32543254
end32553255
end3256+
# Bare calls inside an instance method can resolve to another3257+
# user-defined method on self. Let the receiver-aware class method3258+
# lookup later in infer_call_type answer those before the generic3259+
# name-based builtins (`length` -> int, `to_s` -> string, ...).3260+
if recv < 0 && @current_class_idx >= 03261+
if cls_find_method(@current_class_idx, mname) >= 03262+
return ""3263+
end3264+
end32563265
if mname == "length"32573266
if recv_could_be_obj(recv) == 1 && any_user_class_defines_imeth(mname) == 132583267
return ""test/bare_self_method_float_return_local.rbaddedView file
Loading diff…
test/bare_self_method_float_return_local.rb.expectedaddedView file
Loading diff…