Skip to content

Commit 6a3eecb

Browse files
committed
[Test] Split out the @objc bits of the new generic_casts.swift code.
rdar://problem/56044443
1 parent 3ff277d commit 6a3eecb

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

test/Interpreter/generic_casts.swift

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift | %FileCheck --check-prefix CHECK --check-prefix CHECK-ONONE %s
1+
// RUN: %target-run-simple-swift | %FileCheck --check-prefix CHECK --check-prefix CHECK-ONONE --dump-input fail %s
22
// RUN: %target-build-swift -O %s -o %t/a.out.optimized
33
// RUN: %target-codesign %t/a.out.optimized
44
// RUN: %target-run %t/a.out.optimized | %FileCheck %s
@@ -132,18 +132,14 @@ anyClassToCOrE(D()).print() // CHECK: D!
132132
anyClassToCOrE(X()).print() // CHECK: E!
133133

134134
protocol P {}
135-
@objc protocol PObjC {}
136135
struct PS: P {}
137136
enum PE: P {}
138-
class PC: P, PObjC {}
137+
class PC: P {}
139138
class PCSub: PC {}
140139

141140
func nongenericAnyIsP(type: Any.Type) -> Bool {
142141
return type is P.Type
143142
}
144-
func nongenericAnyIsPObjC(type: Any.Type) -> Bool {
145-
return type is PObjC.Type
146-
}
147143
func nongenericAnyIsPAndAnyObject(type: Any.Type) -> Bool {
148144
return type is (P & AnyObject).Type
149145
}
@@ -164,17 +160,6 @@ print(genericAnyIs(type: PC.self, to: P.self)) // CHECK-ONONE: true
164160
print(nongenericAnyIsP(type: PCSub.self)) // CHECK: true
165161
print(genericAnyIs(type: PCSub.self, to: P.self)) // CHECK-ONONE: true
166162

167-
// CHECK-LABEL: casting types to ObjC protocols with generics:
168-
print("casting types to ObjC protocols with generics:")
169-
print(nongenericAnyIsPObjC(type: PS.self)) // CHECK: false
170-
print(genericAnyIs(type: PS.self, to: PObjC.self)) // CHECK: false
171-
print(nongenericAnyIsPObjC(type: PE.self)) // CHECK: false
172-
print(genericAnyIs(type: PE.self, to: PObjC.self)) // CHECK: false
173-
print(nongenericAnyIsPObjC(type: PC.self)) // CHECK: true
174-
print(genericAnyIs(type: PC.self, to: PObjC.self)) // CHECK-ONONE: true
175-
print(nongenericAnyIsPObjC(type: PCSub.self)) // CHECK: true
176-
print(genericAnyIs(type: PCSub.self, to: PObjC.self)) // CHECK-ONONE: true
177-
178163
// CHECK-LABEL: casting types to protocol & AnyObject existentials:
179164
print("casting types to protocol & AnyObject existentials:")
180165
print(nongenericAnyIsPAndAnyObject(type: PS.self)) // CHECK: false
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %target-run-simple-swift | %FileCheck --check-prefix CHECK --check-prefix CHECK-ONONE --dump-input fail %s
2+
// RUN: %target-build-swift -O %s -o %t/a.out.optimized
3+
// RUN: %target-codesign %t/a.out.optimized
4+
// RUN: %target-run %t/a.out.optimized | %FileCheck %s
5+
// REQUIRES: executable_test
6+
// REQUIRES: objc_interop
7+
8+
import Foundation
9+
10+
protocol P {}
11+
@objc protocol PObjC {}
12+
struct PS: P {}
13+
enum PE: P {}
14+
class PC: P, PObjC {}
15+
class PCSub: PC {}
16+
17+
func nongenericAnyIsPObjC(type: Any.Type) -> Bool {
18+
return type is PObjC.Type
19+
}
20+
func genericAnyIs<T>(type: Any.Type, to: T.Type) -> Bool {
21+
return type is T.Type
22+
}
23+
24+
// CHECK-LABEL: casting types to ObjC protocols with generics:
25+
print("casting types to ObjC protocols with generics:")
26+
print(nongenericAnyIsPObjC(type: PS.self)) // CHECK: false
27+
print(genericAnyIs(type: PS.self, to: PObjC.self)) // CHECK: false
28+
print(nongenericAnyIsPObjC(type: PE.self)) // CHECK: false
29+
print(genericAnyIs(type: PE.self, to: PObjC.self)) // CHECK: false
30+
print(nongenericAnyIsPObjC(type: PC.self)) // CHECK: true
31+
print(genericAnyIs(type: PC.self, to: PObjC.self)) // CHECK-ONONE: true
32+
print(nongenericAnyIsPObjC(type: PCSub.self)) // CHECK: true
33+
print(genericAnyIs(type: PCSub.self, to: PObjC.self)) // CHECK-ONONE: true

0 commit comments

Comments
 (0)