1
1
// RUN: %target-run-simple-swift | %FileCheck %s
2
2
// REQUIRES: executable_test
3
3
4
- // rdar://problem/27616753
5
- // XFAIL: *
6
-
7
4
// REQUIRES: objc_interop
8
5
9
6
import Foundation
@@ -139,14 +136,14 @@ if (obj as? SwiftSub) != nil { abort() }
139
136
if ( obj as? SwiftSuper ) == nil { abort ( ) }
140
137
141
138
// Test optional and non-optional bridged conversions
142
- var ao : AnyObject = " s "
139
+ var ao : AnyObject = " s " as NSObject
143
140
ao as! String
144
141
ao is String
145
142
146
- var auo : AnyObject ! = " s "
143
+ var auo : AnyObject ! = " s " as NSObject
147
144
var s : String = auo as! String
148
145
149
- var auoo : AnyObject ? = " s "
146
+ var auoo : AnyObject ? = " s " as NSObject
150
147
auoo! as? String
151
148
152
149
// Test bridged casts.
@@ -438,22 +435,25 @@ if let doubleArr = obj as? [Double] {
438
435
print ( " Numbers-as-doubles failed " )
439
436
}
440
437
441
- // CHECK: Numbers-as-floats cast produces [3.9375, 2.71828{{.*}}, 0.0]
438
+ // CHECK-FAIL: Numbers-as-floats cast produces [3.9375, 2.71828{{.*}}, 0.0]
439
+ // TODO: check if this is intention: rdar://33021520
442
440
if let floatArr = obj as? [ Float ] {
443
441
print ( MemoryLayout< Float> . size)
444
442
print ( " Numbers-as-floats cast produces \( floatArr) " )
445
443
} else {
446
444
print ( " Numbers-as-floats failed " )
447
445
}
448
446
449
- // CHECK: Numbers-as-ints cast produces [3, 2, 0]
447
+ // CHECK-FAIL: Numbers-as-ints cast produces [3, 2, 0]
448
+ // TODO: check if this is intention: rdar://33021520
450
449
if let intArr = obj as? [ Int ] {
451
450
print ( " Numbers-as-ints cast produces \( intArr) " )
452
451
} else {
453
452
print ( " Numbers-as-ints failed " )
454
453
}
455
454
456
- // CHECK: Numbers-as-bools cast produces [true, true, false]
455
+ // CHECK-FAIL: Numbers-as-bools cast produces [true, true, false]
456
+ // TODO: check if this is intention: rdar://33021520
457
457
if let boolArr = obj as? [ Bool ] {
458
458
print ( " Numbers-as-bools cast produces \( boolArr) " )
459
459
} else {
@@ -472,7 +472,7 @@ class Derived : Base {
472
472
}
473
473
474
474
// CHECK: Array-of-base cast produces [Derived, Derived, Base]
475
- obj = [ Derived ( ) , Derived ( ) , Base ( ) ]
475
+ obj = [ Derived ( ) , Derived ( ) , Base ( ) ] as NSObject
476
476
if let baseArr = obj as? [ Base ] {
477
477
print ( " Array-of-base cast produces \( baseArr) " )
478
478
} else {
@@ -508,13 +508,13 @@ if let dict = obj as? Dictionary<Derived, Derived> {
508
508
print ( " Not a dictionary of derived/derived " )
509
509
}
510
510
511
- let strArray : AnyObject = [ " hello " , " world " ]
512
- let intArray : AnyObject = [ 1 , 2 , 3 ]
511
+ let strArray : AnyObject = [ " hello " , " world " ] as NSObject
512
+ let intArray : AnyObject = [ 1 , 2 , 3 ] as NSObject
513
513
let dictArray : AnyObject = [ [ " hello " : 1 , " world " : 2 ] ,
514
- [ " swift " : 1 , " speedy " : 2 ] ]
514
+ [ " swift " : 1 , " speedy " : 2 ] ] as NSObject
515
515
516
516
// CHECK: Dictionary<String, AnyObject> is
517
- obj = [ " a " : strArray, " b " : intArray, " c " : dictArray]
517
+ obj = [ " a " : strArray, " b " : intArray, " c " : dictArray] as NSObject
518
518
if let dict = obj as? Dictionary < String , [ AnyObject ] > {
519
519
print ( " Dictionary<String, AnyObject> is \( dict) " )
520
520
} else {
@@ -551,7 +551,7 @@ if let array = obj as? [Dictionary<String, String>] {
551
551
}
552
552
553
553
// CHECK: Dictionary<String, [Dictionary<String, Int>]> is ["a": [
554
- obj = [ " a " : dictArray]
554
+ obj = [ " a " : dictArray] as NSObject
555
555
if let dict = obj as? Dictionary < String , [ Dictionary < String , Int > ] > {
556
556
print ( " Dictionary<String, [Dictionary<String, Int>]> is \( dict) " )
557
557
} else {
@@ -566,7 +566,7 @@ if let dict = obj as? Dictionary<String, [Dictionary<String, String>]> {
566
566
}
567
567
568
568
// CHECK: [Dictionary<String, [Dictionary<String, Int>]>] is
569
- obj = [ obj, obj, obj]
569
+ obj = [ obj, obj, obj] as NSObject
570
570
if let array = obj as? [ Dictionary < String , [ Dictionary < String , Int > ] > ] {
571
571
print ( " [Dictionary<String, [Dictionary<String, Int>]>] is \( array) " )
572
572
} else {
@@ -598,15 +598,15 @@ func downcastToStringArrayOptOpt(_ obj: AnyObject???!) {
598
598
}
599
599
600
600
// CHECK: {{^}}some(some(some(["a", "b", "c"]))){{$}}
601
- var objOptOpt : AnyObject ? ? = . some( . some( [ " a " , " b " , " c " ] ) )
601
+ var objOptOpt : AnyObject ? ? = . some( . some( [ " a " , " b " , " c " ] as NSObject ) )
602
602
downcastToStringArrayOptOpt ( objOptOpt)
603
603
604
604
// CHECK: {{^}}none{{$}}
605
- objOptOpt = . some( . some( [ 1 : " hello " , 2 : " swift " , 3 : " world " ] ) )
605
+ objOptOpt = . some( . some( [ 1 : " hello " , 2 : " swift " , 3 : " world " ] as NSObject ) )
606
606
downcastToStringArrayOptOpt ( objOptOpt)
607
607
608
608
// CHECK: {{^}}none{{$}}
609
- objOptOpt = . some( . some( [ 1 , 2 , 3 ] ) )
609
+ objOptOpt = . some( . some( [ 1 , 2 , 3 ] as NSObject ) )
610
610
downcastToStringArrayOptOpt ( objOptOpt)
611
611
612
612
print ( " ok " ) // CHECK: ok
0 commit comments