diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-15 12:15:47 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-15 12:15:47 +0100 |
commit | 3d5f9b9f989a13d5f80e0aaced70a205e56e6ff9 (patch) | |
tree | 286f2a3da7aaf06ce245dd356d1d55fe6558eea3 /src/core/lombok/javac | |
parent | e8736d6b6449145c220404bb5480ffcbbd900030 (diff) | |
download | lombok-3d5f9b9f989a13d5f80e0aaced70a205e56e6ff9.tar.gz lombok-3d5f9b9f989a13d5f80e0aaced70a205e56e6ff9.tar.bz2 lombok-3d5f9b9f989a13d5f80e0aaced70a205e56e6ff9.zip |
Potential fix for issue #83.
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleSetter.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java index 1d1421b9..5acb47af 100644 --- a/src/core/lombok/javac/handlers/HandleSetter.java +++ b/src/core/lombok/javac/handlers/HandleSetter.java @@ -21,7 +21,13 @@ */ package lombok.javac.handlers; +import static com.sun.tools.javac.code.TypeTags.*; import static lombok.javac.handlers.JavacHandlerUtil.*; + +import javax.lang.model.type.NoType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeVisitor; + import lombok.AccessLevel; import lombok.Setter; import lombok.core.AnnotationValues; @@ -34,6 +40,8 @@ import lombok.javac.JavacNode; import org.mangosdk.spi.ProviderFor; import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.code.TypeTags; import com.sun.tools.javac.tree.TreeMaker; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCAssign; @@ -142,7 +150,7 @@ public class HandleSetter implements JavacAnnotationHandler<Setter> { JCBlock methodBody = treeMaker.Block(0, statements); Name methodName = field.toName(toSetterName(fieldDecl)); JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(Flags.FINAL, nonNulls.appendList(nullables)), fieldDecl.name, fieldDecl.vartype, null); - JCExpression methodType = treeMaker.Type(field.getSymbolTable().voidType); + JCExpression methodType = treeMaker.Type(new JCNoType(TypeTags.VOID)); List<JCTypeParameter> methodGenericParams = List.nil(); List<JCVariableDecl> parameters = List.of(param); @@ -152,4 +160,25 @@ public class HandleSetter implements JavacAnnotationHandler<Setter> { return treeMaker.MethodDef(treeMaker.Modifiers(access, List.<JCAnnotation>nil()), methodName, methodType, methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue); } + + private static class JCNoType extends Type implements NoType { + public JCNoType(int tag) { + super(tag, null); + } + + @Override + public TypeKind getKind() { + switch (tag) { + case VOID: return TypeKind.VOID; + case NONE: return TypeKind.NONE; + default: + throw new AssertionError("Unexpected tag: " + tag); + } + } + + @Override + public <R, P> R accept(TypeVisitor<R, P> v, P p) { + return v.visitNoType(this, p); + } + } } |