Skip to content

Commit 1d76ecb

Browse files
authored
Merge pull request #4239 from jrose-apple/swift-3-PrintAsObjC-existential-metatypes-are-metatypes-too
[PrintAsObjC] Handle forward-declarations for 'Class <SomeProto>'.
2 parents 888136f + c819278 commit 1d76ecb

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/PrintAsObjC/PrintAsObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ class ReferencedTypeFinder : private TypeVisitor<ReferencedTypeFinder> {
15601560
Callback(*this, nominal->getDecl());
15611561
}
15621562

1563-
void visitMetatypeType(MetatypeType *metatype) {
1563+
void visitAnyMetatypeType(AnyMetatypeType *metatype) {
15641564
visit(metatype->getInstanceType());
15651565
}
15661566

test/PrintAsObjC/classes.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,18 @@ class MyObject : NSObject {}
328328
// CHECK-NEXT: @end
329329
@objc protocol MyProtocol : NSObjectProtocol {}
330330

331+
// CHECK-LABEL: @protocol MyProtocolMetaOnly;
332+
// CHECK-LABEL: @interface MyProtocolMetaCheck
333+
// CHECK-NEXT: - (void)test:(Class <MyProtocolMetaOnly> _Nullable)x;
334+
// CHECK-NEXT: init
335+
// CHECK-NEXT: @end
336+
@objc class MyProtocolMetaCheck {
337+
func test(_ x: MyProtocolMetaOnly.Type?) {}
338+
}
339+
// CHECK-LABEL: @protocol MyProtocolMetaOnly
340+
// CHECK-NEXT: @end
341+
@objc protocol MyProtocolMetaOnly {}
342+
331343
// CHECK-LABEL: @interface Nested
332344
// CHECK-NEXT: init
333345
// CHECK-NEXT: @end

test/PrintAsObjC/extensions.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Foundation
1414
import AppKit
15+
import objc_generics
1516

1617
// CHECK-NOT: AppKit
1718

@@ -83,6 +84,13 @@ extension CGColor {
8384
func anyOldMethod() {}
8485
}
8586

87+
// CHECK-LABEL: @interface GenericClass (SWIFT_EXTENSION(extensions))
88+
// CHECK-NEXT: - (void)bar;
89+
// CHECK-NEXT: @end
90+
extension GenericClass {
91+
func bar() {}
92+
}
93+
8694
// NEGATIVE-NOT: NotObjC
8795
class NotObjC {}
8896
extension NotObjC {}

0 commit comments

Comments
 (0)