@@ -1058,6 +1058,42 @@ bool SILParser::parseASTType(CanType &result,
1058
1058
return false ;
1059
1059
}
1060
1060
1061
+ bool SILParser::parseASTTypeOrValue (CanType &result,
1062
+ GenericSignature genericSig,
1063
+ GenericParamList *genericParams,
1064
+ bool forceContextualType) {
1065
+ auto parsedType = P.parseTypeOrValue ();
1066
+ if (parsedType.isNull ()) return true ;
1067
+
1068
+ // If we weren't given a specific generic context to resolve the type
1069
+ // within, use the contextual generic parameters and always produce
1070
+ // a contextual type. Otherwise, produce a contextual type only if
1071
+ // we were asked for one.
1072
+ bool wantContextualType = forceContextualType;
1073
+ if (!genericSig) {
1074
+ genericSig = ContextGenericSig;
1075
+ wantContextualType = true ;
1076
+ }
1077
+ if (genericParams == nullptr )
1078
+ genericParams = ContextGenericParams;
1079
+
1080
+ bindSILGenericParams (parsedType.get ());
1081
+
1082
+ auto resolvedType = performTypeResolution (
1083
+ parsedType.get (), /* isSILType=*/ false , genericSig, genericParams);
1084
+ if (wantContextualType && genericSig) {
1085
+ resolvedType = genericSig.getGenericEnvironment ()
1086
+ ->mapTypeIntoContext (resolvedType);
1087
+ }
1088
+
1089
+ if (resolvedType->hasError ())
1090
+ return true ;
1091
+
1092
+ result = resolvedType->getCanonicalType ();
1093
+
1094
+ return false ;
1095
+ }
1096
+
1061
1097
void SILParser::bindSILGenericParams (TypeRepr *TyR) {
1062
1098
// Resolve the generic environments for parsed generic function and box types.
1063
1099
class HandleSILGenericParamsWalker : public ASTWalker {
@@ -3098,7 +3134,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
3098
3134
CanType paramType;
3099
3135
if (parseSILType (Ty) ||
3100
3136
parseVerbatim (" for" ) ||
3101
- parseASTType (paramType))
3137
+ parseASTTypeOrValue (paramType))
3102
3138
return true ;
3103
3139
3104
3140
ResultVal = B.createTypeValue (InstLoc, Ty, paramType);
0 commit comments