# type checking: go through each prefix and determine what type it is, get that type, and check if that type contains the next access
# eg: a.b.c.d - disambigName would have already determined what the heck the shortest prefix is for this, so take that (let's say it's a.b) then check type c, see if it contains d, then get d return type and add it to self.myType
# 11. A nonstatic method must not replace a static method
if'static'incur.modsand'static'notinnew.mods:
raiseException("ERROR: Non-static {0} '{1}' in class '{2}' replaces static {0}".format(methodOrField,new.name,className))
raiseException("ERROR: In class {0}, non-static {1} '{2}' in class '{3}' replaces static {1} in class/interface {3}".format(className,methodOrField,new.name,new.typeName,cur.typeName))
# 9. A class/interface must not contain two methods with the same signature but different return types
# 12. A method must not replace a method with a different return type
raiseException("ERROR: Method '{}' in class '{}' replaces method with a different return type".format(className,cur.name))
raiseException("ERROR: In class {}, method '{}' in class '{}' replaces method with a different return type in class/interface {}".format(className,new.name,new.typeName,cur.typeName))
# 13. A protected method must not replace a public method
if'public'incur.modsand'protected'innew.mods:
raiseException("ERROR: Protected {0} '{1}'in class '{2}' replaces public {0}".format(methodOrField,new.name,className))
raiseException("ERROR: In class {0}, protected {1} '{2}'from class '{3}' replaces public {1} from class/interface {4}".format(className,methodOrField,new.name,new.typeName,cur.typeName))
# 14. A method must not replace a final method
# quick fix for final method getClass from java.lang.Object
if'final'incur.modsandcur.name!='getClass':
raiseException("ERROR: {} '{}' in class '{}' replaces final {}".format(methodOrField.capitalize(),cur.name,className,methodOrField))
raiseException("ERROR: In class {0}, {1} '{2}' in class '{3}' replaces final {1} in class/interface {4}".format(className,methodOrField,new.name,new.typeName,cur.typeName))