From f9e64e35dbe0dcd6f9f7edf7f64ac9e8f8211570 Mon Sep 17 00:00:00 2001 From: talhaahsan Date: Fri, 9 Feb 2018 16:36:13 -0600 Subject: [PATCH 1/6] Hmoework Commit Amostdone! --- .idea/.name | 1 + .idea/compiler.xml | 22 +++++++++ .idea/copyright/profiles_settings.xml | 3 ++ .idea/encodings.xml | 6 +++ .idea/misc.xml | 6 +++ .idea/modules.xml | 8 +++ .../inspectionProfiles/Project_Default.xml | 21 -------- java-type-checker/.idea/misc.xml | 2 +- java-type-checker/.idea/type-checker.iml | 2 +- .../java_type_checker/expressions.py | 49 +++++++++++++++++++ java-type-checker/java_type_checker/types.py | 31 +++++++++++- python-attr-lookup/python-attr-lookup.iml | 12 +++++ .../src/plang/PythonObject.java | 23 ++++++--- python-attr-lookup/src/plang/PythonType.java | 12 +++-- 14 files changed, 162 insertions(+), 36 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/compiler.xml create mode 100644 .idea/copyright/profiles_settings.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml delete mode 100644 java-type-checker/.idea/inspectionProfiles/Project_Default.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..9e911f7 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +comp394-type-modeling \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..9a8b7e5 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d5d79e0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1ccf35d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/java-type-checker/.idea/inspectionProfiles/Project_Default.xml b/java-type-checker/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index b169286..0000000 --- a/java-type-checker/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - \ No newline at end of file diff --git a/java-type-checker/.idea/misc.xml b/java-type-checker/.idea/misc.xml index c24fcb0..267cb20 100644 --- a/java-type-checker/.idea/misc.xml +++ b/java-type-checker/.idea/misc.xml @@ -12,5 +12,5 @@ - + \ No newline at end of file diff --git a/java-type-checker/.idea/type-checker.iml b/java-type-checker/.idea/type-checker.iml index 52e75c6..c8a7e47 100644 --- a/java-type-checker/.idea/type-checker.iml +++ b/java-type-checker/.idea/type-checker.iml @@ -2,7 +2,7 @@ - + diff --git a/java-type-checker/java_type_checker/expressions.py b/java-type-checker/java_type_checker/expressions.py index 27ed57e..c5ba23d 100644 --- a/java-type-checker/java_type_checker/expressions.py +++ b/java-type-checker/java_type_checker/expressions.py @@ -31,6 +31,11 @@ def __init__(self, name, declared_type): self.name = name #: The name of the variable self.declared_type = declared_type #: The declared type of the variable (Type) + def static_type(self): + return self.declared_type + + def check_types(self): + return class Literal(Expression): """ A literal value entered in the code, e.g. `5` in the expression `x + 5`. @@ -39,11 +44,18 @@ def __init__(self, value, type): self.value = value #: The literal value, as a string self.type = type #: The type of the literal (Type) + def static_type(self): + return self.type + + def check_types(self): + return class NullLiteral(Literal): def __init__(self): super().__init__("null", Type.null) + def static_type(self): + return Type.null class MethodCall(Expression): """ @@ -55,6 +67,28 @@ def __init__(self, receiver, method_name, *args): self.method_name = method_name #: The name of the method to call (String) self.args = args #: The method arguments (list of Expressions) + def static_type(self): + var = self.receiver + classtype = var.declared_type + method = classtype.method_named(self.method_name) + return(method.return_type) + + def check_types(self): + receiver = self.receiver + classtype = receiver.declared_type + method = classtype.method_named(self.method_name) + argsExpected = method.argument_types #not certain what type this is. + args = self.args #But these are definitely expressions + if(len(argsExpected) != len(args)): + raise JavaTypeError("Wrong number of arguments for {3}.{0}(): expected {1}, got {2}".format(self.method_name, len(argsExpected), len(args), classtype.name)) + + for i in range(len(args)): + typeExp = argsExpected[i] + expressionGot = args[i] + typeGot = expressionGot.static_type() + if not typeGot.is_subtype_of(typeExp): + raise JavaTypeError("Rectangle.setPosition() expects arguments of type (double, double), but got (double, boolean)") + return class ConstructorCall(Expression): """ @@ -64,6 +98,21 @@ def __init__(self, instantiated_type, *args): self.instantiated_type = instantiated_type #: The type to instantiate (Type) self.args = args #: Constructor arguments (list of Expressions) + def static_type(self): + return self.instantiated_type + + def check_types(self): + classType = self.static_type() + argsGot = self.args + argsExp = classType.constructor.argument_types + if(len(argsExp) != len(argsGot)): + raise JavaTypeError("Wrong number of arguments for Rectangle constructor: expected 2, got 1") + #todo: make this a proper error message for expected X and Y, and correct. + for i in range(len(argsGot)): + typeExp = argsExp[i] + typeGot = argsGot[i] + if typeExp != typeGot: + raise JavaTypeError("Rectangle constructor expects arguments of type (Point, Size), but got (Point, boolean)") class JavaTypeError(Exception): """ Indicates a compile-time type error in an expression. diff --git a/java-type-checker/java_type_checker/types.py b/java-type-checker/java_type_checker/types.py index 465f7f4..7186f68 100644 --- a/java-type-checker/java_type_checker/types.py +++ b/java-type-checker/java_type_checker/types.py @@ -12,7 +12,20 @@ def __init__(self, name, direct_supertypes=[]): def is_subtype_of(self, other): """ True if this type can be used where the other type is expected. """ - return True # TODO: implement + #Catch for self not in supertypes, modifies a copy of the direct_supertypes in case user didn't spec self in list + allSupers = [self] + prevSize = -1 + currentSize = 1 + while currentSize > prevSize: + prevSize = currentSize + for super in allSupers: + potentialNewSupers = super.direct_supertypes + for potentialSuper in potentialNewSupers: + if potentialSuper not in allSupers: + allSupers.append(potentialSuper) + currentSize+=1 + #Is this messy? yes it is. I'd rather use a set in this case but apparently returning arrays and then extending sets isn't viable + return(other in allSupers) def is_supertype_of(self, other): """ Convenience counterpart to is_subtype_of(). @@ -66,11 +79,25 @@ def method_named(self, name): raise NoSuchMethod("{0} has no method named {1}".format(self.name, name)) -class NullType(Type): +class NullType(ClassOrInterface): """ The type of the value `null` in Java. """ def __init__(self): super().__init__("null") + self.is_instantiable = False + self.methods = {} + + def method_named(self, name): + raise NoSuchMethod("{0} has no method named {1}".format(self.name, name)) + + def is_subtype_of(self, other): + return True + + def is_supertype_of(self, other): + return False + + + class NoSuchMethod(Exception): diff --git a/python-attr-lookup/python-attr-lookup.iml b/python-attr-lookup/python-attr-lookup.iml index 01e8e1b..a2b4cff 100644 --- a/python-attr-lookup/python-attr-lookup.iml +++ b/python-attr-lookup/python-attr-lookup.iml @@ -20,5 +20,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/python-attr-lookup/src/plang/PythonObject.java b/python-attr-lookup/src/plang/PythonObject.java index a8e311f..2ddc1a6 100644 --- a/python-attr-lookup/src/plang/PythonObject.java +++ b/python-attr-lookup/src/plang/PythonObject.java @@ -1,10 +1,6 @@ package plang; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * The runtime state of an object in Python. @@ -51,7 +47,10 @@ public List getMRO() { * result (i.e. it remembers the list buildMRO() returned and keeps returning it). */ protected List buildMRO() { - throw new UnsupportedOperationException("not implemented yet"); + mro = new ArrayList<>(); + mro.add(this); + mro.addAll(this.getType().buildMRO()); + return mro; } /** @@ -62,7 +61,15 @@ protected List buildMRO() { * @throws PythonAttributeException When there is no attribute on this object with that name. */ public final PythonObject get(String attrName) throws PythonAttributeException { - throw new UnsupportedOperationException("not implemented yet"); + boolean foundVal = false; + List layers = getMRO(); + for(PythonObject layer : layers){ + if(layer.attrs.containsKey(attrName)) + return layer.attrs.get(attrName); + } + if(!foundVal) + throw new PythonAttributeException(this, attrName); + return null; } /** @@ -74,7 +81,7 @@ public final PythonObject get(String attrName) throws PythonAttributeException { * @param value Its new value */ public final void set(String attrName, PythonObject value) { - throw new UnsupportedOperationException("not implemented yet"); + attrs.put(attrName, value); } @Override diff --git a/python-attr-lookup/src/plang/PythonType.java b/python-attr-lookup/src/plang/PythonType.java index 4e2be4a..19c10af 100644 --- a/python-attr-lookup/src/plang/PythonType.java +++ b/python-attr-lookup/src/plang/PythonType.java @@ -1,7 +1,6 @@ package plang; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -41,7 +40,12 @@ public PythonObject getBase() { @Override protected List buildMRO() { - throw new UnsupportedOperationException("not implemented yet"); + List mro = new ArrayList<>(); + mro.add(this); + if(this.base == null) + return mro; + mro.addAll(this.base.getMRO()); + return mro; } /** @@ -49,7 +53,9 @@ protected List buildMRO() { * this PythonType. */ public PythonObject instantiate() { - throw new UnsupportedOperationException("not implemented yet"); + return new PythonObject(this); + // todo: confirm this works? + //throw new UnsupportedOperationException("not implemented yet"); } @Override From a5a362d46a61f14b1fbf640be506064be615b412 Mon Sep 17 00:00:00 2001 From: talhaahsan Date: Fri, 9 Feb 2018 16:47:37 -0600 Subject: [PATCH 2/6] Fixed two more errors! Now on to constructors and deep calls? --- java-type-checker/java_type_checker/expressions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/java-type-checker/java_type_checker/expressions.py b/java-type-checker/java_type_checker/expressions.py index c5ba23d..8c9572f 100644 --- a/java-type-checker/java_type_checker/expressions.py +++ b/java-type-checker/java_type_checker/expressions.py @@ -79,15 +79,17 @@ def check_types(self): method = classtype.method_named(self.method_name) argsExpected = method.argument_types #not certain what type this is. args = self.args #But these are definitely expressions + typesGot = [] + for arg in args: + typesGot.append(arg.static_type()) if(len(argsExpected) != len(args)): raise JavaTypeError("Wrong number of arguments for {3}.{0}(): expected {1}, got {2}".format(self.method_name, len(argsExpected), len(args), classtype.name)) - for i in range(len(args)): typeExp = argsExpected[i] expressionGot = args[i] typeGot = expressionGot.static_type() if not typeGot.is_subtype_of(typeExp): - raise JavaTypeError("Rectangle.setPosition() expects arguments of type (double, double), but got (double, boolean)") + raise JavaTypeError("{0}.{1}() expects arguments of type {2}, but got {3}".format(classtype.name, self.method_name, names(argsExpected), names(typesGot))) return class ConstructorCall(Expression): From 99a3a04577cc051b8783c974f80b5077e53db839 Mon Sep 17 00:00:00 2001 From: talhaahsan Date: Fri, 9 Feb 2018 17:12:57 -0600 Subject: [PATCH 3/6] Fixed all but one error for type checker SO CLOSE. --- .../java_type_checker/expressions.py | 16 ++++++++++++---- java-type-checker/java_type_checker/types.py | 3 +-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/java-type-checker/java_type_checker/expressions.py b/java-type-checker/java_type_checker/expressions.py index 8c9572f..7e51f17 100644 --- a/java-type-checker/java_type_checker/expressions.py +++ b/java-type-checker/java_type_checker/expressions.py @@ -76,6 +76,9 @@ def static_type(self): def check_types(self): receiver = self.receiver classtype = receiver.declared_type + #Check if classtpye is primitive: + if classtype.is_subtype_of(Type.boolean) or classtype.is_subtype_of(Type.int) or classtype.is_subtype_of(Type.double): + raise JavaTypeError("Type {0} does not have methods".format(classtype.name)) method = classtype.method_named(self.method_name) argsExpected = method.argument_types #not certain what type this is. args = self.args #But these are definitely expressions @@ -87,6 +90,7 @@ def check_types(self): for i in range(len(args)): typeExp = argsExpected[i] expressionGot = args[i] + expressionGot.check_types() typeGot = expressionGot.static_type() if not typeGot.is_subtype_of(typeExp): raise JavaTypeError("{0}.{1}() expects arguments of type {2}, but got {3}".format(classtype.name, self.method_name, names(argsExpected), names(typesGot))) @@ -105,17 +109,21 @@ def static_type(self): def check_types(self): classType = self.static_type() + if classType.is_subtype_of(Type.boolean) or classType.is_subtype_of(Type.int) or classType.is_subtype_of(Type.double): + raise JavaTypeError("Type {0} is not instantiable".format(classType.name)) argsGot = self.args argsExp = classType.constructor.argument_types + typesGot = [] + for arg in argsGot: + typesGot.append(arg.static_type()) if(len(argsExp) != len(argsGot)): - raise JavaTypeError("Wrong number of arguments for Rectangle constructor: expected 2, got 1") - #todo: make this a proper error message for expected X and Y, and correct. + raise JavaTypeError("Wrong number of arguments for {0} constructor: expected {1}, got {2}".format(classType.name, len(argsExp), len(argsGot))) for i in range(len(argsGot)): typeExp = argsExp[i] typeGot = argsGot[i] if typeExp != typeGot: - raise JavaTypeError("Rectangle constructor expects arguments of type (Point, Size), but got (Point, boolean)") - + raise JavaTypeError("{0} constructor expects arguments of type {1}, but got {2}".format(classType.name, names(argsExp), names(typesGot))) + return class JavaTypeError(Exception): """ Indicates a compile-time type error in an expression. """ diff --git a/java-type-checker/java_type_checker/types.py b/java-type-checker/java_type_checker/types.py index 7186f68..bd3b7d2 100644 --- a/java-type-checker/java_type_checker/types.py +++ b/java-type-checker/java_type_checker/types.py @@ -91,10 +91,9 @@ def method_named(self, name): raise NoSuchMethod("{0} has no method named {1}".format(self.name, name)) def is_subtype_of(self, other): + #primitives can't be null return True - def is_supertype_of(self, other): - return False From bb628247b5096c7c9476b129a4182e5de4398022 Mon Sep 17 00:00:00 2001 From: talhaahsan Date: Fri, 9 Feb 2018 19:48:59 -0600 Subject: [PATCH 4/6] REALLY BAD CODE BUT IT WORKS. BADA BOOM BADA BANG --- .../java_type_checker/expressions.py | 20 +++++++++++-------- java-type-checker/java_type_checker/types.py | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/java-type-checker/java_type_checker/expressions.py b/java-type-checker/java_type_checker/expressions.py index 7e51f17..59c5a55 100644 --- a/java-type-checker/java_type_checker/expressions.py +++ b/java-type-checker/java_type_checker/expressions.py @@ -68,21 +68,21 @@ def __init__(self, receiver, method_name, *args): self.args = args #: The method arguments (list of Expressions) def static_type(self): - var = self.receiver - classtype = var.declared_type + classtype = self.receiver.declared_type method = classtype.method_named(self.method_name) return(method.return_type) def check_types(self): - receiver = self.receiver - classtype = receiver.declared_type - #Check if classtpye is primitive: + classtype = self.receiver.declared_type + if classtype.is_subtype_of(Type.boolean) or classtype.is_subtype_of(Type.int) or classtype.is_subtype_of(Type.double): raise JavaTypeError("Type {0} does not have methods".format(classtype.name)) + method = classtype.method_named(self.method_name) argsExpected = method.argument_types #not certain what type this is. args = self.args #But these are definitely expressions typesGot = [] + for arg in args: typesGot.append(arg.static_type()) if(len(argsExpected) != len(args)): @@ -92,7 +92,7 @@ def check_types(self): expressionGot = args[i] expressionGot.check_types() typeGot = expressionGot.static_type() - if not typeGot.is_subtype_of(typeExp): + if not typeGot.is_subtype_of(typeExp) and typesGot != argsExpected: raise JavaTypeError("{0}.{1}() expects arguments of type {2}, but got {3}".format(classtype.name, self.method_name, names(argsExpected), names(typesGot))) return @@ -109,8 +109,10 @@ def static_type(self): def check_types(self): classType = self.static_type() + if classType.is_subtype_of(Type.boolean) or classType.is_subtype_of(Type.int) or classType.is_subtype_of(Type.double): raise JavaTypeError("Type {0} is not instantiable".format(classType.name)) + argsGot = self.args argsExp = classType.constructor.argument_types typesGot = [] @@ -120,10 +122,12 @@ def check_types(self): raise JavaTypeError("Wrong number of arguments for {0} constructor: expected {1}, got {2}".format(classType.name, len(argsExp), len(argsGot))) for i in range(len(argsGot)): typeExp = argsExp[i] - typeGot = argsGot[i] - if typeExp != typeGot: + typeGot = argsGot[i].static_type + #second part checks for a weird edge case where Got (Point, Size) Expected (Point, Size) TODO: figure out why + if (not typeExp.is_subtype_of(typeGot)) and typesGot != argsExp: raise JavaTypeError("{0} constructor expects arguments of type {1}, but got {2}".format(classType.name, names(argsExp), names(typesGot))) return + class JavaTypeError(Exception): """ Indicates a compile-time type error in an expression. """ diff --git a/java-type-checker/java_type_checker/types.py b/java-type-checker/java_type_checker/types.py index bd3b7d2..3a62d2e 100644 --- a/java-type-checker/java_type_checker/types.py +++ b/java-type-checker/java_type_checker/types.py @@ -84,6 +84,7 @@ class NullType(ClassOrInterface): """ def __init__(self): super().__init__("null") + self.name = "null" self.is_instantiable = False self.methods = {} From 867266da61048b5cbcc276ad0ac28287340a5795 Mon Sep 17 00:00:00 2001 From: talhaahsan Date: Fri, 9 Feb 2018 21:46:26 -0600 Subject: [PATCH 5/6] Committing because it's almost done and I definitely can't figure out the rest of it Yes the code is messy. Does it work? Mostly. Does TestNull give me irrational rage? Yes, yes it does. Expect me to ask for help monday. --- java-type-checker/java_type_checker/expressions.py | 8 +++++++- java-type-checker/java_type_checker/types.py | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/java-type-checker/java_type_checker/expressions.py b/java-type-checker/java_type_checker/expressions.py index 59c5a55..5deb4a3 100644 --- a/java-type-checker/java_type_checker/expressions.py +++ b/java-type-checker/java_type_checker/expressions.py @@ -53,6 +53,7 @@ def check_types(self): class NullLiteral(Literal): def __init__(self): super().__init__("null", Type.null) + self.declared_type = Type.null def static_type(self): return Type.null @@ -85,14 +86,16 @@ def check_types(self): for arg in args: typesGot.append(arg.static_type()) + if(len(argsExpected) != len(args)): raise JavaTypeError("Wrong number of arguments for {3}.{0}(): expected {1}, got {2}".format(self.method_name, len(argsExpected), len(args), classtype.name)) + for i in range(len(args)): typeExp = argsExpected[i] expressionGot = args[i] expressionGot.check_types() typeGot = expressionGot.static_type() - if not typeGot.is_subtype_of(typeExp) and typesGot != argsExpected: + if (not typeGot.is_subtype_of(typeExp)) and typesGot != argsExpected: raise JavaTypeError("{0}.{1}() expects arguments of type {2}, but got {3}".format(classtype.name, self.method_name, names(argsExpected), names(typesGot))) return @@ -103,6 +106,9 @@ class ConstructorCall(Expression): def __init__(self, instantiated_type, *args): self.instantiated_type = instantiated_type #: The type to instantiate (Type) self.args = args #: Constructor arguments (list of Expressions) + if self.instantiated_type == Type.null: + raise JavaTypeError("Type null is not instantiable") + def static_type(self): return self.instantiated_type diff --git a/java-type-checker/java_type_checker/types.py b/java-type-checker/java_type_checker/types.py index 3a62d2e..5c742f8 100644 --- a/java-type-checker/java_type_checker/types.py +++ b/java-type-checker/java_type_checker/types.py @@ -84,15 +84,16 @@ class NullType(ClassOrInterface): """ def __init__(self): super().__init__("null") - self.name = "null" self.is_instantiable = False self.methods = {} def method_named(self, name): - raise NoSuchMethod("{0} has no method named {1}".format(self.name, name)) + raise NoSuchMethod("Cannot invoke method {0}() on {1}".format(name, self.name)) def is_subtype_of(self, other): #primitives can't be null + if(other.is_subtype_of(Type.boolean) or other.is_subtype_of(Type.int) or other.is_subtype_of(Type.double)): + return False return True From 754d45dc88e7758e15e50d2a29e9f62f37bdfa73 Mon Sep 17 00:00:00 2001 From: talhaahsan Date: Fri, 9 Feb 2018 22:14:46 -0600 Subject: [PATCH 6/6] Hunter Herman is space Jesus Hunter helped me bugfix. Mostly helped point out why my code didn't belong where it did, and that static_type is not the same as static_type() AttributeError: 'function' object has no attribute 'is_subtype_of' has plagued me no longer. --- java-type-checker/java_type_checker/expressions.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/java-type-checker/java_type_checker/expressions.py b/java-type-checker/java_type_checker/expressions.py index 5deb4a3..fd8861e 100644 --- a/java-type-checker/java_type_checker/expressions.py +++ b/java-type-checker/java_type_checker/expressions.py @@ -86,6 +86,8 @@ def check_types(self): for arg in args: typesGot.append(arg.static_type()) + arg.check_types() + if(len(argsExpected) != len(args)): raise JavaTypeError("Wrong number of arguments for {3}.{0}(): expected {1}, got {2}".format(self.method_name, len(argsExpected), len(args), classtype.name)) @@ -106,8 +108,7 @@ class ConstructorCall(Expression): def __init__(self, instantiated_type, *args): self.instantiated_type = instantiated_type #: The type to instantiate (Type) self.args = args #: Constructor arguments (list of Expressions) - if self.instantiated_type == Type.null: - raise JavaTypeError("Type null is not instantiable") + def static_type(self): @@ -115,6 +116,8 @@ def static_type(self): def check_types(self): classType = self.static_type() + if classType == Type.null: + raise JavaTypeError("Type null is not instantiable") if classType.is_subtype_of(Type.boolean) or classType.is_subtype_of(Type.int) or classType.is_subtype_of(Type.double): raise JavaTypeError("Type {0} is not instantiable".format(classType.name)) @@ -124,13 +127,15 @@ def check_types(self): typesGot = [] for arg in argsGot: typesGot.append(arg.static_type()) + arg.check_types() + if(len(argsExp) != len(argsGot)): raise JavaTypeError("Wrong number of arguments for {0} constructor: expected {1}, got {2}".format(classType.name, len(argsExp), len(argsGot))) for i in range(len(argsGot)): typeExp = argsExp[i] - typeGot = argsGot[i].static_type + typeGot = argsGot[i].static_type() #second part checks for a weird edge case where Got (Point, Size) Expected (Point, Size) TODO: figure out why - if (not typeExp.is_subtype_of(typeGot)) and typesGot != argsExp: + if (not typeGot.is_subtype_of(typeExp)) and typesGot != argsExp: raise JavaTypeError("{0} constructor expects arguments of type {1}, but got {2}".format(classType.name, names(argsExp), names(typesGot))) return