Commit 854c48d9
854c48d915f8Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Module#method_defined? from the class method table
Decide Class.method_defined?(:m[, inherit]) at compile time from the recorded instance methods plus attr readers/writers, accepting a symbol or string name and a setter (m=) query. With inherit=false the lookup is restricted to the receiver's own definitions; since attr readers/writers are flattened into descendants, "own" means present here but absent from the parent chain.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 854c48d915f8
- Parent
- 6b9fd5ab1453
src/analyze.cmodifiedView file
@@ -751,6 +751,7 @@
751751
return ty_is_numeric(rt) ? rt : TY_UNKNOWN;752752
if (!strcmp(name, "!")) return TY_BOOL;753753
if (!strcmp(name, "respond_to?") && recv >= 0) return TY_BOOL;754+
if ((!strcmp(name, "method_defined?") || !strcmp(name, "const_defined?")) && recv >= 0) return TY_BOOL;754755
if (!strcmp(name, "nil?") && recv >= 0 && argc == 0) return TY_BOOL;755756
if (!strcmp(name, "object_id") && recv >= 0 && argc == 0) return TY_INT;756757
if (!strcmp(name, "between?") && argc == 2 && (rt == TY_STRING || ty_is_numeric(rt))) return TY_BOOL;src/codegen.cmodifiedView file
Loading diff…