[svn:parrot] r38605 - in trunk: src/pmc t/pmc

jonathan at svn.parrot.org jonathan at svn.parrot.org
Fri May 8 13:37:27 UTC 2009


Author: jonathan
Date: Fri May  8 13:37:27 2009
New Revision: 38605
URL: https://trac.parrot.org/parrot/changeset/38605

Log:
[core] In add_parent we were checking if we already inherited from another class by name; this should always just be done by pointer equality (which is cheaper too). Fix and add a test.

Modified:
   trunk/src/pmc/class.pmc
   trunk/t/pmc/class.t

Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc	Fri May  8 13:25:42 2009	(r38604)
+++ trunk/src/pmc/class.pmc	Fri May  8 13:37:27 2009	(r38605)
@@ -820,7 +820,7 @@
             STRING * const current_name = VTABLE_get_string(interp, current_parent);
 
             /* throw an exception if we already have this parent */
-            if (Parrot_str_equal(interp, current_name, parent_name))
+            if (current_parent == parent)
                 Parrot_ex_throw_from_c_args(interp, NULL,
                     EXCEPTION_INVALID_OPERATION,
                     "The class '%S' already has a parent class '%S'. "

Modified: trunk/t/pmc/class.t
==============================================================================
--- trunk/t/pmc/class.t	Fri May  8 13:25:42 2009	(r38604)
+++ trunk/t/pmc/class.t	Fri May  8 13:37:27 2009	(r38605)
@@ -17,7 +17,7 @@
 =cut
 
 
-.const int TESTS = 62 
+.const int TESTS = 63 
 
 
 .sub 'main' :main
@@ -45,6 +45,7 @@
      'isa'()
      'does'()
      'more does'()
+     'anon_inherit'()
 .end
 
 
@@ -592,6 +593,14 @@
     is($I0, 1, 'does Red')
 .end
 
+.sub 'anon_inherit'
+    $P0 = new 'Class'
+    $P1 = new 'Class'
+    $P2 = new 'Class'
+    addparent $P2, $P0
+    addparent $P2, $P1
+    ok(1, 'inheritance of two different anonymous classes works')
+.end
 
 # Local Variables:
 #   mode: pir


More information about the parrot-commits mailing list