Skip to content

Commit 464dac7

Browse files
committed
Reinstate "AST: Fix excessive deserialization in GenericSignatureBuilder"
This reverts commit d3926d1.
1 parent 966f616 commit 464dac7

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,16 @@ auto GenericSignatureBuilder::PotentialArchetype::getNestedType(
554554
SmallVector<std::pair<ProtocolDecl *, RequirementSource>, 4>
555555
conformsTo(rep->ConformsTo.begin(), rep->ConformsTo.end());
556556
for (auto &conforms : conformsTo) {
557-
for (auto member : conforms.first->lookupDirect(nestedName)) {
557+
// Make sure we don't trigger deserialization of extensions,
558+
// since they can refer back to a protocol we're currently
559+
// type checking.
560+
//
561+
// Note that typealiases in extensions won't matter here,
562+
// because a typealias is never going to be a representative
563+
// PA.
564+
auto members = conforms.first->lookupDirect(nestedName,
565+
/*ignoreNewExtensions=*/true);
566+
for (auto member : members) {
558567
PotentialArchetype *pa;
559568

560569
if (auto assocType = dyn_cast<AssociatedTypeDecl>(member)) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public protocol A {
2+
associatedtype T : B
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public protocol BB {
2+
associatedtype T
3+
}
4+
5+
public protocol B {
6+
associatedtype T : BB
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extension B {
2+
public init?<T : A>(_: T) where T.T == Self {
3+
return nil
4+
}
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: rm -rf %t && mkdir -p %t
2+
3+
// RUN: %target-swift-frontend -emit-module -module-name Multi -o %t/a.swiftmodule -primary-file %S/Inputs/circular-associated-type/a.swift %S/Inputs/circular-associated-type/b.swift %S/Inputs/circular-associated-type/c.swift
4+
// RUN: %target-swift-frontend -emit-module -module-name Multi -o %t/b.swiftmodule -primary-file %S/Inputs/circular-associated-type/b.swift %S/Inputs/circular-associated-type/a.swift %S/Inputs/circular-associated-type/c.swift
5+
// RUN: %target-swift-frontend -emit-module -module-name Multi -o %t/c.swiftmodule -primary-file %S/Inputs/circular-associated-type/c.swift %S/Inputs/circular-associated-type/a.swift %S/Inputs/circular-associated-type/b.swift
6+
7+
// RUN: %target-swift-frontend -parse-as-library -emit-module -module-name Multi %t/a.swiftmodule %t/b.swiftmodule %t/c.swiftmodule -o %t
8+

0 commit comments

Comments
 (0)