Skip to content

Commit a6b415e

Browse files
Update some tests
1 parent 911040a commit a6b415e

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

lib/Sema/CSSimplify.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7778,7 +7778,7 @@ void ConstraintSystem::addExplicitConversionConstraint(
77787778

77797779
auto locatorPtr = getConstraintLocator(locator);
77807780
auto coerceLocator = [&]() {
7781-
if (addCoercionPathElt) {
7781+
if (addCoercionPathElt && shouldAttemptFixes()) {
77827782
if (auto *expr = dyn_cast_or_null<CoerceExpr>(locator.getAnchor())) {
77837783
// Only adding this path for explicty coercions e.g _ = a as Int
77847784
// and also only for left-side is a DeclRefExpr or a

test/Constraints/bridging.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func rdar19836341(_ ns: NSString?, vns: NSString?) {
292292
// <rdar://problem/20029786> Swift compiler sometimes suggests changing "as!" to "as?!"
293293
func rdar20029786(_ ns: NSString?) {
294294
var s: String = ns ?? "str" as String as String // expected-error{{cannot convert value of type 'NSString?' to expected argument type 'String?'}}{{21-21= as String?}}
295-
var s2 = ns ?? "str" as String as String // expected-error {{cannot convert value of type 'String' to expected argument type 'NSString'}}{{43-43= as NSString}}
295+
var s2 = ns ?? "str" as String as String // expected-error {{cannot convert value of type 'String' to expected argument type 'NSString'}}{{43-43= as NSString}} expected-warning {{casting expression to 'String' doesn't change the type}} {{34-44=}}
296296

297297
let s3: NSString? = "str" as String? // expected-error {{cannot convert value of type 'String?' to specified type 'NSString?'}}{{39-39= as NSString?}}
298298

@@ -346,7 +346,7 @@ func forceUniversalBridgeToAnyObject<T, U: KnownClassProtocol>(a: T, b: U, c: An
346346
z = d as AnyObject
347347
z = e as AnyObject
348348
z = f as AnyObject
349-
z = g as AnyObject
349+
z = g as AnyObject // expected-warning {{casting expression to 'AnyObject' doesn't change the type}} {{9-22=}}
350350
z = h as AnyObject
351351

352352
z = a // expected-error{{does not conform to 'AnyObject'}}

test/Constraints/casts.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ var c2f2: C2<[Float]>? = b as! C3
180180

181181

182182
// <rdar://problem/15633178>
183-
var f: (Float) -> Float = { $0 as Float }
183+
var f: (Float) -> Float = { $0 as Float } // expected-warning {{casting expression to 'Float' doesn't change the type}} {{32-41=}}
184184
var f2: (B) -> Bool = { $0 is D }
185185

186186
func metatype_casts<T, U>(_ b: B.Type, t:T.Type, u: U.Type) {

test/Constraints/construction.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ _ = b as! Derived
9292
// NOTE: Int and other integer-literal convertible types
9393
// are special cased in the library.
9494
Int(i) // expected-warning{{unused}}
95-
_ = i as Int
95+
_ = i as Int // expected-warning {{casting expression to 'Int' doesn't change the type}} {{7-14=}}
9696
Z(z) // expected-error{{cannot invoke initializer for type 'Z' with an argument list of type '(Z)'}}
9797
// expected-note @-1 {{overloads for 'Z' exist with these partially matching parameter lists: (String), (UnicodeScalar)}}
9898

9999
Z.init(z) // expected-error {{cannot invoke 'Z.Type.init' with an argument list of type '(Z)'}}
100100
// expected-note @-1 {{overloads for 'Z.Type.init' exist with these partially matching parameter lists: (String), (UnicodeScalar)}}
101101

102102

103-
_ = z as Z
103+
_ = z as Z // expected-warning {{casting expression to 'Z' doesn't change the type}} {{7-12=}}
104104

105105
// Construction from inouts.
106106
struct FooRef { }

test/Constraints/diagnostics.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ _ = 4(1) // expected-error {{cannot call value of non-function type 'Int'}}
297297
// <rdar://problem/21784170> Incongruous `unexpected trailing closure` error in `init` function which is cast and called without trailing closure.
298298
func rdar21784170() {
299299
let initial = (1.0 as Double, 2.0 as Double)
300-
(Array.init as (Double...) -> Array<Double>)(initial as (Double, Double)) // expected-error {{cannot convert value of type '(Double, Double)' to expected argument type 'Double'}}
300+
(Array.init as (Double...) -> Array<Double>)(initial as (Double, Double)) // expected-error {{cannot convert value of type '(Double, Double)' to expected argument type 'Double'}} // expected-warning {{casting expression to '(Double, Double)' doesn't change the type}} {{56-75=}}
301301
}
302302

303303
// <rdar://problem/21829141> BOGUS: unexpected trailing closure

test/Generics/generic_types.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ var xarray : XArray = [1, 2, 3]
191191
// Type parameters can be referenced only via unqualified name lookup
192192
struct XParam<T> {
193193
func foo(_ x: T) {
194-
_ = x as T // expected-warning {{casting expression to 'T' doesn't change the type}} {{11-16}}
194+
_ = x as T // expected-warning {{casting expression to 'T' doesn't change the type}} {{11-16=}}
195195
}
196196

197197
static func bar(_ x: T) {
198-
_ = x as T // expected-warning {{casting expression to 'T' doesn't change the type}} {{11-16}}
198+
_ = x as T // expected-warning {{casting expression to 'T' doesn't change the type}} {{11-16=}}
199199
}
200200
}
201201

0 commit comments

Comments
 (0)