File tree 2 files changed +46
-3
lines changed 2 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -4630,9 +4630,14 @@ namespace {
4630
4630
auto convertKind = ConstantConvertKind::None;
4631
4631
// Request conversions on enums, and swift_wrapper((enum/struct))
4632
4632
// types
4633
- if (decl->getType()->isEnumeralType())
4634
- convertKind = ConstantConvertKind::Construction;
4635
- else if (findSwiftNewtype(decl, Impl.getClangSema(),
4633
+ if (decl->getType()->isEnumeralType()) {
4634
+ if (type->getEnumOrBoundGenericEnum()) {
4635
+ // When importing as an enum, also apply implicit force unwrap
4636
+ convertKind = ConstantConvertKind::ConstructionWithUnwrap;
4637
+ } else {
4638
+ convertKind = ConstantConvertKind::Construction;
4639
+ }
4640
+ } else if (findSwiftNewtype(decl, Impl.getClangSema(),
4636
4641
Impl.CurrentVersion))
4637
4642
convertKind = ConstantConvertKind::Construction;
4638
4643
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t/src)
2
+ // RUN: split-file %s %t/src
3
+
4
+ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %t/src/main.swift \
5
+ // RUN: -module-name main -I %t/src -emit-sil -sil-verify-all | %FileCheck %s
6
+
7
+ //--- test.h
8
+
9
+ typedef long NSInteger;
10
+ typedef enum XCTestErrorCode : NSInteger {
11
+ XCTestErrorCodeTimeoutWhileWaiting,
12
+ XCTestErrorCodeFailureWhileWaiting,
13
+ } XCTestErrorCode;
14
+
15
+ static XCTestErrorCode const XCTestErrorUnsupported = ( XCTestErrorCode) 109 ;
16
+
17
+ //--- Framework.apinotes
18
+ ---
19
+ Name: Framework
20
+ Tags:
21
+ - Name: XCTestErrorCode
22
+ NSErrorDomain: XCTestErrorDomain
23
+
24
+ //--- module.modulemap
25
+ module Framework {
26
+ header " test.h "
27
+ }
28
+
29
+ //--- main.swift
30
+ import Framework
31
+ func foo( ) {
32
+ print ( XCTestError . timeoutWhileWaiting)
33
+ print ( XCTestErrorUnsupported)
34
+ }
35
+
36
+
37
+ // CHECK: // XCTestErrorUnsupported.getter
38
+ // CHECK: sil shared [transparent] @$sSo22XCTestErrorUnsupportedSo0aB4CodeVvg : $@convention(thin) () -> XCTestError {
You can’t perform that action at this time.
0 commit comments