[m-rev.] diff: adjust TypeInfo_Struct unify method

Peter Wang novalazy at gmail.com
Wed Jan 27 14:41:39 AEDT 2010


Branches: main

java/runtime/TypeInfo_Struct.java:
        Make TypeInfo_Struct.unify() method compare correctly two type_infos
        where one type_info has a null `args' field and another has a
        zero-length `args' array.

diff --git a/java/runtime/TypeInfo_Struct.java b/java/runtime/TypeInfo_Struct.java
index e328350..f8a8fdd 100644
--- a/java/runtime/TypeInfo_Struct.java
+++ b/java/runtime/TypeInfo_Struct.java
@@ -115,22 +115,24 @@ public class TypeInfo_Struct extends PseudoTypeInfo
 			return true;
 		}
 
-		if (type_ctor.unify(ti.type_ctor) == false) {
+		if (!type_ctor.unify(ti.type_ctor)) {
 			return false;
 		}
 
-		if (args == null || ti.args == null) {
-			if (args == null && ti.args == null) {
-				return true;
-			}
+		int len1 = 0;
+		int len2 = 0;
+		if (args != null) {
+			len1 = args.length;
+		}
+		if (ti.args != null) {
+			len2 = ti.args.length;
+		}
+		if (len1 != len2) {
 			return false;
 		}
 
-		for (int i = 0; i < args.length || i < ti.args.length; i++) {
-			if (i == args.length || i == ti.args.length) {
-				return false;
-			}
-			if (args[i].unify(ti.args[i]) == false) {
+		for (int i = 0; i < len1; i++) {
+			if (!args[i].unify(ti.args[i])) {
 				return false;
 			}
 		}

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list