JavaLookup.st
branchdevelopment
changeset 1886 746919e0fc34
parent 1864 60a8dc26c8c6
child 1888 3b3d5c9d87aa
--- a/JavaLookup.st	Sat Dec 15 23:25:19 2012 +0100
+++ b/JavaLookup.st	Sun Dec 16 11:53:36 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)'!