From c526a584c8b9c132993310637aeae75129309400 Mon Sep 17 00:00:00 2001
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Fri, 2 Sep 2011 05:36:49 +0000
Subject: * vm_insnhelper.c (vm_search_const_defined_class): search   ancestors
 only when global scope.  [ruby-core:39227] [Bug #5264]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 insns.def | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

(limited to 'insns.def')

diff --git a/insns.def b/insns.def
index 0ee0e3fc85..df36c6323b 100644
--- a/insns.def
+++ b/insns.def
@@ -895,7 +895,6 @@ defineclass
 (VALUE val)
 {
     VALUE klass;
-    int newclass = 1;
 
     switch ((int)define_type) {
       case 0: /* scoped:   class Foo::Bar */
@@ -904,16 +903,15 @@ defineclass
 
 	if (super == Qnil) {
 	    super = rb_cObject;
-	    newclass = 0;
 	}
 
 	vm_check_if_namespace(cbase);
 
 	/* find klass */
 	rb_autoload_load(cbase, id);
-	if (vm_const_defined_at(cbase, id, newclass)) {
+	if ((klass = vm_search_const_defined_class(cbase, id)) != 0) {
 	    /* already exist */
-	    klass = define_type == 0 ? rb_public_const_get(cbase, id) : rb_const_get_from(cbase, id);
+	    klass = define_type == 0 ? rb_public_const_get_at(klass, id) : rb_const_get_at(klass, id);
 	    if (TYPE(klass) != T_CLASS) {
 		rb_raise(rb_eTypeError, "%s is not a class", rb_id2name(id));
 	    }
@@ -949,8 +947,8 @@ defineclass
 	vm_check_if_namespace(cbase);
 
 	/* find klass */
-	if (vm_const_defined_at(cbase, id, 0)) {
-	    klass = define_type == 2 ? rb_public_const_get(cbase, id) : rb_const_get_from(cbase, id);
+	if ((klass = vm_search_const_defined_class(cbase, id)) != 0) {
+	    klass = define_type == 2 ? rb_public_const_get_at(klass, id) : rb_const_get_at(klass, id);
 	    /* already exist */
 	    if (TYPE(klass) != T_MODULE) {
 		rb_raise(rb_eTypeError, "%s is not a module", rb_id2name(id));
-- 
cgit v1.2.3

