From af6723ea02c76742a80e2e229b1af4b5ee966f01 Mon Sep 17 00:00:00 2001 From: Xun Yang <x299yang@uwaterloo.ca> Date: Fri, 6 Mar 2020 18:49:15 -0500 Subject: [PATCH] array assignable to Object --- ExprPrimaryNodes.py | 8 ++------ TheTypeNode.py | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ExprPrimaryNodes.py b/ExprPrimaryNodes.py index 1d948a4..2fba479 100644 --- a/ExprPrimaryNodes.py +++ b/ExprPrimaryNodes.py @@ -375,13 +375,9 @@ class ExprNode(ASTNode): if self.op in ['&&', '&', '|', '||', '!=', '==']: self.myType = TypeStruct("boolean", None) return - # Other Comparisons: - if self.op == 'instanceof': - self.myType = TypeStruct("boolean", None) - return - + if self.left.myType.assignable(self.right.myType) or self.right.myType.assignable(self.left.myType): - if self.op == '==' or self.op == '!=': + if self.op == '==' or self.op == '!=' or self.op == 'instanceof': self.myType = TypeStruct("boolean", None) return diff --git a/TheTypeNode.py b/TheTypeNode.py index b75db2a..68b6988 100644 --- a/TheTypeNode.py +++ b/TheTypeNode.py @@ -70,6 +70,9 @@ class TypeStruct(): return True return False + if right.isArray and self.name in ['java.lang.Object', 'java.lang.Cloneable', 'java.io.Serializable']: + return True + return False # helper: get list of all super class/interface of a ClassInterNode -- GitLab