Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix javac @Delegate(types={...}) #32

Closed
wants to merge 1 commit into from

2 participants

@adambrewster

Here's my hack at fixing issue #359.

@rzwitserloot
Owner

This code is possibly an improvement, but doesn't fix #359. We've dropped tier 1 status for @Delegate (to be honest, it's been that way for a while now, we're just making it official), and we're giving up on fixing #359.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 4, 2012
  1. fix javac @Delegate(types={...})

    Adam Brewster authored
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 1 deletion.
  1. +26 −1 src/core/lombok/javac/handlers/HandleDelegate.java
View
27 src/core/lombok/javac/handlers/HandleDelegate.java
@@ -24,6 +24,7 @@
import static lombok.javac.handlers.JavacHandlerUtil.*;
import static com.sun.tools.javac.code.Flags.*;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -130,12 +131,36 @@
if (delegateTypes.isEmpty()) {
if (delegateType != null) toDelegate.add(delegateType);
} else {
+ Types types = Types.instance(annotationNode.getContext());
+
for (Object dt : delegateTypes) {
if (dt instanceof JCFieldAccess && ((JCFieldAccess)dt).name.toString().equals("class")) {
Type type = ((JCFieldAccess)dt).selected.type;
if (type == null) reso.resolveClassMember(annotationNode);
type = ((JCFieldAccess)dt).selected.type;
- if (type != null) toDelegate.add(type);
+
+ if (type != null) {
+ // find the superclass or implemented interface of
+ // delegateType with the erasure of type.
+ ArrayDeque<Type> deque = new ArrayDeque<Type>();
+ deque.add(delegateType);
+ while (deque.size() > 0) {
+ ClassType tmpType = (ClassType) deque.removeFirst();
+
+ if (types.isSameType(types.erasure(tmpType), type)) {
+ type = tmpType;
+ break;
+ }
+
+ Type superType = types.supertype(tmpType);
+ if (superType != Type.noType) deque.addLast(superType);
+
+ List<Type> interfaces = types.interfaces(tmpType);
+ deque.addAll(interfaces);
+ }
+
+ toDelegate.add(type);
+ }
}
}
}
Something went wrong with that request. Please try again.