Skip to content

Commit

Permalink
Invasive, hardcoded changes for JSpecify handling of unbounded wildca…
Browse files Browse the repository at this point in the history
…rds.
  • Loading branch information
cpovirk committed Oct 14, 2020
1 parent d1aba1c commit 00cc056
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,26 +577,20 @@ public void initializeExtendsBound(AnnotatedWildcardType wildcard) {
AnnotatedTypeFactory typeFactory = wildcard.atypeFactory;

WildcardType javaWildcardType = wildcard.getUnderlyingType();
TypeMirror javaExtendsBound;
AnnotatedTypeMirror extendsBound;
if (javaWildcardType.getExtendsBound() != null) {
// If the wildcard type has an extends bound, use it.
javaExtendsBound = javaWildcardType.getExtendsBound();
} else if (wildcard.getTypeVariable() != null) {
// Otherwise use the upper bound of the type variable associated with this wildcard.
javaExtendsBound = wildcard.getTypeVariable().getUpperBound();
extendsBound =
AnnotatedTypeMirror.createType(
javaWildcardType.getExtendsBound(), typeFactory, false);
} else {
// Otherwise use the upper bound of the java wildcard.
javaExtendsBound =
TypesUtils.wildUpperBound(
javaWildcardType, wildcard.atypeFactory.processingEnv);
extendsBound = AnnotatedTypeMirror.createTypeOfObject(wildcard.atypeFactory);
}

if (wildcard.isUninferredTypeArgument()) {
rawTypeWildcards.put(wildcard.getTypeVariable(), wildcard.getUnderlyingType());
}

AnnotatedTypeMirror extendsBound =
AnnotatedTypeMirror.createType(javaExtendsBound, typeFactory, false);
wildcard.setExtendsBound(extendsBound);

this.wildcards.put(wildcard.getUnderlyingType(), wildcard);
Expand Down

0 comments on commit 00cc056

Please sign in to comment.