@@ -68,14 +68,19 @@ public enum Kind {
6868 /** The {@link AnnotatedTypeFactory}. */
6969 protected final AnnotatedTypeFactory typeFactory ;
7070
71+ /** Whether the annotations on this type should be ignored. */
72+ public final boolean ignoreAnnotations ;
73+
7174 /**
7275 * Creates an {@link AbstractType}.
7376 *
7477 * @param context the context object
78+ * @param ignoreAnnotations whether the annotations on this type should be ignored
7579 */
76- protected AbstractType (Java8InferenceContext context ) {
80+ protected AbstractType (Java8InferenceContext context , boolean ignoreAnnotations ) {
7781 this .context = context ;
7882 this .typeFactory = context .typeFactory ;
83+ this .ignoreAnnotations = ignoreAnnotations ;
7984 }
8085
8186 /**
@@ -126,9 +131,11 @@ public final TypeKind getTypeKind() {
126131 *
127132 * @param atm annotated type mirror
128133 * @param type type mirror
134+ * @param ignoreAnnotations whether the annotations on this type should be ignored
129135 * @return the new type
130136 */
131- public abstract AbstractType create (AnnotatedTypeMirror atm , TypeMirror type );
137+ public abstract AbstractType create (
138+ AnnotatedTypeMirror atm , TypeMirror type , boolean ignoreAnnotations );
132139
133140 /**
134141 * Return the underlying Java type without inference variables.
@@ -183,7 +190,9 @@ public List<ProperType> getTypeParameterBounds() {
183190
184191 for (AnnotatedTypeParameterBounds bound : typeVars ) {
185192 TypeVariable typeVariable = (TypeVariable ) javaEle .next ().asType ();
186- bounds .add (new ProperType (bound .getUpperBound (), typeVariable .getUpperBound (), context ));
193+ bounds .add (
194+ new ProperType (
195+ bound .getUpperBound (), typeVariable .getUpperBound (), context , ignoreAnnotations ));
187196 }
188197 return bounds ;
189198 }
@@ -197,7 +206,7 @@ public List<ProperType> getTypeParameterBounds() {
197206 public AbstractType capture (Java8InferenceContext context ) {
198207 AnnotatedTypeMirror capturedType =
199208 context .typeFactory .applyCaptureConversion (getAnnotatedType ());
200- return create (capturedType , capturedType .getUnderlyingType ());
209+ return create (capturedType , capturedType .getUnderlyingType (), ignoreAnnotations );
201210 }
202211
203212 /**
@@ -228,7 +237,7 @@ public AbstractType asSuper(TypeMirror superType) {
228237 AnnotatedTypeMirror .createType (superType , typeFactory , type .isDeclaration ());
229238 typeFactory .initializeAtm (superAnnotatedType );
230239 AnnotatedTypeMirror asSuper = AnnotatedTypes .asSuper (typeFactory , type , superAnnotatedType );
231- return create (asSuper , asSuper .getUnderlyingType ());
240+ return create (asSuper , asSuper .getUnderlyingType (), ignoreAnnotations );
232241 }
233242
234243 /**
@@ -277,7 +286,7 @@ public AbstractType getFunctionTypeReturnType() {
277286 if (returnType .getKind () == TypeKind .VOID ) {
278287 return null ;
279288 }
280- return create (returnType , returnTypeJava );
289+ return create (returnType , returnTypeJava , ignoreAnnotations );
281290 } else {
282291 return null ;
283292 }
@@ -297,7 +306,7 @@ public List<AbstractType> getFunctionTypeParameterTypes() {
297306 List <AbstractType > params = new ArrayList <>();
298307 Iterator <? extends TypeMirror > iter = paramsTypeMirror .iterator ();
299308 for (AnnotatedTypeMirror param : pair .first .getParameterTypes ()) {
300- params .add (create (param , iter .next ()));
309+ params .add (create (param , iter .next (), ignoreAnnotations ));
301310 }
302311 return params ;
303312 } else {
@@ -385,7 +394,7 @@ public AbstractType replaceTypeArgs(List<AbstractType> args) {
385394 }
386395 newType .setTypeArguments (argTypes );
387396 newType .replaceAnnotations (getAnnotatedType ().getPrimaryAnnotations ());
388- return create (newType , newTypeJava );
397+ return create (newType , newTypeJava , ignoreAnnotations );
389398 }
390399
391400 /**
@@ -416,7 +425,7 @@ public AbstractType getMostSpecificArrayType() {
416425 TypeMirror typeMirror =
417426 TypesUtils .getMostSpecificArrayType (getJavaType (), context .modelTypes );
418427 if (msat != null ) {
419- return create (msat , typeMirror );
428+ return create (msat , typeMirror , ignoreAnnotations );
420429 }
421430 return null ;
422431 }
@@ -466,7 +475,7 @@ public List<AbstractType> getIntersectionBounds() {
466475 List <AbstractType > bounds = new ArrayList <>();
467476 for (AnnotatedTypeMirror bound :
468477 ((AnnotatedIntersectionType ) getAnnotatedType ()).directSupertypes ()) {
469- bounds .add (create (bound , iter .next ()));
478+ bounds .add (create (bound , iter .next (), ignoreAnnotations ));
470479 }
471480 return bounds ;
472481 }
@@ -478,7 +487,10 @@ public List<AbstractType> getIntersectionBounds() {
478487 */
479488 public AbstractType getTypeVarUpperBound () {
480489 TypeMirror javaUpperBound = ((TypeVariable ) getJavaType ()).getUpperBound ();
481- return create (((AnnotatedTypeVariable ) getAnnotatedType ()).getUpperBound (), javaUpperBound );
490+ return create (
491+ ((AnnotatedTypeVariable ) getAnnotatedType ()).getUpperBound (),
492+ javaUpperBound ,
493+ ignoreAnnotations );
482494 }
483495
484496 /**
@@ -490,7 +502,10 @@ public AbstractType getTypeVarUpperBound() {
490502 */
491503 public AbstractType getTypeVarLowerBound () {
492504 TypeMirror lowerBound = ((TypeVariable ) getJavaType ()).getLowerBound ();
493- return create (((AnnotatedTypeVariable ) getAnnotatedType ()).getLowerBound (), lowerBound );
505+ return create (
506+ ((AnnotatedTypeVariable ) getAnnotatedType ()).getLowerBound (),
507+ lowerBound ,
508+ ignoreAnnotations );
494509 }
495510
496511 /**
@@ -530,7 +545,7 @@ public List<AbstractType> getTypeArguments() {
530545 List <AbstractType > list = new ArrayList <>();
531546 for (AnnotatedTypeMirror typeArg :
532547 ((AnnotatedDeclaredType ) getAnnotatedType ()).getTypeArguments ()) {
533- list .add (create (typeArg , iter .next ()));
548+ list .add (create (typeArg , iter .next (), ignoreAnnotations ));
534549 }
535550 return list ;
536551 }
@@ -571,7 +586,9 @@ public AbstractType getWildcardLowerBound() {
571586 if (getJavaType ().getKind () == TypeKind .WILDCARD ) {
572587 WildcardType wild = (WildcardType ) getJavaType ();
573588 return create (
574- ((AnnotatedWildcardType ) getAnnotatedType ()).getSuperBound (), wild .getSuperBound ());
589+ ((AnnotatedWildcardType ) getAnnotatedType ()).getSuperBound (),
590+ wild .getSuperBound (),
591+ ignoreAnnotations );
575592 }
576593 return null ;
577594 }
@@ -587,7 +604,10 @@ public AbstractType getWildcardUpperBound() {
587604 if (upperBoundJava == null ) {
588605 upperBoundJava = context .object .getJavaType ();
589606 }
590- return create (((AnnotatedWildcardType ) getAnnotatedType ()).getExtendsBound (), upperBoundJava );
607+ return create (
608+ ((AnnotatedWildcardType ) getAnnotatedType ()).getExtendsBound (),
609+ upperBoundJava ,
610+ ignoreAnnotations );
591611 } else {
592612 return null ;
593613 }
@@ -600,7 +620,7 @@ public AbstractType getWildcardUpperBound() {
600620 */
601621 public AbstractType getErased () {
602622 TypeMirror typeMirror = context .env .getTypeUtils ().erasure (getJavaType ());
603- return create (getAnnotatedType ().getErased (), typeMirror );
623+ return create (getAnnotatedType ().getErased (), typeMirror , ignoreAnnotations );
604624 }
605625
606626 /**
@@ -611,7 +631,10 @@ public AbstractType getErased() {
611631 public final AbstractType getComponentType () {
612632 if (getJavaType ().getKind () == TypeKind .ARRAY ) {
613633 TypeMirror javaType = ((ArrayType ) getJavaType ()).getComponentType ();
614- return create (((AnnotatedArrayType ) getAnnotatedType ()).getComponentType (), javaType );
634+ return create (
635+ ((AnnotatedArrayType ) getAnnotatedType ()).getComponentType (),
636+ javaType ,
637+ ignoreAnnotations );
615638 } else {
616639 return null ;
617640 }
@@ -634,6 +657,9 @@ public boolean equals(Object o) {
634657 }
635658
636659 AbstractType that = (AbstractType ) o ;
660+ if (ignoreAnnotations != that .ignoreAnnotations ) {
661+ return false ;
662+ }
637663
638664 if (!context .equals (that .context )) {
639665 return false ;
0 commit comments