Skip to content

Commit

Permalink
Invasive, hardcoded changes for JSpecify substitution rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpovirk committed Oct 14, 2020
1 parent aa9ebc5 commit d1aba1c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,9 @@ public AnnotatedTypeMirror getLowerBound() {
// The type of "@Nullable X" has to be "@Nullable X extends @Nullable Object",
// because otherwise the annotations are inconsistent.
private void fixupBoundAnnotations() {
if (true) {
return;
}
if (!this.getAnnotationsField().isEmpty()) {
Set<AnnotationMirror> newAnnos = this.getAnnotationsField();
if (upperBound != null) {
Expand Down Expand Up @@ -1953,6 +1956,9 @@ public AnnotatedTypeMirror getExtendsBound() {
}

private void fixupBoundAnnotations() {
if (true) {
return;
}
if (!this.getAnnotationsField().isEmpty()) {
if (superBound != null) {
superBound.replaceAnnotations(this.getAnnotationsField());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,17 @@ public AnnotatedTypeMirror visitPrimitive_Wildcard(
private AnnotatedTypeMirror visitTypevar_NotTypevarNorWildcard(
AnnotatedTypeVariable type, AnnotatedTypeMirror superType, Void p) {
AnnotatedTypeMirror asSuper = visit(type.getUpperBound(), superType, p);
return copyPrimaryAnnos(type, asSuper);
for (AnnotationMirror onType : type.getAnnotations()) {
AnnotationMirror onSuper = asSuper.getAnnotationInHierarchy(onType);
AnnotationMirror result =
onSuper == null
? onType
: annotatedTypeFactory
.getQualifierHierarchy()
.leastUpperBound(onSuper, onType);
asSuper.replaceAnnotation(result);
}
return asSuper;
}

@Override
Expand Down Expand Up @@ -742,10 +752,19 @@ private AnnotatedTypeMirror visitWildcard_NotTypvarNorWildcard(
isUninferredTypeArgument = true;
}
AnnotatedTypeMirror asSuper = visit(type.getExtendsBound(), superType, p);
for (AnnotationMirror onType : type.getAnnotations()) {
AnnotationMirror onSuper = asSuper.getAnnotationInHierarchy(onType);
AnnotationMirror result =
onSuper == null
? onType
: annotatedTypeFactory
.getQualifierHierarchy()
.leastUpperBound(onSuper, onType);
asSuper.replaceAnnotation(result);
}
isUninferredTypeArgument = oldIsUninferredTypeArgument;
annotatedTypeFactory.addDefaultAnnotations(superType);

return copyPrimaryAnnos(type, asSuper);
return asSuper;
}

@Override
Expand Down

0 comments on commit d1aba1c

Please sign in to comment.