Merge pull request #70866 from kavon/ncgenerics-stdlib-building-v4

Build Stdlib with Noncopyable Generics (Part 4)
This commit is contained in:
Kavon Farvardin
2024-01-25 07:09:38 -08:00
committed by GitHub
84 changed files with 802 additions and 279 deletions

View File

@@ -462,8 +462,6 @@ CallExpr *
DerivedConformance::createBuiltinCall(ASTContext &ctx,
BuiltinValueKind builtin,
ArrayRef<Type> typeArgs,
ArrayRef<ProtocolConformanceRef>
conformances,
ArrayRef<Expr *> args) {
auto name = ctx.getIdentifier(getBuiltinName(builtin));
auto decl = getBuiltinValueDecl(ctx, name);
@@ -472,8 +470,21 @@ DerivedConformance::createBuiltinCall(ASTContext &ctx,
ConcreteDeclRef declRef = decl;
auto fnType = decl->getInterfaceType();
if (auto genericFnType = fnType->getAs<GenericFunctionType>()) {
auto builtinModule = decl->getModuleContext();
auto generics = genericFnType->getGenericSignature();
auto subs = SubstitutionMap::get(generics, typeArgs, conformances);
auto genericParams = generics.getGenericParams();
assert(genericParams.size() == typeArgs.size());
TypeSubstitutionMap map;
for (auto i : indices(genericParams))
map.insert({genericParams[i]->getCanonicalType()
->getAs<SubstitutableType>(),
typeArgs[i]});
auto subs = SubstitutionMap::get(generics,
QueryTypeSubstitutionMap{map},
LookUpConformanceInModule{builtinModule});
declRef = ConcreteDeclRef(decl, subs);
fnType = genericFnType->substGenericArgs(subs);
} else {