[pypy-svn] r40530 - in pypy/dist/pypy/translator/cli: . test

antocuni at codespeak.net antocuni at codespeak.net
Thu Mar 15 14:49:41 CET 2007


Author: antocuni
Date: Thu Mar 15 14:49:37 2007
New Revision: 40530

Modified:
   pypy/dist/pypy/translator/cli/dotnet.py
   pypy/dist/pypy/translator/cli/test/test_dotnet.py
Log:
fix also the annotation of box()



Modified: pypy/dist/pypy/translator/cli/dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/dotnet.py	(original)
+++ pypy/dist/pypy/translator/cli/dotnet.py	Thu Mar 15 14:49:37 2007
@@ -366,7 +366,8 @@
     _about_ = box
 
     def compute_result_annotation(self, x_s):
-        return SomeOOInstance(CLR.System.Object._INSTANCE)
+        can_be_None = getattr(x_s, 'can_be_None', False)
+        return SomeOOInstance(CLR.System.Object._INSTANCE, can_be_None=can_be_None)
 
     def specialize_call(self, hop):
         v_obj, = hop.inputargs(*hop.args_r)

Modified: pypy/dist/pypy/translator/cli/test/test_dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_dotnet.py	(original)
+++ pypy/dist/pypy/translator/cli/test/test_dotnet.py	Thu Mar 15 14:49:37 2007
@@ -85,6 +85,19 @@
         s = a.build_types(fn, [])
         assert isinstance(s, annmodel.SomeOOInstance)
         assert s.ootype._name == '[mscorlib]System.Object'
+        assert not s.can_be_None
+
+    def test_box_can_be_None(self):
+        def fn(flag):
+            if flag:
+                return box(42)
+            else:
+                return box(None)
+        a = RPythonAnnotator()
+        s = a.build_types(fn, [bool])
+        assert isinstance(s, annmodel.SomeOOInstance)
+        assert s.ootype._name == '[mscorlib]System.Object'
+        assert s.can_be_None
 
     def test_unbox(self):
         def fn():



More information about the Pypy-commit mailing list