Skip to content

Instantly share code, notes, and snippets.

@espeed
Created April 27, 2012 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save espeed/2506332 to your computer and use it in GitHub Desktop.
Save espeed/2506332 to your computer and use it in GitHub Desktop.
Jython Snippet
Set<String> allModified = Generic.set();
PyJavaType[] conflicted = inConflict.toArray(new PyJavaType[inConflict.size()]);
for (PyJavaType type : conflicted) {
if (type.modified == null) {
continue;
}
for (String method : type.modified) {
if (!allModified.add(method)) { // Another type in conflict has this method, fail
PyList types = new PyList();
for (PyJavaType othertype : conflicted) {
if (othertype.modified != null && othertype.modified.contains(method)) {
types.add(othertype);
}
}
throw Py.TypeError(String.format("Supertypes that share a modified attribute "
+ " have an MRO conflict[attribute=%s, types=%s]", method, types));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment