Author: Armin Rigo <ar...@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] _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit