Implement serialization of inner types
This commit is contained in:
+29
-4
@@ -471,7 +471,11 @@ public class DescriptorSerializer {
|
||||
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
builder.setClassName(getClassId((ClassDescriptor) descriptor));
|
||||
PossiblyInnerType possiblyInnerType = TypeParameterUtilsKt.buildPossiblyInnerType(type);
|
||||
assert possiblyInnerType != null : "possiblyInnerType should not be null in case of class";
|
||||
|
||||
fillFromPossiblyInnerType(builder, possiblyInnerType);
|
||||
|
||||
}
|
||||
if (descriptor instanceof TypeParameterDescriptor) {
|
||||
TypeParameterDescriptor typeParameter = (TypeParameterDescriptor) descriptor;
|
||||
@@ -481,10 +485,8 @@ public class DescriptorSerializer {
|
||||
else {
|
||||
builder.setTypeParameter(getTypeParameterId(typeParameter));
|
||||
}
|
||||
}
|
||||
|
||||
for (TypeProjection projection : type.getArguments()) {
|
||||
builder.addArgument(typeArgument(projection));
|
||||
assert type.getArguments().isEmpty() : "Found arguments for type constructor build on type parameter: " + descriptor;
|
||||
}
|
||||
|
||||
if (type.isMarkedNullable() != builder.getNullable()) {
|
||||
@@ -496,6 +498,29 @@ public class DescriptorSerializer {
|
||||
return builder;
|
||||
}
|
||||
|
||||
private void fillFromPossiblyInnerType(
|
||||
@NotNull ProtoBuf.Type.Builder builder,
|
||||
@NotNull PossiblyInnerType type
|
||||
) {
|
||||
builder.setClassName(getClassId(type.getClassDescriptor()));
|
||||
|
||||
for (TypeProjection projection : type.getArguments()) {
|
||||
builder.addArgument(typeArgument(projection));
|
||||
}
|
||||
|
||||
if (type.getOuterType() != null) {
|
||||
ProtoBuf.Type.Builder outerBuilder = ProtoBuf.Type.newBuilder();
|
||||
fillFromPossiblyInnerType(outerBuilder, type.getOuterType());
|
||||
if (useTypeTable()) {
|
||||
builder.setOuterTypeId(typeTable.get(outerBuilder));
|
||||
}
|
||||
else {
|
||||
builder.setOuterType(outerBuilder);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ProtoBuf.Type.Argument.Builder typeArgument(@NotNull TypeProjection typeProjection) {
|
||||
ProtoBuf.Type.Argument.Builder builder = ProtoBuf.Type.Argument.newBuilder();
|
||||
|
||||
Reference in New Issue
Block a user