Skip to content

Commit e8b660a

Browse files
committed
---
yaml --- r: 345009 b: refs/heads/master c: 3b17a09 h: refs/heads/master i: 345007: e7533c6
1 parent 6364550 commit e8b660a

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8720c8ce9d90b53cd40cf8182ee72ea8ac88f0cc
2+
refs/heads/master: 3b17a0931282847a26cf939317d2111a3857dfa2
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/SIL/SILWitnessVisitor.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {
6161
SmallVector<AssociatedTypeDecl *, 2> associatedTypes;
6262
for (Decl *member : protocol->getMembers()) {
6363
if (auto associatedType = dyn_cast<AssociatedTypeDecl>(member)) {
64-
associatedTypes.push_back(associatedType);
64+
// If this is a new associated type (which does not override an
65+
// existing associated type), add it.
66+
if (associatedType->getOverriddenDecls().empty())
67+
associatedTypes.push_back(associatedType);
6568
}
6669
}
6770

@@ -70,7 +73,6 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {
7073
TypeDecl::compare);
7174

7275
for (auto *associatedType : associatedTypes) {
73-
// TODO: only add associated types when they're new?
7476
asDerived().addAssociatedType(AssociatedType(associatedType));
7577
}
7678
};

trunk/test/IRGen/generic_structs.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ struct GenericLayoutWithAssocType<T: ParentHasAssociatedType> {
262262
// CHECK: [[T4:%.*]] = call swiftcc %swift.metadata_response [[T3]](i64 0, %swift.type* %T, i8** [[T1]])
263263
// CHECK: %T.Assoc = extractvalue %swift.metadata_response [[T4]], 0
264264

265-
// CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** %T.ParentHasAssociatedType, i32 3
265+
// CHECK: [[T0:%.*]] = getelementptr inbounds i8*, i8** %T.ParentHasAssociatedType, i32 2
266266
// CHECK: [[T1:%.*]] = load i8*, i8** [[T0]],
267267
// CHECK: [[T2:%.*]] = bitcast i8* [[T1]] to i8** (%swift.type*, %swift.type*, i8**)*
268268
// CHECK: %T.Assoc.HasAssociatedType = call swiftcc i8** [[T2]](%swift.type* %T.Assoc, %swift.type* %T, i8** %T.ParentHasAssociatedType)

trunk/test/SILGen/witnesses_refinement.swift

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,44 @@ extension Int: Saturable {
1313
// CHECK-NOT: sil_witness_table Int: Equatable module witnesses_refinement {
1414
// CHECK-NOT: sil_witness_table Int: Comparable module witnesses_refinement {
1515
// CHECK: sil_witness_table hidden Int: Saturable module witnesses_refinement {
16+
17+
protocol P { }
18+
19+
protocol P0 {
20+
associatedtype A
21+
}
22+
23+
protocol P1 {
24+
associatedtype A
25+
}
26+
27+
protocol P2: P0 {
28+
associatedtype A
29+
}
30+
31+
protocol P3: P2, P1 {
32+
associatedtype A: P
33+
}
34+
35+
struct ConformsToP: P { }
36+
37+
// CHECK-LABEL: sil_witness_table hidden ConformsToP3: P3
38+
// CHECK: base_protocol P1
39+
// CHECK-NEXT: base_protocol P2
40+
// CHECK-NEXT: associated_type_protocol (A: P)
41+
// CHECK-NEXT: }
42+
struct ConformsToP3: P3 {
43+
typealias A = ConformsToP
44+
}
45+
46+
// CHECK-LABEL: sil_witness_table hidden ConformsToP3: P2
47+
// CHECK: base_protocol P0
48+
// CHECK-NEXT: }
49+
50+
// CHECK-LABEL: sil_witness_table hidden ConformsToP3: P1
51+
// CHECK: associated_type A: ConformsToP
52+
// CHECK-NEXT: }
53+
54+
// CHECK-LABEL: sil_witness_table hidden ConformsToP3: P0
55+
// CHECK: associated_type A: ConformsToP
56+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)