File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -85,3 +85,38 @@ func testCFStringAnyObjectType() {
8585 print ( " done " )
8686}
8787testCFStringAnyObjectType ( )
88+
89+ // https://github.com/apple/swift/issues/43022
90+ func testOptionalCFStringToStringAndNSString( ) {
91+ let optCFStr : CFString ? = " Swift " as CFString
92+
93+ // CHECK: {{^}}Optional(Swift){{$}}
94+ print ( optCFStr)
95+
96+ let swiftStr1 = optCFStr as? String
97+ let swiftStr2 = optCFStr as String ?
98+
99+ let nsStr1 = optCFStr as? NSString
100+ let nsStr2 = optCFStr as NSString ?
101+
102+ if let unwrapped = swiftStr1 {
103+ // CHECK-NEXT: {{^}}Swift{{$}}
104+ print ( unwrapped)
105+ }
106+ if let unwrapped = swiftStr2 {
107+ // CHECK-NEXT: {{^}}Swift{{$}}
108+ print ( unwrapped)
109+ }
110+ if let unwrapped = nsStr1 {
111+ // CHECK-NEXT: {{^}}Swift{{$}}
112+ print ( unwrapped)
113+ }
114+ if let unwrapped = nsStr2 {
115+ // CHECK-NEXT: {{^}}Swift{{$}}
116+ print ( unwrapped)
117+ }
118+
119+ // CHECK-NEXT: {{^}}done{{$}}
120+ print ( " done " )
121+ }
122+ testOptionalCFStringToStringAndNSString ( )
You can’t perform that action at this time.
0 commit comments