diff options
-rw-r--r-- | variable.c | 23 | ||||
-rw-r--r-- | version.h | 2 |
2 files changed, 20 insertions, 5 deletions
diff --git a/variable.c b/variable.c index 54e7928292..fadc8d1763 100644 --- a/variable.c +++ b/variable.c @@ -2608,10 +2608,25 @@ rb_const_set(VALUE klass, ID id, VALUE val) * and avoid order-dependency on const_tbl */ if (rb_cObject && (RB_TYPE_P(val, T_MODULE) || RB_TYPE_P(val, T_CLASS))) { - if (!NIL_P(rb_class_path_cached(val))) { - rb_name_class(val, id); - if (rb_class_path_cached(klass)) { - rb_class_name(val); + if (NIL_P(rb_class_path_cached(val))) { + if (klass == rb_cObject) { + rb_ivar_set(val, classpath, rb_id2str(id)); + rb_name_class(val, id); + } + else { + VALUE path; + ID pathid; + st_data_t n; + st_table *ivtbl = RCLASS_IV_TBL(klass); + if (ivtbl && + (st_lookup(ivtbl, (st_data_t)(pathid = classpath), &n) || + st_lookup(ivtbl, (st_data_t)(pathid = tmp_classpath), &n))) { + path = rb_str_dup((VALUE)n); + rb_str_append(rb_str_cat2(path, "::"), rb_id2str(id)); + OBJ_FREEZE(path); + rb_ivar_set(val, pathid, path); + rb_name_class(val, id); + } } } } @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.4.0" #define RUBY_RELEASE_DATE "2017-03-12" -#define RUBY_PATCHLEVEL 21 +#define RUBY_PATCHLEVEL 22 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 |