File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -1183,7 +1183,7 @@ class DeclAndTypePrinter::Implementation
1183
1183
copyTy->isDictionary () ||
1184
1184
copyTy->isSet () ||
1185
1185
copyTy->isString () ||
1186
- (! getKnownTypeInfo (nominal) && getObjCBridgedClass (nominal) )) {
1186
+ getObjCBridgedClass (nominal)) {
1187
1187
// We fast-path the most common cases in the condition above.
1188
1188
os << " , copy" ;
1189
1189
} else if (copyTy->isUnmanaged ()) {
@@ -1371,10 +1371,15 @@ class DeclAndTypePrinter::Implementation
1371
1371
1372
1372
public:
1373
1373
// / If \p nominal is bridged to an Objective-C class (via a conformance to
1374
- // / _ObjectiveCBridgeable), return that class.
1374
+ // / _ObjectiveCBridgeable) and is not an imported Clang type or a known type,
1375
+ // / return that class.
1375
1376
// /
1376
1377
// / Otherwise returns null.
1377
1378
const ClassDecl *getObjCBridgedClass (const NominalTypeDecl *nominal) {
1379
+ // Print known types as their unbridged type.
1380
+ if (getKnownTypeInfo (nominal))
1381
+ return nullptr ;
1382
+
1378
1383
// Print imported bridgeable decls as their unbridged type.
1379
1384
if (nominal->hasClangNode ())
1380
1385
return nullptr ;
Original file line number Diff line number Diff line change
1
+ // Test that known types that conform to `_ObjectiveCBridgeable` import or
2
+ // forward-declare based on the Clang type in their known type mapping, not
3
+ // their bridged type.
4
+ //
5
+ // This is particularly important for `CGFloat`, which has a native Swift decl
6
+ // in the CoreGraphics overlay that shadows the imported Clang decl, so relying
7
+ // solely on whether or not the decl has a Clang node is not sufficient.
8
+
9
+ // RUN: %empty-directory(%t)
10
+ // RUN: %target-swift-frontend -typecheck %s -parse-as-library -emit-objc-header-path %t/swift.h
11
+ // RUN: %FileCheck %s < %t/swift.h
12
+
13
+ // REQUIRES: objc_interop
14
+
15
+ import CoreGraphics
16
+ import Foundation
17
+
18
+ // CHECK: @import CoreGraphics;
19
+
20
+ // CHECK-NOT: @class NSNumber;
21
+
22
+ // CHECK-LABEL: @interface Test : NSObject{{$}}
23
+ public class Test : NSObject {
24
+ // CHECK-NEXT: - (CGFloat)level
25
+ @objc public func level( ) -> CGFloat { 9000.0 }
26
+ // CHECK-NEXT: - (BOOL)isEnabled
27
+ @objc public func isEnabled( ) -> Bool { true }
28
+ // CHECK-NEXT: init
29
+ } // CHECK-NEXT: @end
You can’t perform that action at this time.
0 commit comments