[AST] Introduce BuiltinProtocolConformance

This commit is contained in:
Azoy
2020-05-23 11:07:38 -04:00
parent 64ec60bbd4
commit f21a306ae5
16 changed files with 294 additions and 27 deletions

View File

@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
@@ -562,6 +562,34 @@ ModuleFile::readConformanceChecked(llvm::BitstreamCursor &Cursor,
return ProtocolConformanceRef(conformance);
}
case BUILTIN_PROTOCOL_CONFORMANCE: {
TypeID conformingTypeID;
DeclID protoID;
size_t numConformances;
BuiltinProtocolConformanceLayout::readRecord(scratch, conformingTypeID,
protoID, numConformances);
Type conformingType = getType(conformingTypeID);
auto decl = getDeclChecked(protoID);
if (!decl)
return decl.takeError();
auto proto = cast<ProtocolDecl>(decl.get());
// Read the conformances.
SmallVector<ProtocolConformanceRef, 4> conformances;
conformances.reserve(numConformances);
for (unsigned i : range(numConformances)) {
(void)i;
conformances.push_back(readConformance(Cursor));
}
auto conformance = getContext().getBuiltinConformance(conformingType, proto,
conformances);
return ProtocolConformanceRef(conformance);
}
case NORMAL_PROTOCOL_CONFORMANCE_ID: {
NormalConformanceID conformanceID;
NormalProtocolConformanceIdLayout::readRecord(scratch, conformanceID);