Bugfix: JavaLookupTests>>testPassingNilAsParameter2. development
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 16 Dec 2012 17:23:16 +0100
branchdevelopment
changeset 1898 51de40865b71
parent 1897 a52c49c12f19
child 1901 02f4c2d0cebc
Bugfix: JavaLookupTests>>testPassingNilAsParameter2.
JavaLookupTests.st
--- a/JavaLookupTests.st	Sun Dec 16 16:50:17 2012 +0100
+++ b/JavaLookupTests.st	Sun Dec 16 17:23:16 2012 +0100
@@ -257,11 +257,38 @@
 !
 
 testPassingNilAsParameter
-    "nil should match any formal argument object type (so should not match primitives)"
-    
-    self assert: (self javaTestClass new overloadedMethod: nil) = 3.
+    "
+    Scenario: from smalltalk, pass a nil to an overloaded method with object-type argument.
+
+    Question: What to do? Both matches, so Ambibuous message looks good,
+    but then it behave differently if you do
+        foo overloadedMethod: 'XXX'
+        foo overloadedMethod: nil
+    than if you do
+        foo overloadedMethod: nil
+        foo overloadedMethod: 'XXX'.
+    On the other hand, which method do choose? Random one? Would lead into
+    hard-to-debug situations.
+
+    No good solution so far..."
+    <skip>
+
+    self assert: false message:'Solution wanted'
+
+"/    self 
+"/        should:[r := self javaTestClass new overloadedMethod: nil]
+"/        raise: AmbiguousMessage
 
     "Created: / 16-12-2012 / 11:35:14 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
+    "Modified: / 16-12-2012 / 17:21:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testPassingNilAsParameter2
+    "nil should match any formal argument object type (so should not match primitives)"
+
+    self assert: (self javaTestClass new overloadedMethodInt: nil) = 2.
+
+    "Created: / 16-12-2012 / 16:21:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testSayHello