Skip to content

Commit

Permalink
Do not build raw type descriptors for types with no type parameters.
Browse files Browse the repository at this point in the history
Instead use the unparameterized version. The main issue is that for types with no type variables the interning keys are the same for the unparameterized and the raw type but their internals differ and can cause errors if an raw type is returned instead of the unparameterized type.

PiperOrigin-RevId: 589809769
  • Loading branch information
rluble authored and copybara-github committed Dec 11, 2023
1 parent f721b50 commit fed9efd
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,15 @@ public int getMaxInterfaceDepth() {
*/
@Memoized
public DeclaredTypeDescriptor toRawTypeDescriptor() {
if (getTypeParameterDescriptors().isEmpty()) {
// The type does not declare any type variables, the raw type should equivalent to the
// unparameterized type. Return the nullable version explicitly since the unparameterized
// type descriptor is created with the default nullability of the scope.
return toUnparameterizedTypeDescriptor().toNullable();
}

// TODO(b/315520047): Evaluate whether this deep recursive construction of raw types is correct
// or if the raw types should always be equivalent to the unparameterized type.
return DeclaredTypeDescriptor.newBuilder()
.setTypeDeclaration(this)
.setEnclosingTypeDescriptor(
Expand Down

0 comments on commit fed9efd

Please sign in to comment.