Skip to content

Commit 497d46f

Browse files
[tests] Spliting literals downcast tests into commom and bridged
1 parent 705e468 commit 497d46f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

test/expr/cast/literals_downcast.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-objc-interop
2-
// REQUIRES: objc_interop
3-
4-
import Foundation
1+
// RUN: %target-typecheck-verify-swift
52

63
let ok = "A" as Character // OK
74
let succeed = "A" as? String // expected-warning {{always succeeds}}
@@ -18,10 +15,6 @@ let okUInt = 1 as UInt // OK
1815
let badUInt = 1 as? UInt // expected-warning {{conditional downcast from literal to 'UInt' always fails; consider using 'as' coercion}} {{none}}
1916
let badUInt1 = 1.0 as? UInt // expected-warning {{cast from 'Double' to unrelated type 'UInt' always fails}}
2017

21-
// Can downcast by bridging
22-
let bridge = "A" as? NSString // expected-warning {{always succeeds}}
23-
let bridge1 = 1 as? NSNumber // expected-warning {{always succeeds}}
24-
2518
// Custom protocol adoption
2619
struct S: ExpressibleByStringLiteral {
2720
typealias StringLiteralType = String
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-typecheck-verify-swift -enable-objc-interop
2+
// REQUIRES: OS=macosx
3+
4+
import Foundation
5+
6+
// Can downcast by bridging
7+
let bridge = "A" as? NSString // expected-warning {{always succeeds}}
8+
let bridge1 = 1 as? NSNumber // expected-warning {{always succeeds}}

0 commit comments

Comments
 (0)