Use representative upper bound in JetTypeMapper instead of just the first
This commit is contained in:
@@ -509,10 +509,9 @@ public class JetTypeMapper {
|
||||
}
|
||||
|
||||
if (descriptor instanceof TypeParameterDescriptor) {
|
||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
|
||||
Type type = mapType(typeParameterDescriptor.getUpperBounds().iterator().next(), kind);
|
||||
Type type = mapType(getRepresentativeUpperBound((TypeParameterDescriptor) descriptor), kind);
|
||||
if (signatureVisitor != null) {
|
||||
signatureVisitor.writeTypeVariable(typeParameterDescriptor.getName(), type);
|
||||
signatureVisitor.writeTypeVariable(descriptor.getName(), type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -520,6 +519,18 @@ public class JetTypeMapper {
|
||||
throw new UnsupportedOperationException("Unknown type " + jetType);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static KotlinType getRepresentativeUpperBound(@NotNull TypeParameterDescriptor descriptor) {
|
||||
List<KotlinType> upperBounds = descriptor.getUpperBounds();
|
||||
assert !upperBounds.isEmpty() : "Upper bounds should not be empty: " + descriptor;
|
||||
for (KotlinType upperBound : upperBounds) {
|
||||
if (!isJvmInterface(upperBound)) {
|
||||
return upperBound;
|
||||
}
|
||||
}
|
||||
return CollectionsKt.first(upperBounds);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Type mapBuiltinType(@NotNull KotlinType type) {
|
||||
DeclarationDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
|
||||
Reference in New Issue
Block a user