@@ -1067,6 +1067,42 @@ bool SILParser::parseASTType(CanType &result,
1067
1067
return false ;
1068
1068
}
1069
1069
1070
+ bool SILParser::parseASTTypeOrValue (CanType &result,
1071
+ GenericSignature genericSig,
1072
+ GenericParamList *genericParams,
1073
+ bool forceContextualType) {
1074
+ auto parsedType = P.parseTypeOrValue ();
1075
+ if (parsedType.isNull ()) return true ;
1076
+
1077
+ // If we weren't given a specific generic context to resolve the type
1078
+ // within, use the contextual generic parameters and always produce
1079
+ // a contextual type. Otherwise, produce a contextual type only if
1080
+ // we were asked for one.
1081
+ bool wantContextualType = forceContextualType;
1082
+ if (!genericSig) {
1083
+ genericSig = ContextGenericSig;
1084
+ wantContextualType = true ;
1085
+ }
1086
+ if (genericParams == nullptr )
1087
+ genericParams = ContextGenericParams;
1088
+
1089
+ bindSILGenericParams (parsedType.get ());
1090
+
1091
+ auto resolvedType = performTypeResolution (
1092
+ parsedType.get (), /* isSILType=*/ false , genericSig, genericParams);
1093
+ if (wantContextualType && genericSig) {
1094
+ resolvedType = genericSig.getGenericEnvironment ()
1095
+ ->mapTypeIntoContext (resolvedType);
1096
+ }
1097
+
1098
+ if (resolvedType->hasError ())
1099
+ return true ;
1100
+
1101
+ result = resolvedType->getCanonicalType ();
1102
+
1103
+ return false ;
1104
+ }
1105
+
1070
1106
void SILParser::bindSILGenericParams (TypeRepr *TyR) {
1071
1107
// Resolve the generic environments for parsed generic function and box types.
1072
1108
class HandleSILGenericParamsWalker : public ASTWalker {
@@ -3122,7 +3158,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
3122
3158
CanType paramType;
3123
3159
if (parseSILType (Ty) ||
3124
3160
parseVerbatim (" for" ) ||
3125
- parseASTType (paramType))
3161
+ parseASTTypeOrValue (paramType))
3126
3162
return true ;
3127
3163
3128
3164
ResultVal = B.createTypeValue (InstLoc, Ty, paramType);
0 commit comments