@@ -3936,13 +3936,17 @@ class Serializer::TypeSerializer : public TypeVisitor<TypeSerializer> {
3936
3936
S.addSubstitutionMapRef (alias->getSubstitutionMap ()));
3937
3937
}
3938
3938
3939
+ template <typename Layout>
3940
+ void serializeSimpleWrapper (Type wrappedTy) {
3941
+ unsigned abbrCode = S.DeclTypeAbbrCodes [Layout::Code];
3942
+ Layout::emitRecord (S.Out , S.ScratchRecord , abbrCode,
3943
+ S.addTypeRef (wrappedTy));
3944
+ }
3945
+
3939
3946
void visitParenType (const ParenType *parenTy) {
3940
3947
using namespace decls_block ;
3941
3948
assert (parenTy->getParameterFlags ().isNone ());
3942
-
3943
- unsigned abbrCode = S.DeclTypeAbbrCodes [ParenTypeLayout::Code];
3944
- ParenTypeLayout::emitRecord (S.Out , S.ScratchRecord , abbrCode,
3945
- S.addTypeRef (parenTy->getUnderlyingType ()));
3949
+ serializeSimpleWrapper<ParenTypeLayout>(parenTy->getUnderlyingType ());
3946
3950
}
3947
3951
3948
3952
void visitTupleType (const TupleType *tupleTy) {
@@ -4014,10 +4018,8 @@ class Serializer::TypeSerializer : public TypeVisitor<TypeSerializer> {
4014
4018
4015
4019
void visitOpenedArchetypeType (const OpenedArchetypeType *archetypeTy) {
4016
4020
using namespace decls_block ;
4017
- unsigned abbrCode = S.DeclTypeAbbrCodes [OpenedArchetypeTypeLayout::Code];
4018
- OpenedArchetypeTypeLayout::emitRecord (
4019
- S.Out , S.ScratchRecord , abbrCode,
4020
- S.addTypeRef (archetypeTy->getOpenedExistentialType ()));
4021
+ serializeSimpleWrapper<OpenedArchetypeTypeLayout>(
4022
+ archetypeTy->getOpenedExistentialType ());
4021
4023
}
4022
4024
4023
4025
void
@@ -4113,10 +4115,8 @@ class Serializer::TypeSerializer : public TypeVisitor<TypeSerializer> {
4113
4115
4114
4116
void visitSILBlockStorageType (const SILBlockStorageType *storageTy) {
4115
4117
using namespace decls_block ;
4116
- unsigned abbrCode = S.DeclTypeAbbrCodes [SILBlockStorageTypeLayout::Code];
4117
- SILBlockStorageTypeLayout::emitRecord (
4118
- S.Out , S.ScratchRecord , abbrCode,
4119
- S.addTypeRef (storageTy->getCaptureType ()));
4118
+ serializeSimpleWrapper<SILBlockStorageTypeLayout>(
4119
+ storageTy->getCaptureType ());
4120
4120
}
4121
4121
4122
4122
void visitSILBoxType (const SILBoxType *boxTy) {
@@ -4182,10 +4182,7 @@ class Serializer::TypeSerializer : public TypeVisitor<TypeSerializer> {
4182
4182
4183
4183
void visitArraySliceType (const ArraySliceType *sliceTy) {
4184
4184
using namespace decls_block ;
4185
- Type base = sliceTy->getBaseType ();
4186
- unsigned abbrCode = S.DeclTypeAbbrCodes [ArraySliceTypeLayout::Code];
4187
- ArraySliceTypeLayout::emitRecord (S.Out , S.ScratchRecord , abbrCode,
4188
- S.addTypeRef (base));
4185
+ serializeSimpleWrapper<ArraySliceTypeLayout>(sliceTy->getBaseType ());
4189
4186
}
4190
4187
4191
4188
void visitDictionaryType (const DictionaryType *dictTy) {
@@ -4198,10 +4195,7 @@ class Serializer::TypeSerializer : public TypeVisitor<TypeSerializer> {
4198
4195
4199
4196
void visitOptionalType (const OptionalType *optionalTy) {
4200
4197
using namespace decls_block ;
4201
- Type base = optionalTy->getBaseType ();
4202
- unsigned abbrCode = S.DeclTypeAbbrCodes [OptionalTypeLayout::Code];
4203
- OptionalTypeLayout::emitRecord (S.Out , S.ScratchRecord , abbrCode,
4204
- S.addTypeRef (base));
4198
+ serializeSimpleWrapper<OptionalTypeLayout>(optionalTy->getBaseType ());
4205
4199
}
4206
4200
4207
4201
void
0 commit comments