[pypy-svn] r40848 - in pypy/dist/pypy/annotation: . test

arigo at codespeak.net arigo at codespeak.net
Tue Mar 20 16:39:48 CET 2007


Author: arigo
Date: Tue Mar 20 16:39:47 2007
New Revision: 40848

Modified:
   pypy/dist/pypy/annotation/description.py
   pypy/dist/pypy/annotation/test/test_annrpython.py
Log:
test, typo, typo.


Modified: pypy/dist/pypy/annotation/description.py
==============================================================================
--- pypy/dist/pypy/annotation/description.py	(original)
+++ pypy/dist/pypy/annotation/description.py	Tue Mar 20 16:39:47 2007
@@ -751,9 +751,9 @@
             if desc.flags != commonflags:
                 newdesc = desc.bookkeeper.getmethoddesc(desc.funcdesc,
                                                         desc.originclassdef,
-                                                        desc.selfclassdefs,
+                                                        desc.selfclassdef,
                                                         desc.name,
-                                                        flags)
+                                                        commonflags)
                 del descs[desc]
                 descs[newdesc] = True
 

Modified: pypy/dist/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/dist/pypy/annotation/test/test_annrpython.py	Tue Mar 20 16:39:47 2007
@@ -2696,6 +2696,46 @@
         s = a.build_types(f, [bool])
         assert isinstance(s, annmodel.SomeExternalBuiltin)        
 
+    def test_instance_with_flags(self):
+        from pypy.rlib.objectmodel import hint
+
+        class A:
+            _virtualizable_ = True
+        class B(A):
+            def meth(self):
+                return self
+        class C(A): 
+            def meth(self):
+                return self
+
+        def f(n):
+            x = B()
+            x = hint(x, access_directly=True)
+            m = x.meth
+            for i in range(n):
+                x = C()
+                m = x.meth
+            return x, m, m()
+
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [a.bookkeeper.immutablevalue(0)])
+        assert isinstance(s.items[0], annmodel.SomeInstance)
+        assert s.items[0].flags == {'access_directly': True}
+        assert isinstance(s.items[1], annmodel.SomePBC)
+        assert len(s.items[1].descriptions) == 1
+        assert s.items[1].descriptions.keys()[0].flags == {'access_directly':
+                                                           True}
+        assert isinstance(s.items[2], annmodel.SomeInstance)
+        assert s.items[2].flags == {'access_directly': True}
+
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [int])
+        assert isinstance(s.items[0], annmodel.SomeInstance)
+        assert s.items[0].flags == {}
+        assert isinstance(s.items[1], annmodel.SomePBC)
+        assert isinstance(s.items[2], annmodel.SomeInstance)
+        assert s.items[2].flags == {}
+
 def g(n):
     return [0,1,2,n]
 



More information about the Pypy-commit mailing list