[pypy-svn] r29518 - pypy/dist/pypy/translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Fri Jun 30 01:02:22 CEST 2006


Author: antocuni
Date: Fri Jun 30 01:02:18 2006
New Revision: 29518

Modified:
   pypy/dist/pypy/translator/cli/class_.py
Log:
It could happen that first argument of a method of a class is
annotated with the tyoe of a subclass: in this case don't render the
method, else there would be a type mismatch.



Modified: pypy/dist/pypy/translator/cli/class_.py
==============================================================================
--- pypy/dist/pypy/translator/cli/class_.py	(original)
+++ pypy/dist/pypy/translator/cli/class_.py	Fri Jun 30 01:02:18 2006
@@ -1,3 +1,4 @@
+from pypy.rpython.ootypesystem import ootype
 from pypy.translator.cli.node import Node
 from pypy.translator.cli.cts import CTS
 
@@ -55,6 +56,15 @@
         # lazy import to avoid circular dependencies
         #import pypy.translator.cli.function as function
         for m_name, m_meth in self.classdef._methods.iteritems():
+            args =  m_meth.graph.getargs()
+            
+            # if the first argument of the method is a strict subclass
+            # of this class, then this method is not really used by
+            # the class: don't render it, else there would be a type
+            # mismatch.
+            SELF = args[0].concretetype
+            if SELF is not self.classdef and ootype.isSubclass(SELF, self.classdef):
+                continue
             f = self.db.function_class(self.db, m_meth.graph, m_name, is_method = True)
             f.render(ilasm)
 



More information about the Pypy-commit mailing list