Skip to content

Commit 1bccf58

Browse files
committed
[Sema] -debug-generic-signatures prints conformances after they've been filled out.
If they're printed before being checked, they have little useful content: just (normal_conformance type=Basic protocol=P1), with no details about their contents at all.
1 parent 60b6789 commit 1bccf58

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4670,17 +4670,20 @@ void TypeChecker::checkConformancesInContext(DeclContext *dc,
46704670
inferStaticInitializeObjCMetadata(*this, classDecl);
46714671
}
46724672
}
4673+
}
4674+
4675+
// Check all conformances.
4676+
groupChecker.checkAllConformances();
46734677

4674-
// When requested, print out information about this conformance.
4675-
if (Context.LangOpts.DebugGenericSignatures) {
4678+
if (Context.LangOpts.DebugGenericSignatures) {
4679+
// Now that they're filled out, print out information about the conformances
4680+
// here, when requested.
4681+
for (auto conformance : conformances) {
46764682
dc->dumpContext();
46774683
conformance->dump();
46784684
}
46794685
}
46804686

4681-
// Check all conformances.
4682-
groupChecker.checkAllConformances();
4683-
46844687
// Catalog all of members of this declaration context that satisfy
46854688
// requirements of conformances in this context.
46864689
SmallVector<ValueDecl *, 16>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s 2>&1 | %FileCheck %s
2+
3+
// CHECK: Generic signature: <Self where Self : P1>
4+
// CHECK-NEXT: Canonical generic signature: <τ_0_0 where τ_0_0 : P1>
5+
// CHECK-LABEL: main.(file).P1@
6+
// CHECK: Requirement signature: <Self>
7+
// CHECK-NEXT: Canonical requirement signature: <τ_0_0>
8+
protocol P1 {
9+
associatedtype A
10+
func f() -> A
11+
}
12+
13+
// CHECK-LABEL: StructDecl name=Basic
14+
// CHECK: (normal_conformance type=Basic protocol=P1
15+
// CHECK-NEXT: (assoc_type req=A type=Basic.A)
16+
// CHECK-NEXT: (value req=f() witness=main.(file).Basic.f()@{{.*}}))
17+
struct Basic: P1 {
18+
typealias A = Int
19+
func f() -> Int { fatalError() }
20+
}

test/Generics/conditional_conformances.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ struct InheritEqual<T> {}
217217
extension InheritEqual: P2 where T: P1 {}
218218
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InheritEqual<T>
219219
// CHECK-NEXT: (normal_conformance type=InheritEqual<T> protocol=P5
220+
// CHECK-NEXT: (normal_conformance type=InheritEqual<T> protocol=P2
221+
// CHECK-NEXT: conforms_to: T P1)
220222
// CHECK-NEXT: conforms_to: T P1)
221223
extension InheritEqual: P5 where T: P1 {}
222224
func inheritequal_good<U: P1>(_: U) {
@@ -249,6 +251,8 @@ struct InheritMore<T> {}
249251
extension InheritMore: P2 where T: P1 {}
250252
// CHECK-LABEL: ExtensionDecl line={{.*}} base=InheritMore<T>
251253
// CHECK-NEXT: (normal_conformance type=InheritMore<T> protocol=P5
254+
// CHECK-NEXT: (normal_conformance type=InheritMore<T> protocol=P2
255+
// CHECK-NEXT: conforms_to: T P1)
252256
// CHECK-NEXT: conforms_to: T P4)
253257
extension InheritMore: P5 where T: P4 {}
254258
func inheritequal_good_good<U: P4>(_: U) {

0 commit comments

Comments
 (0)