Files
swift-mirror/validation-test/IRGen/sr6844.swift
Jordan Rose 520d6b9b91 Make NS_TYPED_ENUMS ObjectiveCBridgeable when they wrap an object (#15270)
This allows them to be used in generic arguments for NSArray et al.
We already do this for the ones that wrap bridged values (like
NSString/String), but failed to do it for objects that /weren't/
bridged to Swift values (class instances and protocol compositions),
or for Error-which-is-special.

In addition to this being a sensible thing to do, /not/ doing this led
to IRGen getting very confused (i.e. crashing) when we imported a
Objective-C protocol that actually used an NS_TYPED_ENUM in this way.

(We actually shouldn't be using Swift's IRGen logic to emit protocol
descriptors for imported protocols at all, because it's possible we
weren't able to import all the requirements. But that's a separate
issue.)

https://bugs.swift.org/browse/SR-6844
2018-03-15 16:17:38 -07:00

31 lines
1.3 KiB
Swift

// RUN: %target-swift-frontend -emit-ir %s -import-objc-header %S/Inputs/sr6844.h | %FileCheck %s
// REQUIRES: objc_interop
import Foundation
// CHECK-LABEL: @_PROTOCOL_INSTANCE_METHODS_MyJSONSerializing = {{.+}} @"\01L_selector_data(JSONKeyPathsByPropertyKey)"
// CHECK: [[OBJC_PROPNAME:@.+]] = private unnamed_addr constant [{{.+}} x i8] c"JSONKeyPathsByPropertyKey\00"
// CHECK: [[PROPKIND:@.+]] = private unnamed_addr constant [{{.+}} x i8] c"T@\22NSDictionary\22,N,R\00"
// CHECK: @_PROTOCOL_PROPERTIES_MyJSONSerializing =
// CHECK-SAME: [[OBJC_PROPNAME]]
// CHECK-SAME: [[PROPKIND]]
// CHECK-LABEL: @_PROTOCOL_INSTANCE_METHODS__TtP6sr684418MyJSONSerializing2_ = {{.+}} @"\01L_selector_data(JSONKeyPathsByPropertyKey2)"
// CHECK: [[SWIFT_PROPNAME:@.+]] = private unnamed_addr constant [{{.+}} x i8] c"JSONKeyPathsByPropertyKey2\00"
// CHECK: @_PROTOCOL_PROPERTIES__TtP6sr684418MyJSONSerializing2_ =
// CHECK-SAME: [[SWIFT_PROPNAME]]
// CHECK-SAME: [[PROPKIND]]
@objc public protocol MyJSONSerializing2 {
var JSONKeyPathsByPropertyKey2: [String: MyJSONKeyPath]? { get }
}
extension MyJSONAdapter {
public func model<Model: MyJSONSerializing>(of _: Model.Type = Model.self) throws -> Model {
return __model() as! Model
}
public func model<Model: MyJSONSerializing2>(of _: Model.Type = Model.self) throws -> Model {
return __model() as! Model
}
}