mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Mess with the way we do canonicalization for ProtocolCompositionTypes in a way
that doesn't violate canonical type invariants. It's still a little messy, but it's consistent. Fixes <rdar://problem/11886926>. Swift SVN r2368
This commit is contained in:
@@ -240,8 +240,8 @@ IdentifierType *IdentifierType::getNew(ASTContext &C,
|
||||
}
|
||||
|
||||
ProtocolCompositionType *
|
||||
ProtocolCompositionType::get(ASTContext &C, SourceLoc FirstLoc,
|
||||
ArrayRef<Type> Protocols) {
|
||||
ProtocolCompositionType::build(ASTContext &C, SourceLoc FirstLoc,
|
||||
ArrayRef<Type> Protocols) {
|
||||
// Check to see if we've already seen this protocol composition before.
|
||||
void *InsertPos = 0;
|
||||
llvm::FoldingSetNodeID ID;
|
||||
@@ -249,10 +249,17 @@ ProtocolCompositionType::get(ASTContext &C, SourceLoc FirstLoc,
|
||||
if (ProtocolCompositionType *Result
|
||||
= C.Impl.ProtocolCompositionTypes.FindNodeOrInsertPos(ID, InsertPos))
|
||||
return Result;
|
||||
|
||||
|
||||
bool isCanonical = true;
|
||||
for (Type t : Protocols) {
|
||||
if (!t->isCanonical())
|
||||
isCanonical = false;
|
||||
}
|
||||
|
||||
// Create a new protocol composition type.
|
||||
ProtocolCompositionType *New = new (C) ProtocolCompositionType(C, FirstLoc,
|
||||
Protocols);
|
||||
ProtocolCompositionType *New =
|
||||
new (C) ProtocolCompositionType(isCanonical ? &C : nullptr, FirstLoc,
|
||||
C.AllocateCopy(Protocols));
|
||||
C.Impl.ProtocolCompositionTypes.InsertNode(New, InsertPos);
|
||||
return New;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user