merging java lookup bugfix development
authorMarcel Hlopko <marcel.hlopko@fit.cvut.cz>
Sun, 16 Dec 2012 11:58:09 +0100
branchdevelopment
changeset 1887 6d3d6ed2d80c
parent 1885 32d39c55b8b0 (current diff)
parent 1886 746919e0fc34 (diff)
child 1888 3b3d5c9d87aa
merging java lookup bugfix
--- a/JavaLookup.st	Sun Dec 16 11:20:22 2012 +0100
+++ b/JavaLookup.st	Sun Dec 16 11:58:09 2012 +0100
@@ -718,16 +718,19 @@
 
 type: actual matches: formal 
     "Return true, if actual (parameter) type matches given formal (parameter) type"
-
-    formal isJavaPrimitiveType ifTrue: [ 
-        actual == SmallInteger ifTrue:[
-            ^formal == Integer or:[actual == formal].
+    
+    formal isJavaPrimitiveType ifTrue: [
+        actual == SmallInteger ifTrue: [
+            ^ formal == Integer or: [ actual == formal ].
         ].
-        formal == Boolean ifTrue:[
-            ^actual == True or:[actual == False or:[actual == Boolean]].
+        formal == Boolean ifTrue: [
+            ^ actual == True or: [ actual == False or: [ actual == Boolean ] ].
         ].
-        ^ actual == formal. 
+        ^ actual == formal.
     ].
+     "nil matches any formal type (to follow undocumented
+     feature of JVM (also seen in CHECKCAST instruction :))" 
+     actual == UndefinedObject ifTrue: [ ^ true ].
     actual isJavaPrimitiveType ifTrue: [
         ^ formal isJavaWrapperClass and: [ formal == actual javaWrapperClass ]
     ].
@@ -739,6 +742,7 @@
     "Created: / 03-01-2012 / 22:36:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 03-04-2012 / 13:59:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 29-10-2012 / 07:28:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-12-2012 / 11:44:17 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
 ! !
 
 !JavaLookup::Smalltalk2Java methodsFor:'utilities (old)'!
--- a/JavaLookupTests.st	Sun Dec 16 11:20:22 2012 +0100
+++ b/JavaLookupTests.st	Sun Dec 16 11:58:09 2012 +0100
@@ -242,6 +242,14 @@
     "Created: / 05-09-2011 / 20:18:30 / Jan Kurs <kursjan@fit.cvut.cz>"
 !
 
+testPassingNilAsParameter
+    "nil should match any formal argument object type (so should not match primitives)"
+    
+    self assert: (self javaTestClass new overloadedMethod: nil) = 3.
+
+    "Created: / 16-12-2012 / 11:35:14 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
+!
+
 testSayHello
     self assert: (self javaTestClass new sayHello = 'hello').
 
@@ -377,6 +385,11 @@
 
 !JavaLookupTests class methodsFor:'documentation'!
 
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+!
+
 version_SVN
-    ^ '$Id$'
+    ^ '§Id§'
 ! !
--- a/JavaLookupTestsResource.st	Sun Dec 16 11:20:22 2012 +0100
+++ b/JavaLookupTestsResource.st	Sun Dec 16 11:58:09 2012 +0100
@@ -173,8 +173,13 @@
 
 !JavaLookupTestsResource class methodsFor:'documentation'!
 
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+!
+
 version_SVN
-    ^ '$Id$'
+    ^ '§Id§'
 ! !
 
 JavaLookupTestsResource initialize!
--- a/extensions.st	Sun Dec 16 11:20:22 2012 +0100
+++ b/extensions.st	Sun Dec 16 11:58:09 2012 +0100
@@ -2031,4 +2031,4 @@
 extensionsVersion_HG
 
     ^ '$Changeset: <not expanded> $'
-! !
+! !
\ No newline at end of file