Skip to content

Commit c056b25

Browse files
committed
IRGen: Fix capture descriptor emission
1 parent c392b3b commit c056b25

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/IRGen/GenReflection.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@ class CaptureDescriptorBuilder : public ReflectionMetadataBuilder {
546546
// the bindings structure directly.
547547
auto &Bindings = Layout.getBindings();
548548
for (unsigned i = 0; i < Bindings.size(); ++i) {
549+
// Skip protocol requirements (FIXME: for now?)
550+
if (Bindings[i].Protocol != nullptr)
551+
continue;
552+
549553
auto Source = SourceBuilder.createClosureBinding(i);
550554
auto BindingType = Caller.mapTypeOutOfContext(Bindings[i].TypeParameter);
551555
SourceMap.push_back({BindingType->getCanonicalType(), Source});

test/IRGen/reflection_metadata.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
// CHECK-DAG: private constant [3 x i8] c"GS\00", section "{{[^"]*}}swift3_reflstr{{[^"]*}}"
3939
// CHECK-DAG: private constant [3 x i8] c"GE\00", section "{{[^"]*}}swift3_reflstr{{[^"]*}}"
4040

41-
// CHECK: @"\01l__swift3_reflection_metadata{{.*}}" = private constant <{ {{.*}} }>
41+
// CHECK-DAG: @"\01l__swift3_capture_descriptor" = private constant <{ {{.*}} }> <{ i32 1, i32 1, i32 2, {{.*}} }>
42+
43+
// CHECK-DAG: @"\01l__swift3_reflection_metadata{{.*}}" = private constant <{ {{.*}} }>
4244

4345
public protocol MyProtocol {
4446
associatedtype Inner
@@ -101,7 +103,6 @@ public enum MyGenericEnum<T : MyProtocol> {
101103
case I(Int)
102104
}
103105

104-
public func makeSomeClosures<T, U>(t: T, x: Int, y: MyGenericStruct<U>)
105-
-> (() -> (), () -> (), () -> ()) {
106-
return ({ _ = t }, { _ = x }, { _ = y })
106+
public func makeSomeClosures<T : MyProtocol>(t: T) -> (() -> ()) {
107+
return { _ = t }
107108
}

0 commit comments

Comments
 (0)