[pypy-commit] pypy default: checks that specialize:argtype() makes two copies of a

arigo pypy.commits at gmail.com
Wed Sep 6 03:54:41 EDT 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r92332:5bcb6691636b
Date: 2017-09-06 09:54 +0200
http://bitbucket.org/pypy/pypy/changeset/5bcb6691636b/

Log:	checks that specialize:argtype() makes two copies of a function f(),
	one for the base class and one for the subclass

diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -4644,6 +4644,25 @@
         s_exc = a.binding(graphof(a, f).exceptblock.inputargs[1])
         assert not s_exc.can_be_none()
 
+    def test_specialize_argtype_with_subclasses(self):
+        # checks that specialize:argtype() makes two copies of a
+        # function f(), one for the base class and one for the subclass
+        class A:
+            def foo(self):
+                return 123
+        class B(A):
+            def foo(self):
+                return 456
+        def f(x):
+            return x.foo()
+        f._annspecialcase_ = "specialize:argtype(0)"
+        def h(y):
+            if y > 5:
+                f(A())
+            return f(B())
+        a = self.RPythonAnnotator()
+        assert a.build_types(h, [int]).const == 456
+
 
 def g(n):
     return [0, 1, 2, n]


More information about the pypy-commit mailing list