[pypy-svn] r57708 - in pypy/branch/oo-jit/pypy: annotation rpython/ootypesystem/test

antocuni at codespeak.net antocuni at codespeak.net
Mon Sep 1 10:37:49 CEST 2008


Author: antocuni
Date: Mon Sep  1 10:37:46 2008
New Revision: 57708

Modified:
   pypy/branch/oo-jit/pypy/annotation/binaryop.py
   pypy/branch/oo-jit/pypy/rpython/ootypesystem/test/test_oortype.py
Log:
allow mixing ootype.Class of Instances and Records



Modified: pypy/branch/oo-jit/pypy/annotation/binaryop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/annotation/binaryop.py	(original)
+++ pypy/branch/oo-jit/pypy/annotation/binaryop.py	Mon Sep  1 10:37:46 2008
@@ -951,6 +951,8 @@
             common = r2.ootype
         elif r2.ootype is None:
             common = r1.ootype
+        elif isinstance(r1.ootype, ootype.Record) or isinstance(r2.ootype, ootype.Record):
+            common = ootype.Object
         else:
             common = ootype.commonBaseclass(r1.ootype, r2.ootype)
             assert common is not None, ('Mixing of incompatible classes %r, %r'

Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/test/test_oortype.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/test/test_oortype.py	(original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/test/test_oortype.py	Mon Sep  1 10:37:46 2008
@@ -363,3 +363,20 @@
 
     res = interpret(fn, [], type_system='ootype')
     assert not res
+
+def test_mix_class_record_instance():
+    I = Instance("test", ROOT, {"a": Signed})
+    R = Record({"x": Signed})
+
+    c1 = runtimeClass(I)
+    c2 = runtimeClass(R)
+    def fn(flag):
+        if flag:
+            return c1
+        else:
+            return c2
+
+    res = interpret(fn, [True], type_system='ootype')
+    assert res is c1
+    res = interpret(fn, [False], type_system='ootype')
+    assert res is c2



More information about the Pypy-commit mailing list