Skip to content

Commit 72e3086

Browse files
committed
Reflection: Record builtin and imported types referenced from captures
1 parent a86e39d commit 72e3086

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

lib/IRGen/GenReflection.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,6 @@ IRGenModule::getAddrOfBoxDescriptor(CanType BoxedType) {
819819
if (!IRGen.Opts.EnableReflectionMetadata)
820820
return llvm::Constant::getNullValue(CaptureDescriptorPtrTy);
821821

822-
llvm::SetVector<CanType> BuiltinTypes;
823822
BoxDescriptorBuilder builder(*this, BuiltinTypes, BoxedType);
824823

825824
auto var = builder.emit();
@@ -838,7 +837,6 @@ IRGenModule::getAddrOfCaptureDescriptor(SILFunction &Caller,
838837
if (!IRGen.Opts.EnableReflectionMetadata)
839838
return llvm::Constant::getNullValue(CaptureDescriptorPtrTy);
840839

841-
llvm::SetVector<CanType> BuiltinTypes;
842840
CaptureDescriptorBuilder builder(*this, BuiltinTypes, Caller,
843841
OrigCalleeType, SubstCalleeType, Subs,
844842
Layout);

test/Reflection/Inputs/ObjectiveCTypes.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ public class HasObjCClasses {
2828
let integer = NSInteger()
2929
}
3030

31+
public func closureHasObjCClasses(b: NSBundle) -> () -> () {
32+
return { _ = b }
33+
}

test/Reflection/typeref_decoding_objc.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// CHECK-32: integer: Swift.Int
1818
// CHECK-32: (struct Swift.Int)
1919

20+
// CHECK-32: __ObjC.NSBundle
21+
// CHECK-32: ---------------
2022
// CHECK-32: __ObjC.NSURL
2123
// CHECK-32: ------------
2224

@@ -26,6 +28,12 @@
2628
// CHECK-32: BUILTIN TYPES:
2729
// CHECK-32: ==============
2830

31+
// CHECK-32: - __ObjC.NSBundle:
32+
// CHECK-32: Size: 4
33+
// CHECK-32: Alignment: 4
34+
// CHECK-32: Stride: 4
35+
// CHECK-32: NumExtraInhabitants: 4096
36+
2937
// CHECK-32: - __ObjC.NSURL:
3038
// CHECK-32: Size: 4
3139
// CHECK-32: Alignment: 4
@@ -88,6 +96,9 @@
8896
// CHECK-64: integer: Swift.Int
8997
// CHECK-64: (struct Swift.Int)
9098

99+
// CHECK-64: __ObjC.NSBundle
100+
// CHECK-64: ------------
101+
91102
// CHECK-64: __ObjC.NSURL
92103
// CHECK-64: ------------
93104

@@ -97,6 +108,12 @@
97108
// CHECK-64: BUILTIN TYPES:
98109
// CHECK-64: ==============
99110

111+
// CHECK-64: - __ObjC.NSBundle:
112+
// CHECK-64: Size: 8
113+
// CHECK-64: Alignment: 8
114+
// CHECK-64: Stride: 8
115+
// CHECK-64: NumExtraInhabitants: 2147483647
116+
100117
// CHECK-64: - __ObjC.NSURL:
101118
// CHECK-64: Size: 8
102119
// CHECK-64: Alignment: 8

validation-test/Reflection/functions_objc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import SwiftReflectionTest
77
import Foundation
88

9-
func capturesImportedClass(x: Int, n: NSURLX, r: NSRect) {
9+
func capturesImportedClass(x: Int, n: NSURL, r: NSRect) {
1010
reflect(function: {print(x); print(n); print(r)})
1111

1212
// CHECK-32: Type reference:

0 commit comments

Comments
 (0)