Tests pass

This commit is contained in:
konsoletyper 2014-06-09 18:52:16 +04:00
parent 0ee5ba52c4
commit b9d6e29ca2

View File

@ -62,7 +62,7 @@ class ResourceProgramTransformer {
return Arrays.<Instruction>asList(accessInsn);
}
ClassReader iface = innerSource.get(method.getClassName());
if (iface.getAnnotations().get(Resource.class.getName()) == null) {
if (!isSubclass(iface, Resource.class.getName())) {
return null;
}
if (method.getName().startsWith("get")) {
@ -81,6 +81,23 @@ class ResourceProgramTransformer {
return null;
}
private boolean isSubclass(ClassReader cls, String superClass) {
if (cls.getName().equals(superClass)) {
return true;
}
ClassReader parent = cls.getParent() != null ? innerSource.get(cls.getParent()) : null;
if (parent != null && isSubclass(parent, superClass)) {
return true;
}
for (String ifaceName : cls.getInterfaces()) {
ClassReader iface = innerSource.get(ifaceName);
if (iface != null) {
return isSubclass(iface, superClass);
}
}
return false;
}
private List<Instruction> transformGetterInvocation(InvokeInstruction insn, String property) {
if (insn.getReceiver() == null) {
return Collections.emptyList();