< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java

Print this page

 609          *
 610          * @param type The type to copy.
 611          * @param stopAt The type to stop at.
 612          * @param annotations The annotations to insert.
 613          * @return A copy of type that contains the annotations.
 614          */
 615         private Type typeWithAnnotations(final Type type,
 616                 final Type stopAt,
 617                 final List<Attribute.TypeCompound> annotations) {
 618             Visitor<Type, List<TypeCompound>> visitor =
 619                     new Type.Visitor<Type, List<Attribute.TypeCompound>>() {
 620                 @Override
 621                 public Type visitClassType(ClassType t, List<TypeCompound> s) {
 622                     // assert that t.constValue() == null?
 623                     if (t == stopAt ||
 624                         t.getEnclosingType() == Type.noType) {
 625                         return t.annotatedType(s);
 626                     } else {
 627                         ClassType ret = new ClassType(t.getEnclosingType().accept(this, s),
 628                                                       t.typarams_field, t.tsym,
 629                                                       t.getMetadata());
 630                         ret.all_interfaces_field = t.all_interfaces_field;
 631                         ret.allparams_field = t.allparams_field;
 632                         ret.interfaces_field = t.interfaces_field;
 633                         ret.rank_field = t.rank_field;
 634                         ret.supertype_field = t.supertype_field;
 635                         return ret;
 636                     }
 637                 }
 638 
 639                 @Override
 640                 public Type visitWildcardType(WildcardType t, List<TypeCompound> s) {
 641                     return t.annotatedType(s);
 642                 }
 643 
 644                 @Override
 645                 public Type visitArrayType(ArrayType t, List<TypeCompound> s) {
 646                     ArrayType ret = new ArrayType(t.elemtype.accept(this, s), t.tsym,
 647                                                   t.getMetadata());
 648                     return ret;
 649                 }

 609          *
 610          * @param type The type to copy.
 611          * @param stopAt The type to stop at.
 612          * @param annotations The annotations to insert.
 613          * @return A copy of type that contains the annotations.
 614          */
 615         private Type typeWithAnnotations(final Type type,
 616                 final Type stopAt,
 617                 final List<Attribute.TypeCompound> annotations) {
 618             Visitor<Type, List<TypeCompound>> visitor =
 619                     new Type.Visitor<Type, List<Attribute.TypeCompound>>() {
 620                 @Override
 621                 public Type visitClassType(ClassType t, List<TypeCompound> s) {
 622                     // assert that t.constValue() == null?
 623                     if (t == stopAt ||
 624                         t.getEnclosingType() == Type.noType) {
 625                         return t.annotatedType(s);
 626                     } else {
 627                         ClassType ret = new ClassType(t.getEnclosingType().accept(this, s),
 628                                                       t.typarams_field, t.tsym,
 629                                                       t.getMetadata(), t.getFlavor());
 630                         ret.all_interfaces_field = t.all_interfaces_field;
 631                         ret.allparams_field = t.allparams_field;
 632                         ret.interfaces_field = t.interfaces_field;
 633                         ret.rank_field = t.rank_field;
 634                         ret.supertype_field = t.supertype_field;
 635                         return ret;
 636                     }
 637                 }
 638 
 639                 @Override
 640                 public Type visitWildcardType(WildcardType t, List<TypeCompound> s) {
 641                     return t.annotatedType(s);
 642                 }
 643 
 644                 @Override
 645                 public Type visitArrayType(ArrayType t, List<TypeCompound> s) {
 646                     ArrayType ret = new ArrayType(t.elemtype.accept(this, s), t.tsym,
 647                                                   t.getMetadata());
 648                     return ret;
 649                 }
< prev index next >