@@ -173,8 +173,8 @@ namespace {
173
173
// / A callback to be invoked every time a type was deserialized.
174
174
std::function<void (Type)> ParsedTypeCallback;
175
175
176
- Type performTypeLocChecking (TypeRepr *TyR, bool IsSILType,
177
- GenericEnvironment *GenericEnv = nullptr );
176
+ Type performTypeResolution (TypeRepr *TyR, bool IsSILType,
177
+ GenericEnvironment *GenericEnv);
178
178
179
179
void convertRequirements (SILFunction *F, ArrayRef<RequirementRepr> From,
180
180
SmallVectorImpl<Requirement> &To);
@@ -867,9 +867,10 @@ void SILParser::convertRequirements(SILFunction *F,
867
867
IdentTypeReprLookup PerformLookup (P);
868
868
// Use parser lexical scopes to resolve references
869
869
// to the generic parameters.
870
- auto ResolveToInterfaceType = [&](TypeRepr *Ty) -> Type {
871
- Ty->walk (PerformLookup);
872
- return performTypeLocChecking (Ty, /* IsSIL */ false )->mapTypeOutOfContext ();
870
+ auto ResolveToInterfaceType = [&](TypeRepr *TyR) -> Type {
871
+ TyR->walk (PerformLookup);
872
+ return performTypeResolution (TyR, /* IsSILType=*/ false , ContextGenericEnv)
873
+ ->mapTypeOutOfContext ();
873
874
};
874
875
875
876
for (auto &Req : From) {
@@ -1091,16 +1092,14 @@ static bool parseDeclSILOptional(bool *isTransparent,
1091
1092
return false ;
1092
1093
}
1093
1094
1094
- Type SILParser::performTypeLocChecking (TypeRepr *T , bool IsSILType,
1095
- GenericEnvironment *GenericEnv) {
1095
+ Type SILParser::performTypeResolution (TypeRepr *TyR , bool IsSILType,
1096
+ GenericEnvironment *GenericEnv) {
1096
1097
if (GenericEnv == nullptr )
1097
1098
GenericEnv = ContextGenericEnv;
1098
1099
1099
- TypeLoc loc (T);
1100
- (void ) swift::performTypeLocChecking (P.Context , loc,
1101
- /* isSILMode=*/ true , IsSILType,
1102
- GenericEnv, &P.SF );
1103
- return loc.getType ();
1100
+ return swift::performTypeResolution (TyR, P.Context ,
1101
+ /* isSILMode=*/ true , IsSILType, GenericEnv,
1102
+ &P.SF );
1104
1103
}
1105
1104
1106
1105
// / Find the top-level ValueDecl or Module given a name.
@@ -1154,7 +1153,8 @@ static ValueDecl *lookupMember(Parser &P, Type Ty, DeclBaseName Name,
1154
1153
bool SILParser::parseASTType (CanType &result, GenericEnvironment *env) {
1155
1154
ParserResult<TypeRepr> parsedType = P.parseType ();
1156
1155
if (parsedType.isNull ()) return true ;
1157
- auto resolvedType = performTypeLocChecking (parsedType.get (), /* IsSILType=*/ false , env);
1156
+ const auto resolvedType =
1157
+ performTypeResolution (parsedType.get (), /* isSILType=*/ false , env);
1158
1158
if (resolvedType->hasError ())
1159
1159
return true ;
1160
1160
@@ -1243,8 +1243,10 @@ bool SILParser::parseSILType(SILType &Result,
1243
1243
ParsedGenericEnv = env;
1244
1244
1245
1245
// Apply attributes to the type.
1246
- auto *attrRepr = P.applyAttributeToType (TyR.get (), attrs, specifier, specifierLoc);
1247
- auto Ty = performTypeLocChecking (attrRepr, /* IsSILType=*/ true , OuterGenericEnv);
1246
+ auto *attrRepr =
1247
+ P.applyAttributeToType (TyR.get (), attrs, specifier, specifierLoc);
1248
+ const auto Ty =
1249
+ performTypeResolution (attrRepr, /* IsSILType=*/ true , OuterGenericEnv);
1248
1250
if (Ty->hasError ())
1249
1251
return true ;
1250
1252
@@ -1696,7 +1698,8 @@ bool SILParser::parseSubstitutions(SmallVectorImpl<ParsedSubstitution> &parsed,
1696
1698
if (defaultForProto)
1697
1699
bindProtocolSelfInTypeRepr (TyR.get (), defaultForProto);
1698
1700
1699
- auto Ty = performTypeLocChecking (TyR.get (), /* IsSILType=*/ false , GenericEnv);
1701
+ const auto Ty =
1702
+ performTypeResolution (TyR.get (), /* IsSILType=*/ false , GenericEnv);
1700
1703
if (Ty->hasError ())
1701
1704
return true ;
1702
1705
parsed.push_back ({Loc, Ty});
@@ -2105,7 +2108,8 @@ bool SILParser::parseSILDeclRef(SILDeclRef &Member, bool FnTypeRequired) {
2105
2108
}
2106
2109
}
2107
2110
2108
- auto Ty = performTypeLocChecking (TyR.get (), /* IsSILType=*/ false , genericEnv);
2111
+ const auto Ty =
2112
+ performTypeResolution (TyR.get (), /* IsSILType=*/ false , genericEnv);
2109
2113
if (Ty->hasError ())
2110
2114
return true ;
2111
2115
@@ -6321,7 +6325,8 @@ ProtocolConformanceRef SILParser::parseProtocolConformanceHelper(
6321
6325
bindProtocolSelfInTypeRepr (TyR.get (), defaultForProto);
6322
6326
}
6323
6327
6324
- auto ConformingTy = performTypeLocChecking (TyR.get (), /* IsSILType=*/ false , witnessEnv);
6328
+ const auto ConformingTy =
6329
+ performTypeResolution (TyR.get (), /* IsSILType=*/ false , witnessEnv);
6325
6330
if (ConformingTy->hasError ())
6326
6331
return ProtocolConformanceRef ();
6327
6332
@@ -6437,17 +6442,18 @@ static bool parseSILVTableEntry(
6437
6442
ParserResult<TypeRepr> TyR = P.parseType ();
6438
6443
if (TyR.isNull ())
6439
6444
return true ;
6440
- TypeLoc Ty = TyR. get ();
6445
+
6441
6446
if (isDefaultWitnessTable)
6442
6447
bindProtocolSelfInTypeRepr (TyR.get (), proto);
6443
- if (swift::performTypeLocChecking (P.Context , Ty,
6444
- /* isSILMode=*/ false ,
6445
- /* isSILType=*/ false ,
6446
- witnessEnv,
6447
- &P.SF ))
6448
+
6449
+ const auto Ty =
6450
+ swift::performTypeResolution (TyR.get (), P.Context ,
6451
+ /* isSILMode=*/ false ,
6452
+ /* isSILType=*/ false , witnessEnv, &P.SF );
6453
+ if (Ty->hasError ())
6448
6454
return true ;
6449
6455
6450
- assocOrSubject = Ty. getType () ->getCanonicalType ();
6456
+ assocOrSubject = Ty->getCanonicalType ();
6451
6457
}
6452
6458
if (!assocOrSubject)
6453
6459
return true ;
@@ -6498,19 +6504,19 @@ static bool parseSILVTableEntry(
6498
6504
ParserResult<TypeRepr> TyR = P.parseType ();
6499
6505
if (TyR.isNull ())
6500
6506
return true ;
6501
- TypeLoc Ty = TyR. get ();
6507
+
6502
6508
if (isDefaultWitnessTable)
6503
6509
bindProtocolSelfInTypeRepr (TyR.get (), proto);
6504
- if (swift::performTypeLocChecking (P.Context , Ty,
6505
- /* isSILMode=*/ false ,
6506
- /* isSILType=*/ false ,
6507
- witnessEnv,
6508
- &P.SF ))
6510
+
6511
+ const auto Ty =
6512
+ swift::performTypeResolution (TyR.get (), P.Context ,
6513
+ /* isSILMode=*/ false ,
6514
+ /* isSILType=*/ false , witnessEnv, &P.SF );
6515
+ if (Ty->hasError ())
6509
6516
return true ;
6510
6517
6511
- witnessEntries.push_back (SILWitnessTable::AssociatedTypeWitness{
6512
- assoc, Ty.getType ()->getCanonicalType ()
6513
- });
6518
+ witnessEntries.push_back (
6519
+ SILWitnessTable::AssociatedTypeWitness{assoc, Ty->getCanonicalType ()});
6514
6520
return false ;
6515
6521
}
6516
6522
0 commit comments