Package com.google.turbine.binder
Class DisambiguateTypeAnnotations
- java.lang.Object
-
- com.google.turbine.binder.DisambiguateTypeAnnotations
-
public final class DisambiguateTypeAnnotations extends java.lang.ObjectDisambiguate annotations on field, parameter, and method return types that could be declaration or type annotations.Given a declaration like
private @A int x;or@A private int x;, there are three possibilities:@Ais a declaration annotation on the field.@Ais aTYPE_USEannotation on the type.@AsetsTYPE_USEandFIELDtargets, and appears in the bytecode as both a declaration annotation and as a type annotation.
This can't be disambiguated syntactically (note that the presence of other modifiers before or after the annotation has no bearing on whether it's a type annotation). So, we wait until constant binding is done, read the
@Targetmeta-annotation for each ambiguous annotation, and move it to the appropriate location.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SourceTypeBoundClassbind(SourceTypeBoundClass base, Env<ClassSymbol,TypeBoundClass> env)static com.google.common.collect.ImmutableList<AnnoInfo>groupRepeated(Env<ClassSymbol,TypeBoundClass> env, com.google.common.collect.ImmutableList<AnnoInfo> annotations)Group repeated annotations and wrap them in their container annotation.
-
-
-
Method Detail
-
bind
public static SourceTypeBoundClass bind(SourceTypeBoundClass base, Env<ClassSymbol,TypeBoundClass> env)
-
groupRepeated
public static com.google.common.collect.ImmutableList<AnnoInfo> groupRepeated(Env<ClassSymbol,TypeBoundClass> env, com.google.common.collect.ImmutableList<AnnoInfo> annotations)
Group repeated annotations and wrap them in their container annotation.For example, convert
@Foo @Footo@Foos({@Foo, @Foo}).This method is used by
DisambiguateTypeAnnotationsfor declaration annotations, and byLowerfor type annotations. We could group type annotations here, but it would require another rewrite pass.
-
-