@@ -2078,6 +2078,24 @@ Optional<swift::ResilienceExpansion> getActualResilienceExpansion(uint8_t raw) {
2078
2078
return None;
2079
2079
}
2080
2080
2081
+ // / Translate from the serialization VarDeclSpecifier enumerators, which are
2082
+ // / guaranteed to be stable, to the AST ones.
2083
+ static Optional<swift::VarDecl::Specifier>
2084
+ getActualVarDeclSpecifier (serialization::VarDeclSpecifier raw) {
2085
+ switch (raw) {
2086
+ #define CASE (ID ) \
2087
+ case serialization::VarDeclSpecifier::ID: \
2088
+ return swift::VarDecl::Specifier::ID;
2089
+ CASE (Let)
2090
+ CASE (Var)
2091
+ CASE (InOut)
2092
+ CASE (Shared)
2093
+ }
2094
+ #undef CASE
2095
+ return None;
2096
+ }
2097
+
2098
+
2081
2099
void ModuleFile::configureStorage (AbstractStorageDecl *decl,
2082
2100
unsigned rawStorageKind,
2083
2101
serialization::DeclID getter,
@@ -2894,15 +2912,15 @@ ModuleFile::getDeclCheckedImpl(DeclID DID, Optional<DeclContext *> ForcedContext
2894
2912
DeclContextID contextID;
2895
2913
bool isImplicit, isObjC, isStatic, hasNonPatternBindingInit;
2896
2914
bool isGetterMutating, isSetterMutating;
2897
- unsigned specifier ;
2915
+ unsigned rawSpecifier ;
2898
2916
uint8_t storageKind, rawAccessLevel, rawSetterAccessLevel;
2899
2917
TypeID interfaceTypeID;
2900
2918
DeclID getterID, setterID, materializeForSetID, willSetID, didSetID;
2901
2919
DeclID addressorID, mutableAddressorID, overriddenID;
2902
2920
ArrayRef<uint64_t > dependencyIDs;
2903
2921
2904
2922
decls_block::VarLayout::readRecord (scratch, nameID, contextID,
2905
- isImplicit, isObjC, isStatic, specifier ,
2923
+ isImplicit, isObjC, isStatic, rawSpecifier ,
2906
2924
hasNonPatternBindingInit,
2907
2925
isGetterMutating, isSetterMutating,
2908
2926
storageKind, interfaceTypeID,
@@ -2954,9 +2972,15 @@ ModuleFile::getDeclCheckedImpl(DeclID DID, Optional<DeclContext *> ForcedContext
2954
2972
if (declOrOffset.isComplete ())
2955
2973
return declOrOffset;
2956
2974
2957
- auto var = createDecl<VarDecl>(/* IsStatic*/ isStatic,
2958
- (VarDecl::Specifier)specifier,
2959
- /* IsCaptureList*/ false , SourceLoc (), name,
2975
+ auto specifier = getActualVarDeclSpecifier (
2976
+ (serialization::VarDeclSpecifier)rawSpecifier);
2977
+ if (!specifier) {
2978
+ error ();
2979
+ return nullptr ;
2980
+ }
2981
+
2982
+ auto var = createDecl<VarDecl>(/* IsStatic*/ isStatic, *specifier,
2983
+ /* IsCaptureList*/ false , SourceLoc (), name,
2960
2984
Type (), DC);
2961
2985
var->setHasNonPatternBindingInit (hasNonPatternBindingInit);
2962
2986
var->setIsGetterMutating (isGetterMutating);
@@ -3003,18 +3027,25 @@ ModuleFile::getDeclCheckedImpl(DeclID DID, Optional<DeclContext *> ForcedContext
3003
3027
case decls_block::PARAM_DECL: {
3004
3028
IdentifierID argNameID, paramNameID;
3005
3029
DeclContextID contextID;
3006
- unsigned specifier ;
3030
+ unsigned rawSpecifier ;
3007
3031
TypeID interfaceTypeID;
3008
3032
3009
3033
decls_block::ParamLayout::readRecord (scratch, argNameID, paramNameID,
3010
- contextID, specifier, interfaceTypeID);
3034
+ contextID, rawSpecifier,
3035
+ interfaceTypeID);
3011
3036
3012
3037
auto DC = ForcedContext ? *ForcedContext : getDeclContext (contextID);
3013
3038
if (declOrOffset.isComplete ())
3014
3039
return declOrOffset;
3015
3040
3016
- auto param = createDecl<ParamDecl>((VarDecl::Specifier)specifier,
3017
- SourceLoc (), SourceLoc (),
3041
+ auto specifier = getActualVarDeclSpecifier (
3042
+ (serialization::VarDeclSpecifier)rawSpecifier);
3043
+ if (!specifier) {
3044
+ error ();
3045
+ return nullptr ;
3046
+ }
3047
+
3048
+ auto param = createDecl<ParamDecl>(*specifier, SourceLoc (), SourceLoc (),
3018
3049
getIdentifier (argNameID), SourceLoc (),
3019
3050
getIdentifier (paramNameID), Type (), DC);
3020
3051
0 commit comments