Skip to content

Commit b6c0963

Browse files
authored
Merge pull request #69409 from tshortli/silgen-conformance-lazy-typecheck
SILGen: Remove unnecessary assertion when emitting conformances
2 parents 3c7b71e + 1be7745 commit b6c0963

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

lib/SILGen/SILGenType.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,6 @@ class SILGenType : public TypeMemberVisitor<SILGenType> {
11351135
// are existential and do not have witness tables.
11361136
for (auto *conformance : theType->getLocalConformances(
11371137
ConformanceLookupKind::NonInherited)) {
1138-
assert(conformance->isComplete());
11391138
if (auto *normal = dyn_cast<NormalProtocolConformance>(conformance))
11401139
SGM.getWitnessTable(normal);
11411140
}
@@ -1300,7 +1299,6 @@ class SILGenExtension : public TypeMemberVisitor<SILGenExtension> {
13001299
// extension.
13011300
for (auto *conformance : e->getLocalConformances(
13021301
ConformanceLookupKind::All)) {
1303-
assert(conformance->isComplete());
13041302
if (auto *normal =dyn_cast<NormalProtocolConformance>(conformance))
13051303
SGM.getWitnessTable(normal);
13061304
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// RUN: %target-swift-frontend -emit-silgen %s -parse-as-library -module-name Test -experimental-lazy-typecheck | %FileCheck %s
2+
3+
public protocol Proto {
4+
func requirement()
5+
}
6+
7+
public protocol ProtoWithAssociatedType {
8+
associatedtype A
9+
func requirement() -> A
10+
func otherRequirement(_ a: A)
11+
}
12+
13+
public struct StructConformingToProto: Proto {
14+
// CHECK: sil{{.*}} @$s4Test23StructConformingToProtoV11requirementyyF : $@convention(method) (StructConformingToProto) -> () {
15+
public func requirement() {}
16+
}
17+
18+
// CHECK: sil shared [transparent] [serialized] [thunk]{{.*}} @$s4Test23StructConformingToProtoVAA0E0A2aDP11requirementyyFTW : $@convention(witness_method: Proto) (@in_guaranteed StructConformingToProto) -> () {
19+
20+
public struct StructConformingToProtoInExtension {}
21+
22+
extension StructConformingToProtoInExtension: Proto {
23+
// CHECK: sil{{.*}} @$s4Test34StructConformingToProtoInExtensionV11requirementyyF : $@convention(method) (StructConformingToProtoInExtension) -> () {
24+
public func requirement() {}
25+
}
26+
// CHECK: sil shared [transparent] [serialized] [thunk]{{.*}} @$s4Test34StructConformingToProtoInExtensionVAA0E0A2aDP11requirementyyFTW : $@convention(witness_method: Proto) (@in_guaranteed StructConformingToProtoInExtension) -> () {
27+
28+
public struct StructConformingToProtoWithAssociatedType: ProtoWithAssociatedType {
29+
// CHECK: sil{{.*}} @$s4Test41StructConformingToProtoWithAssociatedTypeV11requirementSiyF : $@convention(method) (StructConformingToProtoWithAssociatedType) -> Int {
30+
public func requirement() -> Int { return 1 }
31+
32+
// CHECK: sil{{.*}} @$s4Test41StructConformingToProtoWithAssociatedTypeV16otherRequirementyySiF : $@convention(method) (Int, StructConformingToProtoWithAssociatedType) -> () {
33+
public func otherRequirement(_ a: A) {}
34+
}
35+
// CHECK: sil shared [transparent] [serialized] [thunk]{{.*}} @$s4Test41StructConformingToProtoWithAssociatedTypeVAA0efgH0A2aDP11requirement1AQzyFTW : $@convention(witness_method: ProtoWithAssociatedType) (@in_guaranteed StructConformingToProtoWithAssociatedType) -> @out Int {
36+
// CHECK: sil shared [transparent] [serialized] [thunk]{{.*}} @$s4Test41StructConformingToProtoWithAssociatedTypeVAA0efgH0A2aDP16otherRequirementyy1AQzFTW : $@convention(witness_method: ProtoWithAssociatedType) (@in_guaranteed Int, @in_guaranteed StructConformingToProtoWithAssociatedType) -> () {
37+
38+
// CHECK-LABEL: sil_witness_table [serialized] StructConformingToProto: Proto module Test {
39+
// CHECK-NEXT: method #Proto.requirement: <Self where Self : Proto> (Self) -> () -> () : @$s4Test23StructConformingToProtoVAA0E0A2aDP11requirementyyFTW
40+
// CHECK-NEXT: }
41+
42+
// CHECK-LABEL: sil_witness_table [serialized] StructConformingToProtoInExtension: Proto module Test {
43+
// CHECK-NEXT: method #Proto.requirement: <Self where Self : Proto> (Self) -> () -> () : @$s4Test34StructConformingToProtoInExtensionVAA0E0A2aDP11requirementyyFTW
44+
// CHECK-NEXT: }
45+
46+
// CHECK-LABEL: sil_witness_table [serialized] StructConformingToProtoWithAssociatedType: ProtoWithAssociatedType module Test {
47+
// CHECK-NEXT: associated_type A: Int
48+
// CHECK-NEXT: method #ProtoWithAssociatedType.requirement: <Self where Self : ProtoWithAssociatedType> (Self) -> () -> Self.A : @$s4Test41StructConformingToProtoWithAssociatedTypeVAA0efgH0A2aDP11requirement1AQzyFTW
49+
// CHECK-NEXT: method #ProtoWithAssociatedType.otherRequirement: <Self where Self : ProtoWithAssociatedType> (Self) -> (Self.A) -> () : @$s4Test41StructConformingToProtoWithAssociatedTypeVAA0efgH0A2aDP16otherRequirementyy1AQzFTW
50+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)